Invalid lvalue assignment in ld/emultempl/pe.em with GCC trunk

Danny Smith danny_smith_0000@yahoo.co.nz
Mon Oct 18 19:29:00 GMT 2004


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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pe.em.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20041018/c2caf6de/attachment.ksh>


More information about the Binutils mailing list