[PATCH] Fix --as-needed for MIPS.
David Daney
ddaney@avtrex.com
Fri Jul 29 04:18:00 GMT 2005
As noted in these threads:
http://sourceware.org/ml/binutils/2005-07/msg00476.html
http://sourceware.org/ml/binutils/2005-07/msg00490.html
ld --as-needed seems to be broken for my mipsel-linux cross tool chain.
Quoting from the e-mail threads:
<quote>
It seems that the linker thinks that any shared object that references
the magic _gp_disp symbol actually provides it. Since all mips objects
reference _gp_disp, ld thinks that all shared objects are required to
resolve all the other _gp_disp references. This causes all shared
objects specified with --as-needed to be deemed needed and get a
DT_NEEDED entry.
The linker automagically resolves _gp_disp so this symbol should not
cause a shared library to be needed.
I hope that makes at least a little sense.
I suspect that the problem is mips specific as _gp_disp handling is mips
specific.
And:
Here is my current plan:
$ mipsel-linux-readelf -s -D -W
/usr/local/mipsel-linux-3.4.3/lib/libc-2.3.3.so | grep SECTION
131 324: 0019bfb0 0 SECTION GLOBAL DEFAULT ABS _gp_disp
This seems to be where ld thinks that _gp_disp is defined by shared objects.
I can detect this special case in _bfd_mips_elf_add_symbol_hook() and
cause it to be ignored, thus solving the problem.
Does this seem like a reasonable course of action?
I am not sure how that dynamic symbol got into the shared objects in the
first place. I suppose if the proper solution was to not put it there in
the first place, I could fix that and rebuild the world. But that would
be much more work.
</quote>
The attached patch seems to correct the problem.
Tested with a cross build running on i686-pc-linux configured as:
../src/configure --target=mipsel-linux
--prefix=/usr/local/mipsel-linux-3.4.3
--with-sysroot=/usr/local/mipsel-linux-3.4.3
make -k check with no regressions.
2005-07-29 David Daney <ddaney@avtrex.com>
* elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Ignore _gp_disp
if it is not in the *UND* section.
O.K. to commit?
David Daney
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b.p
Type: text/x-pascal
Size: 920 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050729/2a8593bb/attachment.bin>
More information about the Binutils
mailing list