This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Oct 4, 2013, at 12:45 PM, Richard Sandiford <rdsandiford@googlemail.com> wrote:

> Hi Tristian,
> 
> Just wanted to check, is it OK to backport this to 2.24?

Yes, please.

> 
> Thanks,
> Richard
> 
> Richard Sandiford <rdsandiford@googlemail.com> writes:
>> Gregory Fong <gregory.0xf0@gmail.com> writes:
>>> 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).
>> 
>> Thanks for going through with the copyright assignment.  I updated the
>> patch to current mainline (just a few minor testsuite changes) and applied
>> it as below.
>> 
>> Tristan, I'd like this to go in 2.24 too if that's OK.
>> 
>> Thanks,
>> Richard
>> 
>> 
>> bfd/
>> 2013-09-24  Gregory Fong  <gregory.0xf0@gmail.com>
>> 
>> 	* elfxx-mips.c (mips_elf_create_got_section): Hide
>> 	_GLOBAL_OFFSET_TABLE_.
>> 
>> ld/testsuite/
>> 2013-09-24  Gregory Fong  <gregory.0xf0@gmail.com>
>> 
>> 	* ld-mips-elf/eh-frame5.d, ld-mips-elf/jalx-2.dd,
>> 	ld-mips-elf/mips-elf.exp, ld-mips-elf/mips16-pic-2.ad,
>> 	ld-mips-elf/mips16-pic-2.nd, ld-mips-elf/pic-and-nonpic-3a.dd,
>> 	ld-mips-elf/pic-and-nonpic-3b.ad, ld-mips-elf/pic-and-nonpic-3b.dd,
>> 	ld-mips-elf/pic-and-nonpic-3b.nd, ld-mips-elf/pic-and-nonpic-4b.ad,
>> 	ld-mips-elf/pic-and-nonpic-4b.nd, ld-mips-elf/pic-and-nonpic-4b.rd,
>> 	ld-mips-elf/pic-and-nonpic-5b.ad, ld-mips-elf/pic-and-nonpic-5b.nd,
>> 	ld-mips-elf/pic-and-nonpic-6-n32.ad,
>> 	ld-mips-elf/pic-and-nonpic-6-n32.dd,
>> 	ld-mips-elf/pic-and-nonpic-6-n32.nd,
>> 	ld-mips-elf/pic-and-nonpic-6-n64.ad,
>> 	ld-mips-elf/pic-and-nonpic-6-n64.dd,
>> 	ld-mips-elf/pic-and-nonpic-6-n64.nd,
>> 	ld-mips-elf/pic-and-nonpic-6-o32.ad,
>> 	ld-mips-elf/pic-and-nonpic-6-o32.dd,
>> 	ld-mips-elf/pic-and-nonpic-6-o32.nd, ld-mips-elf/rel32-n32.d,
>> 	ld-mips-elf/rel32-o32.d, ld-mips-elf/rel64.d,
>> 	ld-mips-elf/tls-multi-got-1.got, ld-mips-elf/tls-multi-got-1.r,
>> 	ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-1.got,
>> 	ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.got,
>> 	ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-3.got,
>> 	ld-mips-elf/tlsdyn-o32.d, ld-mips-elf/tlsdyn-o32.got,
>> 	ld-mips-elf/tlslib-o32-ver.got, ld-mips-elf/tlslib-o32.got: Update
>> 	for removal of _GLOBAL_OFFSET_TABLE_ from .dynsym.
>> 
>> Index: bfd/elfxx-mips.c
>> ===================================================================
>> --- bfd/elfxx-mips.c	2013-09-24 21:49:27.682432333 +0100
>> +++ bfd/elfxx-mips.c	2013-09-24 21:50:54.826233086 +0100
>> @@ -5017,6 +5017,7 @@ mips_elf_create_got_section (bfd *abfd,
>>   h->non_elf = 0;
>>   h->def_regular = 1;
>>   h->type = STT_OBJECT;
>> +  h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
>>   elf_hash_table (info)->hgot = h;
>> 
>>   if (info->shared
> [snipped]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]