This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Invalid lvalue assignment in ld/emultempl/pe.em with GCC trunk
- From: Danny Smith <danny_smith_0000 at yahoo dot co dot nz>
- To: binutils <binutils at sources dot redhat dot com>
- Cc: nickc at redhat dot com
- Date: Tue, 19 Oct 2004 08:29:02 +1300 (NZDT)
- Subject: Invalid lvalue assignment in ld/emultempl/pe.em with GCC trunk
Build of ld for mingw target with current GCC head fails with:
> LIB_PATH='' /bin/sh ../../src/ld/genscripts.sh ../../src/ld /mingw/lib
"/mingw" i386-pc-mingw32 i386-pc-mingw32 mingw32 "i386pe"
"/usr/local/lib /lib /usr/lib" no i386pe "mingw32"
> gcc.exe -DHAVE_CONFIG_H -I. -I../../src/ld -I. -D_GNU_SOURCE -I.
-I../../src/ld -I../bfd -I../../src/ld/../bfd -I../../src/ld/../include
-I../../src/ld/../intl -I../intl -O2 -fno-exceptions
-DLOCALEDIR="\"/mingw/share/locale\"" -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -O2 -fno-exceptions -c ei386pe.c
> ei386pe.c: In function 'gld_i386pe_after_open':
> ei386pe.c:1089: error: invalid lvalue in assignment
> make[2]: *** [ei386pe.o] Error 1
ei386pe.c:1089 is:
bfd_filename (is->the_bfd) = n;
where bfd_filename macro expands to:
#define bfd_filename(bfd) ((bfd)->my_archive \
? bfd_get_filename ((bfd)->my_archive) \
: bfd_get_filename (bfd))
Conditional expressions as lvalues were deprecated in 3.4.x and give an
unconditional error in 4.0,
It is easy enough (see attached patch) to simplify the logic and get rid
of the lhs conditional by noting that the is->the_bfd->my_archive is
always non-NULL here because we are in a block bracketed by
pe.em:1024: if (is->the_bfd->my_archive)
However, that conditional at pe.em:1024 may be wrong judging from the
ChangeLog entry that introduced the local bfd_filename macro
2004-08-27 Nick Clifton <nickc@redhat.com>
* emultempl/pe.em (after_open): Do not assume that either bfd is
an archive.
If line 1024 is correct, then attached will fix, else I'll submit a revised
patch. Nick, can you give me an example where one or both of the input bfds
is not archive?
Danny
Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com
2004-10-18 Danny Smith <dannysmith@users.sourceforge.net>
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Simplify
comparison and replacement of filenames.
Index: emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.98
diff -c -3 -p -r1.98 pe.em
*** emultempl/pe.em 14 Oct 2004 12:54:45 -0000 1.98
--- emultempl/pe.em 18 Oct 2004 09:02:28 -0000
*************** gld_${EMULATION_NAME}_after_open (void)
*** 1078,1084 ****
{
struct bfd_symbol *s;
struct bfd_link_hash_entry * blhe;
! bfd *other_bfd;
char *n;
s = (relocs[i]->sym_ptr_ptr)[0];
--- 1078,1084 ----
{
struct bfd_symbol *s;
struct bfd_link_hash_entry * blhe;
! char* other_bfd_filename;
char *n;
s = (relocs[i]->sym_ptr_ptr)[0];
*************** gld_${EMULATION_NAME}_after_open (void)
*** 1095,1114 ****
|| blhe->type != bfd_link_hash_defined)
continue;
! other_bfd = blhe->u.def.section->owner;
! #define bfd_filename(bfd) ((bfd)->my_archive ? bfd_get_filename ((bfd)->my_archive) : bfd_get_filename (bfd))
! if (strcmp (bfd_filename (is->the_bfd),
! bfd_filename (other_bfd)) == 0)
continue;
/* Rename this implib to match the other one. */
! n = xmalloc (strlen (bfd_filename (other_bfd)) + 1);
!
! strcpy (n, bfd_filename (other_bfd));
!
! bfd_filename (is->the_bfd) = n;
! #undef bfd_filename
}
free (relocs);
--- 1095,1113 ----
|| blhe->type != bfd_link_hash_defined)
continue;
! other_bfd_filename
! = blhe->u.def.section->owner->my_archive
! ? bfd_get_filename (blhe->u.def.section->owner->my_archive)
! : bfd_get_filename (blhe->u.def.section->owner);
! if (strcmp (bfd_get_filename (is->the_bfd->my_archive),
! other_bfd_filename) == 0)
continue;
/* Rename this implib to match the other one. */
! n = xmalloc (strlen (other_bfd_filename) + 1);
! strcpy (n, other_bfd_filename);
! is->the_bfd->my_archive->filename = n;
}
free (relocs);