Don't add DT_DEBUG to MIPS shared libraries

David Daney ddaney@avtrex.com
Thu Oct 19 17:40:00 GMT 2006


Richard Sandiford wrote:
> This patch is the first in a series to support prelinking on MIPS.
> 
> The prelinker uses DT_DEBUG as a heuristic to distinguish shared
> libraries from position-independent executables.  However, the
> "traditional MIPS" bfd target creates DT_DEBUG tags for all dynamic
> objects.  This would cause all unused shared libraries to be entered
> into the prelink cache as "not prelinkable", which affects -q prelinks
> if those libraries are later used by new executables.
> 
> The traditional MIPS target was added for mips-dde-sysv4.2MP.
> I can't find any discussion in the archives about why that target
> needed DT_DEBUG tags to be added to shared libraries (or indeed
> whether it was needed for correctness at all, rather than just being
> something that was done for consistency with the native tools).
> 
> It's very difficult to keep a target like mips-dde-sysv4.2MP
> working with so little information.  Given that the tag is of
> no use on GNU/Linux targets, and given that the DT_DEBUG heuristic
> could well be used by tools other than the prelinker, I think it's
> best to just be consistent with other targets.  This patch therefore
> removes DT_DEBUG tags from shared libraries and makes sure that the
> PIEs do indeed get DT_DEBUG and DT_MIPS_RLD_MAP tags.
> 
> Tested on mips{,64}{,el}-{elf,linux-gnu} and mips-sgi-irix6.5.
> OK to install?
> 
> Richard
> 
> 
> bfd/
> 	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Add DT_DEBUG
> 	and DT_MIPS_RLD_MAP tags for position-independent executables.
> 	Do not add DT_DEBUG to shared libraries for any MIPS target.
> 
> ld/testsuite/
> 	* ld-mips-elf/multi-got-1.d: Remove DT_DEBUG tag.  Do not require
> 	a specific file offset for .dynamic.  Reduce DT_HASH by 8 to account
> 	for removed tag.
> 	* ld-mips-elf/tls-multi-got-1.r: Likewise.  Also reduce DT_REL by 8.
> 	Reduce PLTGOT and symbol values by 16 to account for the removed tag.
> 	* ld-mips-elf/textrel-1.d: Remove DT_DEBUG tag.
> 	* ld-mips-elf/rel32-n32.d: Reduce addresses by 16 to account for
> 	removed DT_DEBUG tag.
> 	* ld-mips-elf/rel64.d: Likewise.
> 	* ld-mips-elf/tls-multi-got-1.got: Likewise.
> 	* ld-mips-elf/tlslib-o32-hidden.got: Likewise.

This may break libgcj.  I think the boehm-gc uses DT_DEBUG in libgcj.so.

Looking at the code now, It is difficult to see how it ever worked 
right.  I have some local uClibc patches for it, but it has been a while 
since I worked with it, so the issue is a little unclear to me right now.

Given that I am probably a bit confused is no reason to not do this.  I 
just wanted to note that there may be the potential for breakage.

Really I think it is a good idea as I would very much like to to 
pre-linking.  On the off chance that it does break libgcj, I will fix it.

David Daney



More information about the Binutils mailing list