[PATCH] mips/bfd/ld: Fix --as-needed on mips and update related ld tests

Gregory Fong gregory.0xf0@gmail.com
Wed May 29 23:50:00 GMT 2013


Hello,

Attached are two patches regarding a bug with --as-needed on mips that
causes the following error when using --as-needed (example for a small
test program):

/bin/sh ../libtool --tag=CC --mode=link mipsel-linux-gcc -I../include
-g -O2 -Wl,--as-needed -o test-example test.o ../lib/libTestGcc.la
libtool: link: mipsel-linux-gcc -I../include -g -O2 -Wl,--as-needed -o
.libs/test-example test.o ../lib/.libs/libTestGcc.so -Wl,-rpath
-Wl,/usr/local/lib
../lib/.libs/libTestGcc.so:(.got+0x0): multiple definition of
`_GLOBAL_OFFSET_TABLE_'
collect2: ld returned 1 exit status

The first patch fixes the bug by hiding _GLOBAL_OFFSET_TABLE_ in
elfxx-mips.c .  I know there was some concern that
_GLOBAL_OFFSET_TABLE_ possibly needs to be dynamic on some mips setups
(Eric mentioned SGI).  It doesn't seem to be an issue on my setup but
I thought I'd mention it here in case that comes up for someone.

The second patch updates the ld mips elf tests to account for
the change to _GLOBAL_OFFSET_TABLE_.  I ran them using `make
check' from an x86_64-linux host with target mipsel-linux-uclibc.

Follows up on the thread started by Vincent Wen (Re: binutils 2.19.92
linker broke with --as-needed flag).  For reference, see:

original email:
https://lists.gnu.org/archive/html/bug-binutils/2013-02/msg00016.html
discussion: http://sourceware.org/ml/binutils/2013-03/msg00289.html
discussion: http://sourceware.org/ml/binutils/2013-04/msg00004.html

Based off of Hans-Peter Nilsson's Nov 2004 change to hide
_GLOBAL_OFFSET_TABLE_ (see
http://sourceware.org/ml/binutils-cvs/2004-11/msg00003.html).


This is my first patch submission here, so I'm sure I got a few things
wrong.  Any feedback is greatly appreciated! =)

Best regards,

--
 Gregory Fong
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-2.23.2-bfd-elfxx-mips.patch
Type: application/octet-stream
Size: 476 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20130529/a92bd8b1/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-2.23.2-ld-mips-elf_testsuite_updates.patch
Type: application/octet-stream
Size: 32221 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20130529/a92bd8b1/attachment-0001.obj>


More information about the Binutils mailing list