This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix bfd build with CVS glibc
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 16 Aug 2007 12:58:00 +0200
- Subject: [PATCH] Fix bfd build with CVS glibc
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
open in CVS glibc with -D_FORTIFY_SOURCE{,=2} is implemented as
a function-like macro so that it can check for invalid open uses
like open ("foo", O_CREAT|O_RDWR); or
open ("foo", flags); where flags is not known at compile time,
but at runtime contains O_CREAT bit set.
This is not violating POSIX, as POSIX permits standard functions
to be implemented as function-like macros.
opncls.c includes <fcntl.h>, so open can be implemented as function-like
macro and is in the glibc case.
The following spot in bfd_openr_iovec doesn't call open function though,
but calls a function pointer open passed as parameter to the function.
The following prevents it being expanded as function-like macro, ok for
trunk and 2.18 branch?
Alternative fix would be (also standard conforming) #undef open after
including the headers, but that would mean the real open(1) calls
in the file are not checked.
2007-08-16 Jakub Jelinek <jakub@redhat.com>
* opncls.c (bfd_openr_iovec): Surround open with parentheses.
--- bfd/opncls.c.jj 2007-08-01 09:11:48.000000000 -0400
+++ bfd/opncls.c 2007-08-16 06:23:39.000000000 -0400
@@ -545,7 +545,7 @@ bfd_openr_iovec (const char *filename, c
nbfd->filename = filename;
nbfd->direction = read_direction;
- stream = open (nbfd, open_closure);
+ stream = (open) (nbfd, open_closure);
if (stream == NULL)
{
_bfd_delete_bfd (nbfd);
Jakub