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]

Don't add DT_DEBUG to MIPS shared libraries


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


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