* elf32-m68k.c (elf_m68k_relocate_section): Don't ignore existing
authorAndreas Schwab <schwab@linux-m68k.org>
Sun, 29 Jun 2008 12:56:41 +0000 (12:56 +0000)
committerAndreas Schwab <schwab@linux-m68k.org>
Sun, 29 Jun 2008 12:56:41 +0000 (12:56 +0000)
addend on _GLOBAL_OFFSET_TABLE_.

ld/testsuite/:
* ld-m68k/got-1.s: New file.
* ld-m68k/got-1.d: New dump test.
* ld-m68k/m68k.exp: Run it.

bfd/ChangeLog
bfd/elf32-m68k.c
ld/testsuite/ChangeLog
ld/testsuite/ld-m68k/got-1.d [new file with mode: 0644]
ld/testsuite/ld-m68k/got-1.s [new file with mode: 0644]
ld/testsuite/ld-m68k/m68k.exp

index d87568b39211a0a4e4a356e3ecfec23517162a7e..3f6f5c76eb64b395397c6995f99042c4e0eba3c2 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-29  Andreas Schwab  <schwab@suse.de>
+
+       * elf32-m68k.c (elf_m68k_relocate_section): Don't ignore existing
+       addend on _GLOBAL_OFFSET_TABLE_.
+
 2008-06-24  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * elf32-arm.c (STUB_ENTRY_NAME): Define.
index 7d46fff2d1066cda2eb2e6d2751c40fd6aab0727..0b6fff35fd5be93cac9eac666e3bb4b5932ee775 100644 (file)
@@ -3135,8 +3135,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
          if (h != NULL
              && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
            {
-             BFD_ASSERT (rel->r_addend == 0);
-
              if (elf_m68k_hash_table (info)->local_gp_p)
                {
                  bfd_vma sgot_output_offset;
@@ -3185,7 +3183,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
 
                  /* Adjust GOT pointer to point to the GOT
                     assigned to input_bfd.  */
-                 rel->r_addend = sgot_output_offset + got_offset;
+                 rel->r_addend += sgot_output_offset + got_offset;
                }
              else
                BFD_ASSERT (got == NULL || got->offset == 0);
index 02614c78cc87a73e02f8ebe3f59ea502db002e2a..34d75e611ea1d81a3cbb65e744da9d6b43930f3b 100644 (file)
@@ -1,3 +1,9 @@
+2008-06-29  Andreas Schwab  <schwab@suse.de>
+
+       * ld-m68k/got-1.s: New file.
+       * ld-m68k/got-1.d: New dump test.
+       * ld-m68k/m68k.exp: Run it.
+
 2008-06-24  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * ld-arm/farcall-arm-arm-be8.d, ld-arm/farcall-arm-arm-pic-veneer.d,
diff --git a/ld/testsuite/ld-m68k/got-1.d b/ld/testsuite/ld-m68k/got-1.d
new file mode 100644 (file)
index 0000000..e8070e9
--- /dev/null
@@ -0,0 +1,19 @@
+#source: got-1.s
+#ld: -shared
+#readelf: -d -r
+
+Dynamic section at offset .* contains 9 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\)
+ 0x00000007 \(RELA\)                       0x[0-9a-f]+
+ 0x00000008 \(RELASZ\)                     12 \(bytes\)
+ 0x00000009 \(RELAENT\)                    12 \(bytes\)
+ 0x00000000 \(NULL\)                       0x0
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ Offset     Info    Type            Sym.Value  Sym. Name \+ Addend
+[0-9a-f]+  [0-9a-f]+ R_68K_GLOB_DAT    00000000   a \+ 0
diff --git a/ld/testsuite/ld-m68k/got-1.s b/ld/testsuite/ld-m68k/got-1.s
new file mode 100644 (file)
index 0000000..0cf3692
--- /dev/null
@@ -0,0 +1,18 @@
+#NO_APP
+       .file   "got-1.c"
+       .text
+       .align  2
+       .globl  foo
+       .type   foo, @function
+foo:
+       link.w %fp,#0
+       move.l %a5,-(%sp)
+       lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %a5
+       move.l a@GOT(%a5),%d0
+       move.l %d0,%a0
+       move.l (%a0),%d0
+       move.l (%sp)+,%a5
+       unlk %fp
+       rts
+       .size   foo, .-foo
+       .section        .note.GNU-stack,"",@progbits
index fd98b63c254f7bf16a2073f8b49ae3d8568ec3e9..69ca6baaa27c8f7f52a116fb15315408752e3bb8 100644 (file)
@@ -73,6 +73,7 @@ foreach { id sources } { a { plt1.s } b { plt1-empty.s plt1.s } } {
 # 4 - 16384
 # 5 - 16385
 
+run_dump_test "got-1"
 run_dump_test "got-single-12-ok"
 run_dump_test "got-single-13-er"
 run_dump_test "got-negative-14-ok"