public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Don't add DT_DEBUG to MIPS shared libraries
@ 2006-10-19 11:11 Richard Sandiford
  2006-10-19 14:04 ` Eric Christopher
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Richard Sandiford @ 2006-10-19 11:11 UTC (permalink / raw)
  To: binutils

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.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.184
diff -u -p -r1.184 elfxx-mips.c
--- bfd/elfxx-mips.c	17 Oct 2006 13:41:47 -0000	1.184
+++ bfd/elfxx-mips.c	19 Oct 2006 08:04:32 -0000
@@ -7478,7 +7478,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd
 	 must add the entries now so that we get the correct size for
 	 the .dynamic section.  The DT_DEBUG entry is filled in by the
 	 dynamic linker and used by the debugger.  */
-      if (! info->shared)
+      if (info->executable)
 	{
 	  /* SGI object has the equivalence of DT_DEBUG in the
 	     DT_MIPS_RLD_MAP entry.  */
@@ -7490,15 +7490,6 @@ _bfd_mips_elf_size_dynamic_sections (bfd
 		return FALSE;
 	    }
 	}
-      else
-	{
-	  /* Shared libraries on traditional mips have DT_DEBUG.  */
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
-		return FALSE;
-	    }
-	}
 
       if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks))
 	info->flags |= DF_TEXTREL;
Index: ld/testsuite/ld-mips-elf/multi-got-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/multi-got-1.d,v
retrieving revision 1.7
diff -u -p -r1.7 multi-got-1.d
--- ld/testsuite/ld-mips-elf/multi-got-1.d	5 Jul 2006 16:01:38 -0000	1.7
+++ ld/testsuite/ld-mips-elf/multi-got-1.d	19 Oct 2006 08:04:32 -0000
@@ -5,14 +5,13 @@
 #ld: -melf32btsmip -shared
 #readelf: -d -r
 
-Dynamic section at offset 0xcc contains 18 entries:
+Dynamic section at offset .* contains 17 entries:
   Tag        Type                         Name/Value
- 0x00000004 \(HASH\)                       0x184
+ 0x00000004 \(HASH\)                       0x17c
  0x00000005 \(STRTAB\)                     0x[0-9a-f]+
  0x00000006 \(SYMTAB\)                     0x[0-9a-f]+
  0x0000000a \(STRSZ\)                      [0-9]+ \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
- 0x00000015 \(DEBUG\)                      0x0
  0x00000003 \(PLTGOT\)                     0x[0-9a-f]+
  0x00000011 \(REL\)                        0x[0-9a-f]+
  0x00000012 \(RELSZ\)                      65544 \(bytes\)
Index: ld/testsuite/ld-mips-elf/tls-multi-got-1.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tls-multi-got-1.r,v
retrieving revision 1.4
diff -u -p -r1.4 tls-multi-got-1.r
--- ld/testsuite/ld-mips-elf/tls-multi-got-1.r	17 Oct 2006 13:41:48 -0000	1.4
+++ ld/testsuite/ld-mips-elf/tls-multi-got-1.r	19 Oct 2006 08:04:32 -0000
@@ -1,14 +1,13 @@
 
-Dynamic section at offset 0xec contains 19 entries:
+Dynamic section at offset .* contains 18 entries:
   Tag        Type                         Name/Value
- 0x00000004 \(HASH\)                       0x1ac
+ 0x00000004 \(HASH\)                       0x1a4
  0x00000005 \(STRTAB\).*
  0x00000006 \(SYMTAB\).*
  0x0000000a \(STRSZ\)                      220091 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
- 0x00000015 \(DEBUG\)                      0x0
- 0x00000003 \(PLTGOT\)                     0x122410
- 0x00000011 \(REL\)                        0xa7960
+ 0x00000003 \(PLTGOT\)                     0x122400
+ 0x00000011 \(REL\)                        0xa7958
  0x00000012 \(RELSZ\)                      160072 \(bytes\)
  0x00000013 \(RELENT\)                     8 \(bytes\)
  0x70000001 \(MIPS_RLD_VERSION\)           1
@@ -32,9 +31,9 @@ Relocation section '\.rel\.dyn' at offse
 [0-9a-f ]+R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
 [0-9a-f ]+R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
 [0-9a-f ]+R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
-[0-9a-f ]+R_MIPS_REL32      000d8038   sym_1_9526
-[0-9a-f ]+R_MIPS_REL32      000d6694   sym_1_7885
+[0-9a-f ]+R_MIPS_REL32      000d8028   sym_1_9526
+[0-9a-f ]+R_MIPS_REL32      000d6684   sym_1_7885
 #...
-[0-9a-f ]+R_MIPS_REL32      000cf2a4   sym_1_0465
-[0-9a-f ]+R_MIPS_REL32      000e0ee8   sym_2_8654
+[0-9a-f ]+R_MIPS_REL32      000cf294   sym_1_0465
+[0-9a-f ]+R_MIPS_REL32      000e0ed8   sym_2_8654
 #...
Index: ld/testsuite/ld-mips-elf/textrel-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/textrel-1.d,v
retrieving revision 1.3
diff -u -p -r1.3 textrel-1.d
--- ld/testsuite/ld-mips-elf/textrel-1.d	16 Oct 2006 21:34:25 -0000	1.3
+++ ld/testsuite/ld-mips-elf/textrel-1.d	19 Oct 2006 08:04:32 -0000
@@ -4,14 +4,13 @@
 #ld: -shared -melf32btsmipn32
 #readelf: -d
 
-Dynamic section at offset .* contains 18 entries:
+Dynamic section at offset .* contains 17 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x[0-9a-f]*
  0x00000005 \(STRTAB\)                     0x[0-9a-f]*
  0x00000006 \(SYMTAB\)                     0x[0-9a-f]*
  0x0000000a \(STRSZ\)                      [0-9]* \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
- 0x00000015 \(DEBUG\)                      0x0
  0x00000003 \(PLTGOT\)                     0x[0-9a-f]*
  0x00000011 \(REL\)                        0x[0-9a-f]*
  0x00000012 \(RELSZ\)                      8 \(bytes\)
Index: ld/testsuite/ld-mips-elf/rel32-n32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/rel32-n32.d,v
retrieving revision 1.10
diff -u -p -r1.10 rel32-n32.d
--- ld/testsuite/ld-mips-elf/rel32-n32.d	18 Oct 2006 12:34:19 -0000	1.10
+++ ld/testsuite/ld-mips-elf/rel32-n32.d	19 Oct 2006 08:04:32 -0000
@@ -10,6 +10,6 @@ Relocation section '.rel.dyn' at offset 
 [0-9a-f ]+R_MIPS_REL32     
 
 Hex dump of section '.text':
-  0x000002d0 00000000 00000000 00000000 00000000 ................
-  0x000002e0 000002e0 00000000 00000000 00000000 ................
-  0x000002f0 00000000 00000000 00000000 00000000 ................
+  0x000002c0 00000000 00000000 00000000 00000000 ................
+  0x000002d0 000002d0 00000000 00000000 00000000 ................
+  0x000002e0 00000000 00000000 00000000 00000000 ................
Index: ld/testsuite/ld-mips-elf/rel64.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/rel64.d,v
retrieving revision 1.8
diff -u -p -r1.8 rel64.d
--- ld/testsuite/ld-mips-elf/rel64.d	17 Oct 2006 13:41:48 -0000	1.8
+++ ld/testsuite/ld-mips-elf/rel64.d	19 Oct 2006 08:04:32 -0000
@@ -14,6 +14,6 @@ Relocation section '.rel.dyn' at offset 
  +Type3: R_MIPS_NONE      
 
 Hex dump of section '.text':
-  0x00000430 00000000 00000000 00000000 00000000 ................
-  0x00000440 00000000 00000440 00000000 00000000 ................
-  0x00000450 00000000 00000000 00000000 00000000 ................
+  0x00000420 00000000 00000000 00000000 00000000 ................
+  0x00000430 00000000 00000430 00000000 00000000 ................
+  0x00000440 00000000 00000000 00000000 00000000 ................
Index: ld/testsuite/ld-mips-elf/tls-multi-got-1.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tls-multi-got-1.got,v
retrieving revision 1.4
diff -u -p -r1.4 tls-multi-got-1.got
--- ld/testsuite/ld-mips-elf/tls-multi-got-1.got	17 Oct 2006 13:41:48 -0000	1.4
+++ ld/testsuite/ld-mips-elf/tls-multi-got-1.got	19 Oct 2006 08:04:32 -0000
@@ -4,17 +4,17 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-001495c0 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0013f938 R_MIPS_TLS_DTPMOD32  \*ABS\*
-001495cc R_MIPS_TLS_DTPMOD32  tlsvar_gd
-001495d0 R_MIPS_TLS_DTPREL32  tlsvar_gd
-0013f944 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-0013f948 R_MIPS_TLS_DTPREL32  tlsvar_gd
-001495c8 R_MIPS_TLS_TPREL32  tlsvar_ie
-0013f940 R_MIPS_TLS_TPREL32  tlsvar_ie
-00143f6c R_MIPS_REL32      sym_1_9526
+001495b0 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0013f928 R_MIPS_TLS_DTPMOD32  \*ABS\*
+001495bc R_MIPS_TLS_DTPMOD32  tlsvar_gd
+001495c0 R_MIPS_TLS_DTPREL32  tlsvar_gd
+0013f934 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+0013f938 R_MIPS_TLS_DTPREL32  tlsvar_gd
+001495b8 R_MIPS_TLS_TPREL32  tlsvar_ie
+0013f930 R_MIPS_TLS_TPREL32  tlsvar_ie
+00143f5c R_MIPS_REL32      sym_1_9526
 #...
-00139bc0 R_MIPS_REL32      sym_2_8654
+00139bb0 R_MIPS_REL32      sym_2_8654
 00000000 R_MIPS_NONE       \*ABS\*
 00000000 R_MIPS_NONE       \*ABS\*
 00000000 R_MIPS_NONE       \*ABS\*
@@ -40,19 +40,19 @@ OFFSET   TYPE              VALUE 
 
 
 Contents of section .got:
- 122410 00000000 80000000 00000000 00000000  .*
+ 122400 00000000 80000000 00000000 00000000  .*
+ 122410 00000000 00000000 00000000 00000000  .*
  122420 00000000 00000000 00000000 00000000  .*
- 122430 00000000 00000000 00000000 00000000  .*
- 122440 00000000 000d8038 000d6694 000d2044  .*
+ 122430 00000000 000d8028 000d6684 000d2034  .*
 #...
+ 13f910 00000000 00000000 00000000 00000000  .*
  13f920 00000000 00000000 00000000 00000000  .*
  13f930 00000000 00000000 00000000 00000000  .*
- 13f940 00000000 00000000 00000000 00000000  .*
- 13f950 80000000 00000000 00000000 00000000  .*
+ 13f940 80000000 00000000 00000000 00000000  .*
 #...
+ 149580 00000000 00000000 00000000 00000000  .*
  149590 00000000 00000000 00000000 00000000  .*
  1495a0 00000000 00000000 00000000 00000000  .*
  1495b0 00000000 00000000 00000000 00000000  .*
- 1495c0 00000000 00000000 00000000 00000000  .*
- 1495d0 00000000                             .*
+ 1495c0 00000000                             .*
 #pass
Index: ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got,v
retrieving revision 1.3
diff -u -p -r1.3 tlslib-o32-hidden.got
--- ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got	17 Oct 2006 13:41:48 -0000	1.3
+++ ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got	19 Oct 2006 08:04:32 -0000
@@ -4,13 +4,13 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-000403cc R_MIPS_TLS_DTPMOD32  \*ABS\*
-000403c4 R_MIPS_TLS_DTPMOD32  \*ABS\*
-000403c0 R_MIPS_TLS_TPREL32  \*ABS\*
+000403bc R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403b4 R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403b0 R_MIPS_TLS_TPREL32  \*ABS\*
 
 
 Contents of section .got:
- 403a0 00000000 80000000 00000000 00000000  ................
- 403b0 00000000 00000000 00000000 00000370  ................
- 403c0 00000008 00000000 00000000 00000000  ................
- 403d0 ffff8004                             ....            
+ 40390 00000000 80000000 00000000 00000000  ................
+ 403a0 00000000 00000000 00000000 00000360  ................
+ 403b0 00000008 00000000 00000000 00000000  ................
+ 403c0 ffff8004                             ....            

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2006-10-19 11:11 Don't add DT_DEBUG to MIPS shared libraries Richard Sandiford
@ 2006-10-19 14:04 ` Eric Christopher
  2006-10-19 14:09 ` Thiemo Seufer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Eric Christopher @ 2006-10-19 14:04 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils



> OK to install?
>

OK.

thanks.

-eric

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2006-10-19 11:11 Don't add DT_DEBUG to MIPS shared libraries Richard Sandiford
  2006-10-19 14:04 ` Eric Christopher
@ 2006-10-19 14:09 ` Thiemo Seufer
  2006-10-19 17:40 ` David Daney
  2007-03-29 23:56 ` Sergey Rogozhkin
  3 siblings, 0 replies; 9+ messages in thread
From: Thiemo Seufer @ 2006-10-19 14:09 UTC (permalink / raw)
  To: binutils, richard

Richard Sandiford wrote:
[snip]
> 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.

Also ok with me.


Thiemo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2006-10-19 11:11 Don't add DT_DEBUG to MIPS shared libraries Richard Sandiford
  2006-10-19 14:04 ` Eric Christopher
  2006-10-19 14:09 ` Thiemo Seufer
@ 2006-10-19 17:40 ` David Daney
  2006-10-19 18:12   ` Richard Sandiford
  2007-03-29 23:56 ` Sergey Rogozhkin
  3 siblings, 1 reply; 9+ messages in thread
From: David Daney @ 2006-10-19 17:40 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2006-10-19 17:40 ` David Daney
@ 2006-10-19 18:12   ` Richard Sandiford
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Sandiford @ 2006-10-19 18:12 UTC (permalink / raw)
  To: David Daney; +Cc: binutils

David Daney <ddaney@avtrex.com> writes:
> Richard Sandiford wrote:
>> 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.

Doh!  Thanks for the heads-up.  I was completely unaware of this
potential issue.

> 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.

That's great, thanks. ;)

Richard

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2006-10-19 11:11 Don't add DT_DEBUG to MIPS shared libraries Richard Sandiford
                   ` (2 preceding siblings ...)
  2006-10-19 17:40 ` David Daney
@ 2007-03-29 23:56 ` Sergey Rogozhkin
  2007-04-12 15:55   ` Richard Sandiford
  3 siblings, 1 reply; 9+ messages in thread
From: Sergey Rogozhkin @ 2007-03-29 23:56 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils


> 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.

It seems this patch broke PIE startup on linux-mips. bfd/elfxx-mips.c
code creates DT_MIPS_RLD_MAP entry for pie but doesn't set its value
(leave it equal to 0). On pie startup, dynamic linker tries to save
debug structure address to the place pointed by DT_MIPS_RLD_MAP tag
value. So now it doesn't work even if pie load address is equal to its
link address. Maybe I miss something or my configuration is wrong?
I use glibc-2.3.6 and binutils-2.17.50.0.12.

Sergey Rogozhkin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2007-03-29 23:56 ` Sergey Rogozhkin
@ 2007-04-12 15:55   ` Richard Sandiford
  2007-04-12 18:14     ` Thiemo Seufer
  2007-04-13 11:19     ` Sergey Rogozhkin
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Sandiford @ 2007-04-12 15:55 UTC (permalink / raw)
  To: Sergey Rogozhkin; +Cc: binutils

Sergey Rogozhkin <rogozhkin@niisi.msk.ru> writes:
>> 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.
>
> It seems this patch broke PIE startup on linux-mips. bfd/elfxx-mips.c
> code creates DT_MIPS_RLD_MAP entry for pie but doesn't set its value
> (leave it equal to 0). On pie startup, dynamic linker tries to save
> debug structure address to the place pointed by DT_MIPS_RLD_MAP tag
> value. So now it doesn't work even if pie load address is equal to its
> link address. Maybe I miss something or my configuration is wrong?
> I use glibc-2.3.6 and binutils-2.17.50.0.12.

Sorry for the breakage, and for the long time it has taken me to reply.

All the other .rld_map code is indeed guarded with !info->shared rather
than info->executable, and I don't really have time to look at whether
that should change or not.  I don't use PIEs myself, but it sounds
like you do, and that they worked OK before the patch.  I'd therefore
like to restore the original !info->shared check for the RTLD_MAP code
while keeping the new info->executable check for the DT_DEBUG code.

Tested on mips64-linux-gnu.  OK to install?

Richard


bfd/
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Don't add
	DT_MIPS_RTLD_MAP for PIEs.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.198
diff -u -p -r1.198 elfxx-mips.c
--- bfd/elfxx-mips.c	26 Mar 2007 10:29:35 -0000	1.198
+++ bfd/elfxx-mips.c	12 Apr 2007 15:32:50 -0000
@@ -7575,18 +7575,16 @@ _bfd_mips_elf_size_dynamic_sections (bfd
 	 must add the entries now so that we get the correct size for
 	 the .dynamic section.  The DT_DEBUG entry is filled in by the
 	 dynamic linker and used by the debugger.  */
-      if (info->executable)
-	{
-	  /* SGI object has the equivalence of DT_DEBUG in the
-	     DT_MIPS_RLD_MAP entry.  */
-	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
-	    return FALSE;
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
-		return FALSE;
-	    }
-	}
+      if (info->executable
+	  && !SGI_COMPAT (output_bfd)
+	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+	return FALSE;
+
+      /* SGI object has the equivalence of DT_DEBUG in the
+	 DT_MIPS_RLD_MAP entry.  */
+      if (!info->shared
+	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
+	return FALSE;
 
       if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks))
 	info->flags |= DF_TEXTREL;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2007-04-12 15:55   ` Richard Sandiford
@ 2007-04-12 18:14     ` Thiemo Seufer
  2007-04-13 11:19     ` Sergey Rogozhkin
  1 sibling, 0 replies; 9+ messages in thread
From: Thiemo Seufer @ 2007-04-12 18:14 UTC (permalink / raw)
  To: Sergey Rogozhkin, binutils, richard

Richard Sandiford wrote:
> Sergey Rogozhkin <rogozhkin@niisi.msk.ru> writes:
> >> 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.
> >
> > It seems this patch broke PIE startup on linux-mips. bfd/elfxx-mips.c
> > code creates DT_MIPS_RLD_MAP entry for pie but doesn't set its value
> > (leave it equal to 0). On pie startup, dynamic linker tries to save
> > debug structure address to the place pointed by DT_MIPS_RLD_MAP tag
> > value. So now it doesn't work even if pie load address is equal to its
> > link address. Maybe I miss something or my configuration is wrong?
> > I use glibc-2.3.6 and binutils-2.17.50.0.12.
> 
> Sorry for the breakage, and for the long time it has taken me to reply.
> 
> All the other .rld_map code is indeed guarded with !info->shared rather
> than info->executable, and I don't really have time to look at whether
> that should change or not.  I don't use PIEs myself, but it sounds
> like you do, and that they worked OK before the patch.  I'd therefore
> like to restore the original !info->shared check for the RTLD_MAP code
> while keeping the new info->executable check for the DT_DEBUG code.
> 
> Tested on mips64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> bfd/
> 	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Don't add
> 	DT_MIPS_RTLD_MAP for PIEs.

Ok.


Thiemo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Don't add DT_DEBUG to MIPS shared libraries
  2007-04-12 15:55   ` Richard Sandiford
  2007-04-12 18:14     ` Thiemo Seufer
@ 2007-04-13 11:19     ` Sergey Rogozhkin
  1 sibling, 0 replies; 9+ messages in thread
From: Sergey Rogozhkin @ 2007-04-13 11:19 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

Richard Sandiford wrote:
> Sergey Rogozhkin <rogozhkin@niisi.msk.ru> writes:
>>> 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.
>> It seems this patch broke PIE startup on linux-mips. bfd/elfxx-mips.c
>> code creates DT_MIPS_RLD_MAP entry for pie but doesn't set its value
>> (leave it equal to 0). On pie startup, dynamic linker tries to save
>> debug structure address to the place pointed by DT_MIPS_RLD_MAP tag
>> value. So now it doesn't work even if pie load address is equal to its
>> link address. Maybe I miss something or my configuration is wrong?
>> I use glibc-2.3.6 and binutils-2.17.50.0.12.
> 
> Sorry for the breakage, and for the long time it has taken me to reply.
> 
> All the other .rld_map code is indeed guarded with !info->shared rather
> than info->executable, and I don't really have time to look at whether
> that should change or not.  I don't use PIEs myself, but it sounds
> like you do, and that they worked OK before the patch.  I'd therefore
> like to restore the original !info->shared check for the RTLD_MAP code
> while keeping the new info->executable check for the DT_DEBUG code.
> 
> Tested on mips64-linux-gnu.  OK to install?

Thank you, it works for me now.

There is also another problem with PIE and DT_MIPS_RLD_MAP on mips. Now 
there is no DT_MIPS_RLD_MAP tag in dynamic section of mips PIEs and 
debugger wouldn't operate properly on such executables. But if linker 
add and properly (as possible) initialize DT_MIPS_RLD_MAP tag to PIE, 
next problem arise in dynamic linker. The problem is DT_MIPS_RLD_MAP is 
not an analog of DT_DEBUG, DT_MIPS_RLD_MAP value is calculated by
linker and used by dynamic linker as a legal address of some data inside 
PIE object, but it is not a legal address if PIE load address != PIE 
link address. So, dynamic linker must fix DT_MIPS_RLD_MAP for PIEs by 
adding a base addr of loaded PIE. I don't know if this is an actual 
problem for anybody, but the problem exists.

Sergey Rogozhkin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-04-13 10:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-19 11:11 Don't add DT_DEBUG to MIPS shared libraries Richard Sandiford
2006-10-19 14:04 ` Eric Christopher
2006-10-19 14:09 ` Thiemo Seufer
2006-10-19 17:40 ` David Daney
2006-10-19 18:12   ` Richard Sandiford
2007-03-29 23:56 ` Sergey Rogozhkin
2007-04-12 15:55   ` Richard Sandiford
2007-04-12 18:14     ` Thiemo Seufer
2007-04-13 11:19     ` Sergey Rogozhkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).