bfd/
authorRichard Sandiford <rdsandiford@googlemail.com>
Fri, 20 Oct 2006 07:57:03 +0000 (07:57 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Fri, 20 Oct 2006 07:57:03 +0000 (07:57 +0000)
* elfxx-mips.c (_bfd_mips_elf_additional_program_headers): Allocate
a PT_NULL header for dynamic objects.
(_bfd_mips_elf_modify_segment_map): Add it.

ld/testsuite/
* ld-mips-elf/multi-got-1.d: Do not expect a particular address
for DT_HASH.
* ld-mips-elf/rel32-o32.d: Bump addresses by 0x20 to account for
the extra program header.
* ld-mips-elf/rel32-n32.d: Likewise.
* ld-mips-elf/tlslib-o32.got: Likewise.
* ld-mips-elf/tlslib-o32-hidden.got: Likewise.
* ld-mips-elf/tlslib-o32-ver.got: Likewise.
* ld-mips-elf/tls-multi-got-1.got: Likewise.
* ld-mips-elf/tls-multi-got-1.r: Likewise.
* ld-mips-elf/rel64.d: Bump addresses by 0x30 to account for the
extra program header.
* ld-mips-elf/tlsdyn-o32.d: Reduce the GOT offset by 32 to account
for the extra program header, and thus the shorter gap between the
text and data segments.
* ld-mips-elf/tlsdyn-o32-1.d: Likewise.
* ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* ld-mips-elf/tlsdyn-o32.got: Bump GOT text addresses by 0x20
to account for the extra program header.
* ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* ld-mips-elf/tlsdyn-o32-3.got: Likewise.

20 files changed:
bfd/ChangeLog
bfd/elfxx-mips.c
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/multi-got-1.d
ld/testsuite/ld-mips-elf/rel32-n32.d
ld/testsuite/ld-mips-elf/rel32-o32.d
ld/testsuite/ld-mips-elf/rel64.d
ld/testsuite/ld-mips-elf/tls-multi-got-1.got
ld/testsuite/ld-mips-elf/tls-multi-got-1.r
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
ld/testsuite/ld-mips-elf/tlsdyn-o32.d
ld/testsuite/ld-mips-elf/tlsdyn-o32.got
ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
ld/testsuite/ld-mips-elf/tlslib-o32.got

index b8eced6..5a1cbd3 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-20  Richard Sandiford  <richard@codesourcery.com>
+
+       * elfxx-mips.c (_bfd_mips_elf_additional_program_headers): Allocate
+       a PT_NULL header for dynamic objects.
+       (_bfd_mips_elf_modify_segment_map): Add it.
+
 2006-10-19  Mei Ligang  <ligang@sunnorth.com.cn>
 
        * elf32-score.c (score_elf_rel_dyn_section): Replace
index 33b0e43..639a065 100644 (file)
@@ -9169,6 +9169,12 @@ _bfd_mips_elf_additional_program_headers (bfd *abfd,
       && bfd_get_section_by_name (abfd, ".mdebug"))
     ++ret;
 
+  /* Allocate a PT_NULL header in dynamic objects.  See
+     _bfd_mips_elf_modify_segment_map for details.  */
+  if (!SGI_COMPAT (abfd)
+      && bfd_get_section_by_name (abfd, ".dynamic"))
+    ++ret;
+
   return ret;
 }
 
@@ -9377,6 +9383,38 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd,
        }
     }
 
+  /* Allocate a spare program header in dynamic objects so that tools
+     like the prelinker can add an extra PT_LOAD entry.
+
+     If the prelinker needs to make room for a new PT_LOAD entry, its
+     standard procedure is to move the first (read-only) sections into
+     the new (writable) segment.  However, the MIPS ABI requires
+     .dynamic to be in a read-only segment, and the section will often
+     start within sizeof (ElfNN_Phdr) bytes of the last program header.
+
+     Although the prelinker could in principle move .dynamic to a
+     writable segment, it seems better to allocate a spare program
+     header instead, and avoid the need to move any sections.
+     There is a long tradition of allocating spare dynamic tags,
+     so allocating a spare program header seems like a natural
+     extension.  */
+  if (!SGI_COMPAT (abfd)
+      && bfd_get_section_by_name (abfd, ".dynamic"))
+    {
+      for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+       if ((*pm)->p_type == PT_NULL)
+         break;
+      if (*pm == NULL)
+       {
+         m = bfd_zalloc (abfd, sizeof (*m));
+         if (m == NULL)
+           return FALSE;
+
+         m->p_type = PT_NULL;
+         *pm = m;
+       }
+    }
+
   return TRUE;
 }
 \f
index 9584b47..22cdf09 100644 (file)
@@ -1,5 +1,31 @@
 2006-10-20  Richard Sandiford  <richard@codesourcery.com>
 
+       * ld-mips-elf/multi-got-1.d: Do not expect a particular address
+       for DT_HASH.
+       * ld-mips-elf/rel32-o32.d: Bump addresses by 0x20 to account for
+       the extra program header.
+       * ld-mips-elf/rel32-n32.d: Likewise.
+       * ld-mips-elf/tlslib-o32.got: Likewise.
+       * ld-mips-elf/tlslib-o32-hidden.got: Likewise.
+       * ld-mips-elf/tlslib-o32-ver.got: Likewise.
+       * ld-mips-elf/tls-multi-got-1.got: Likewise.
+       * ld-mips-elf/tls-multi-got-1.r: Likewise.
+       * ld-mips-elf/rel64.d: Bump addresses by 0x30 to account for the
+       extra program header.
+       * ld-mips-elf/tlsdyn-o32.d: Reduce the GOT offset by 32 to account
+       for the extra program header, and thus the shorter gap between the
+       text and data segments.
+       * ld-mips-elf/tlsdyn-o32-1.d: Likewise.
+       * ld-mips-elf/tlsdyn-o32-2.d: Likewise.
+       * ld-mips-elf/tlsdyn-o32-3.d: Likewise.
+       * ld-mips-elf/tlsdyn-o32.got: Bump GOT text addresses by 0x20
+       to account for the extra program header.
+       * ld-mips-elf/tlsdyn-o32-1.got: Likewise.
+       * ld-mips-elf/tlsdyn-o32-2.got: Likewise.
+       * ld-mips-elf/tlsdyn-o32-3.got: Likewise.
+
+2006-10-20  Richard Sandiford  <richard@codesourcery.com>
+
        * ld-mips-elf/rel32-o32.d: Bump the section number of .text by 1
        to account for the fact that .rel.dyn is now before .text in the
        section table.
index 610cfad..3912439 100644 (file)
@@ -7,7 +7,7 @@
 
 Dynamic section at offset .* contains 17 entries:
   Tag        Type                         Name/Value
- 0x00000004 \(HASH\)                       0x17c
+ 0x00000004 \(HASH\)                       0x[0-9a-f]+
  0x00000005 \(STRTAB\)                     0x[0-9a-f]+
  0x00000006 \(SYMTAB\)                     0x[0-9a-f]+
  0x0000000a \(STRSZ\)                      [0-9]+ \(bytes\)
index 7adf822..aae33b3 100644 (file)
@@ -10,6 +10,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries:
 [0-9a-f ]+R_MIPS_REL32     
 
 Hex dump of section '.text':
-  0x000002c0 00000000 00000000 00000000 00000000 ................
-  0x000002d0 000002d0 00000000 00000000 00000000 ................
   0x000002e0 00000000 00000000 00000000 00000000 ................
+  0x000002f0 000002f0 00000000 00000000 00000000 ................
+  0x00000300 00000000 00000000 00000000 00000000 ................
index ac82459..742cdaa 100644 (file)
@@ -10,6 +10,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries:
 [0-9a-f ]+R_MIPS_REL32     
 
 Hex dump of section '.text':
-  0x000002c0 00000000 00000000 00000000 00000000 ................
-  0x000002d0 000002d0 00000000 00000000 00000000 ................
   0x000002e0 00000000 00000000 00000000 00000000 ................
+  0x000002f0 000002f0 00000000 00000000 00000000 ................
+  0x00000300 00000000 00000000 00000000 00000000 ................
index 37f95ae..4279e28 100644 (file)
@@ -14,6 +14,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries:
  +Type3: R_MIPS_NONE      
 
 Hex dump of section '.text':
-  0x00000420 00000000 00000000 00000000 00000000 ................
-  0x00000430 00000000 00000430 00000000 00000000 ................
-  0x00000440 00000000 00000000 00000000 00000000 ................
+  0x00000450 00000000 00000000 00000000 00000000 ................
+  0x00000460 00000000 00000460 00000000 00000000 ................
+  0x00000470 00000000 00000000 00000000 00000000 ................
index de7b430..4ee502f 100644 (file)
@@ -4,17 +4,17 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-0013f928 R_MIPS_TLS_DTPMOD32  \*ABS\*
-001495b0 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0013f934 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-0013f938 R_MIPS_TLS_DTPREL32  tlsvar_gd
-001495bc R_MIPS_TLS_DTPMOD32  tlsvar_gd
-001495c0 R_MIPS_TLS_DTPREL32  tlsvar_gd
-0013f930 R_MIPS_TLS_TPREL32  tlsvar_ie
-001495b8 R_MIPS_TLS_TPREL32  tlsvar_ie
-00143f5c R_MIPS_REL32      sym_1_9526
+0013f948 R_MIPS_TLS_DTPMOD32  \*ABS\*
+001495d0 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0013f954 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+0013f958 R_MIPS_TLS_DTPREL32  tlsvar_gd
+001495dc R_MIPS_TLS_DTPMOD32  tlsvar_gd
+001495e0 R_MIPS_TLS_DTPREL32  tlsvar_gd
+0013f950 R_MIPS_TLS_TPREL32  tlsvar_ie
+001495d8 R_MIPS_TLS_TPREL32  tlsvar_ie
+00143f7c R_MIPS_REL32      sym_1_9526
 #...
-00139bb0 R_MIPS_REL32      sym_2_8654
+00139bd0 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:
- 122400 00000000 80000000 00000000 00000000  .*
- 122410 00000000 00000000 00000000 00000000  .*
- 122420 00000000 00000000 00000000 00000000  .*
- 122430 00000000 000d8028 000d6684 000d2034  .*
+ 122420 00000000 80000000 00000000 00000000  .*
+ 122430 00000000 00000000 00000000 00000000  .*
+ 122440 00000000 00000000 00000000 00000000  .*
+ 122450 00000000 000d8048 000d66a4 000d2054  .*
 #...
- 13f910 00000000 00000000 00000000 00000000  .*
- 13f920 00000000 00000000 00000000 00000000  .*
  13f930 00000000 00000000 00000000 00000000  .*
- 13f940 80000000 00000000 00000000 00000000  .*
+ 13f940 00000000 00000000 00000000 00000000  .*
+ 13f950 00000000 00000000 00000000 00000000  .*
+ 13f960 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                             .*
+ 1495c0 00000000 00000000 00000000 00000000  .*
+ 1495d0 00000000 00000000 00000000 00000000  .*
+ 1495e0 00000000                             .*
 #pass
index 3befcd7..c63d230 100644 (file)
@@ -1,13 +1,13 @@
 
 Dynamic section at offset .* contains 18 entries:
   Tag        Type                         Name/Value
- 0x00000004 \(HASH\)                       0x1a4
+ 0x00000004 \(HASH\)                       0x1c4
  0x00000005 \(STRTAB\).*
  0x00000006 \(SYMTAB\).*
  0x0000000a \(STRSZ\)                      220091 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
- 0x00000003 \(PLTGOT\)                     0x122400
- 0x00000011 \(REL\)                        0xa7958
+ 0x00000003 \(PLTGOT\)                     0x122420
+ 0x00000011 \(REL\)                        0xa7978
  0x00000012 \(RELSZ\)                      160072 \(bytes\)
  0x00000013 \(RELENT\)                     8 \(bytes\)
  0x70000001 \(MIPS_RLD_VERSION\)           1
@@ -31,9 +31,9 @@ Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains 20031 entries:
 [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      000d8028   sym_1_9526
-[0-9a-f ]+R_MIPS_REL32      000d6684   sym_1_7885
+[0-9a-f ]+R_MIPS_REL32      000d8048   sym_1_9526
+[0-9a-f ]+R_MIPS_REL32      000d66a4   sym_1_7885
 #...
-[0-9a-f ]+R_MIPS_REL32      000cf294   sym_1_0465
-[0-9a-f ]+R_MIPS_REL32      000e0ed8   sym_2_8654
+[0-9a-f ]+R_MIPS_REL32      000cf2b4   sym_1_0465
+[0-9a-f ]+R_MIPS_REL32      000e0ef8   sym_2_8654
 #...
index d416a87..3637049 100644 (file)
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7ba0        addiu   gp,gp,31648
+  .*:  279c7b80        addiu   gp,gp,31616
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7ae0        addiu   gp,gp,31456
+  .*:  279c7ac0        addiu   gp,gp,31424
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
index f19d773..9b2e722 100644 (file)
@@ -14,6 +14,6 @@ OFFSET   TYPE              VALUE
 
 Contents of section .got:
  10000020 00000000 80000000 00000000 00000000  ................
- 10000030 00000000 00000000 00000000 0040051c  .............@..
+ 10000030 00000000 00000000 00000000 0040053c  .............@..
  10000040 00000001 00000000 00000000 00000000  ................
  10000050 00000000 00000000 00000000 00000000  ................
index 44730ab..0c466b6 100644 (file)
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7ba0        addiu   gp,gp,31648
+  .*:  279c7b80        addiu   gp,gp,31616
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7ae0        addiu   gp,gp,31456
+  .*:  279c7ac0        addiu   gp,gp,31424
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
index 8ceef73..ba617bb 100644 (file)
@@ -15,6 +15,6 @@ OFFSET   TYPE              VALUE
 Contents of section .got:
  10000020 00000000 80000000 00000000 00000000  .*
  10000030 00000000 00000000 00000000 00000000  .*
- 10000040 0040051c 00000001 00000000 00000000  .*
+ 10000040 0040053c 00000001 00000000 00000000  .*
  10000050 00000000 00000000 00000000 00000000  .*
  10000060 00000000 00000000 00000000 00000000  .*
index d254c94..31f1666 100644 (file)
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7ba0        addiu   gp,gp,31648
+  .*:  279c7b80        addiu   gp,gp,31616
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
@@ -51,7 +51,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7af0        addiu   gp,gp,31472
+  .*:  279c7ad0        addiu   gp,gp,31440
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
index 89c9961..addfc0f 100644 (file)
@@ -15,6 +15,6 @@ OFFSET   TYPE              VALUE
 Contents of section .got:
  10000020 00000000 80000000 00000000 00000000  ................
  10000030 00000000 00000000 00000000 00000000  ................
- 10000040 004005cc 00000001 00000000 00000000  .@..............
+ 10000040 004005ec 00000001 00000000 00000000  .@..............
  10000050 00000000 00000000 00000000 00000000  ................
  10000060 00000000 00000000 00000000 00000000  ................
index d1f383d..31e9e02 100644 (file)
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:  3c1c0fc0        lui     gp,0xfc0
-  .*:  279c7bc0        addiu   gp,gp,31680
+  .*:  279c7ba0        addiu   gp,gp,31648
   .*:  0399e021        addu    gp,gp,t9
   .*:  27bdfff0        addiu   sp,sp,-16
   .*:  afbe0008        sw      s8,8\(sp\)
index 633fc39..1006332 100644 (file)
@@ -14,6 +14,6 @@ OFFSET   TYPE              VALUE
 
 Contents of section .got:
  10000020 00000000 80000000 00000000 00000000  ................
- 10000030 00000000 00000000 00000000 004004fc  ................
+ 10000030 00000000 00000000 00000000 0040051c  ................
  10000040 00000001 00000000 00000000 00000000  ................
  10000050 00000000 00000000 00000000 00000000  ................
index 0b5d7c5..1507f2c 100644 (file)
@@ -4,13 +4,13 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-000403b0 R_MIPS_TLS_TPREL32  \*ABS\*
-000403b4 R_MIPS_TLS_DTPMOD32  \*ABS\*
-000403bc R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403d0 R_MIPS_TLS_TPREL32  \*ABS\*
+000403d4 R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403dc R_MIPS_TLS_DTPMOD32  \*ABS\*
 
 
 Contents of section .got:
- 40390 00000000 80000000 00000000 00000000  ................
- 403a0 00000000 00000000 00000000 00000360  ................
- 403b0 00000008 00000000 00000000 00000000  ................
- 403c0 ffff8004                             ....            
+ 403b0 00000000 80000000 00000000 00000000  ................
+ 403c0 00000000 00000000 00000000 00000380  ................
+ 403d0 00000008 00000000 00000000 00000000  ................
+ 403e0 ffff8004                             ....            
index f039886..c0bf509 100644 (file)
@@ -4,14 +4,14 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-00040514 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0004051c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-00040520 R_MIPS_TLS_DTPREL32  tlsvar_gd
-00040510 R_MIPS_TLS_TPREL32  tlsvar_ie
+00040534 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0004053c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+00040540 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00040530 R_MIPS_TLS_TPREL32  tlsvar_ie
 
 
 Contents of section .got:
- 404f0 00000000 80000000 00000000 00000000  ................
- 40500 00000000 00000000 00000000 000004c0  ................
- 40510 00000000 00000000 00000000 00000000  ................
- 40520 00000000                             ....            
+ 40510 00000000 80000000 00000000 00000000  ................
+ 40520 00000000 00000000 00000000 000004e0  ................
+ 40530 00000000 00000000 00000000 00000000  ................
+ 40540 00000000                             ....            
index 9a93aad..7307081 100644 (file)
@@ -4,14 +4,14 @@ tmpdir/tlslib-o32.so:     file format elf32-tradbigmips
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-00040474 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0004047c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-00040480 R_MIPS_TLS_DTPREL32  tlsvar_gd
-00040470 R_MIPS_TLS_TPREL32  tlsvar_ie
+00040494 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0004049c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+000404a0 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00040490 R_MIPS_TLS_TPREL32  tlsvar_ie
 
 
 Contents of section .got:
- 40450 00000000 80000000 00000000 00000000  ................
- 40460 00000000 00000000 00000000 00000420  ................
- 40470 00000000 00000000 00000000 00000000  ................
- 40480 00000000                             ....            
+ 40470 00000000 80000000 00000000 00000000  ................
+ 40480 00000000 00000000 00000000 00000440  ................
+ 40490 00000000 00000000 00000000 00000000  ................
+ 404a0 00000000                             ....