]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR ld/15787
authorNick Clifton <nickc@redhat.com>
Wed, 14 Aug 2013 12:20:41 +0000 (12:20 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 14 Aug 2013 12:20:41 +0000 (12:20 +0000)
* elf32-arm.c (elf32_arm_final_link_relocate): Use origin of output
segment containing the relocating symbol instead of assuming 0 for
sb group relocations.

* ld-arm/group-relocs-ldr-bad.s: Redefine bar into foo section
beyond 16 bit offset width.
* ld-arm/group-relocs-ldrs-bad.s: Likewise.
* ld-arm/group-relocs-ldr-bad.d: Adjust expected result.
* ld-arm/group-relocs-ldrs-bad.d: Likewise.
* ld-arm/group-relocs.s: Add comments.  Move symbols used for sb
group relocations into .data section.  Drop section zero.  Use pc/r0
as base register when pc/sb group relocations are used.
* ld-arm/group-relocs.d: Adjust expected result.
* ld-arm/group-relocs-alu-bad-2.d: New test for sb group relocation.
* ld-arm/group-relocs-ldc-bad-2.d: Likewise.
* ld-arm/group-relocs-ldr-bad-2.d: New test for pc group relocation.
* ld-arm/group-relocs-ldrs-bad-2.d: Likewise.
* ld-arm/unresolved-2.d: Add sb relocation failure test.
* ld-arm/group-relocs-alu-bad-2.s: New test source.
* ld-arm/group-relocs-ldr-bad-2.s: Likewise.
* ld-arm/group-relocs-ldrs-bad-2.s: Likewise.
* ld-arm/group-relocs-ldc-bad-2.s: Likewise.
* ld-arm/unresolved-2.s: Likewise.
* ld-arm/arm-elf.exp: For group-relocs, drop section zero start
definition.  Run the new tests.

14 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/group-relocs-ldr-bad-2.d
ld/testsuite/ld-arm/group-relocs-ldr-bad-2.s
ld/testsuite/ld-arm/group-relocs-ldr-bad.d
ld/testsuite/ld-arm/group-relocs-ldr-bad.s
ld/testsuite/ld-arm/group-relocs-ldrs-bad-2.d
ld/testsuite/ld-arm/group-relocs-ldrs-bad-2.s
ld/testsuite/ld-arm/group-relocs-ldrs-bad.d
ld/testsuite/ld-arm/group-relocs-ldrs-bad.s
ld/testsuite/ld-arm/unresolved-2.d [new file with mode: 0644]
ld/testsuite/ld-arm/unresolved-2.s [new file with mode: 0644]

index ccbc820909fdb50bf3347ed87e720e3cdc624e64..fb0582efd4dae76799f09ab27d18bfd4ea192310 100644 (file)
@@ -1,3 +1,10 @@
+2013-08-14  John Tytgat  <john@bass-software.com>
+
+       PR ld/15787
+       * elf32-arm.c (elf32_arm_final_link_relocate): Use origin of output
+       segment containing the relocating symbol instead of assuming 0 for
+       sb group relocations.
+
 2013-08-09  Nick Clifton  <nickc@redhat.com>
 
        * elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if G10
index 4616ae9c77c26c4d1818f6246832df99879b7cab..6d2d5534b14311f97e29d360a376a46320e1915d 100644 (file)
@@ -9853,7 +9853,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        bfd_vma pc = input_section->output_section->vma
                     + input_section->output_offset + rel->r_offset;
        /* sb is the origin of the *segment* containing the symbol.  */
-       bfd_vma sb = sym_sec->output_section->vma;
+       bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
        bfd_vma residual;
        bfd_vma g_n;
        bfd_signed_vma signed_value;
@@ -9987,7 +9987,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        bfd_vma pc = input_section->output_section->vma
                     + input_section->output_offset + rel->r_offset;
        /* sb is the origin of the *segment* containing the symbol.  */
-       bfd_vma sb = sym_sec->output_section->vma;
+       bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
        bfd_vma residual;
        bfd_signed_vma signed_value;
        int group = 0;
@@ -10071,7 +10071,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        bfd_vma pc = input_section->output_section->vma
                     + input_section->output_offset + rel->r_offset;
        /* sb is the origin of the *segment* containing the symbol.  */
-       bfd_vma sb = sym_sec->output_section->vma;
+       bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
        bfd_vma residual;
        bfd_signed_vma signed_value;
        int group = 0;
@@ -10155,7 +10155,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        bfd_vma pc = input_section->output_section->vma
                     + input_section->output_offset + rel->r_offset;
        /* sb is the origin of the *segment* containing the symbol.  */
-       bfd_vma sb = sym_sec->output_section->vma;
+       bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
        bfd_vma residual;
        bfd_signed_vma signed_value;
        int group = 0;
index 902e8902253e1d9136729b93bbc5ee3556bb69a1..9d163ec6a2da2f2d56266a9b8c0884898ab9bf41 100644 (file)
@@ -1,3 +1,28 @@
+2013-08-14  John Tytgat  <john@bass-software.com>
+
+       PR ld/15787
+       * ld-arm/group-relocs-ldr-bad.s: Redefine bar into foo section
+       beyond 16 bit offset width.
+       * ld-arm/group-relocs-ldrs-bad.s: Likewise.
+       * ld-arm/group-relocs-ldr-bad.d: Adjust expected result.
+       * ld-arm/group-relocs-ldrs-bad.d: Likewise.
+       * ld-arm/group-relocs.s: Add comments.  Move symbols used for sb
+       group relocations into .data section.  Drop section zero.  Use pc/r0
+       as base register when pc/sb group relocations are used.
+       * ld-arm/group-relocs.d: Adjust expected result.
+       * ld-arm/group-relocs-alu-bad-2.d: New test for sb group relocation.
+       * ld-arm/group-relocs-ldc-bad-2.d: Likewise.
+       * ld-arm/group-relocs-ldr-bad-2.d: New test for pc group relocation.
+       * ld-arm/group-relocs-ldrs-bad-2.d: Likewise.
+       * ld-arm/unresolved-2.d: Add sb relocation failure test.
+       * ld-arm/group-relocs-alu-bad-2.s: New test source.
+       * ld-arm/group-relocs-ldr-bad-2.s: Likewise.
+       * ld-arm/group-relocs-ldrs-bad-2.s: Likewise.
+       * ld-arm/group-relocs-ldc-bad-2.s: Likewise.
+       * ld-arm/unresolved-2.s: Likewise.
+       * ld-arm/arm-elf.exp: For group-relocs, drop section zero start
+       definition.  Run the new tests.
+
 2013-08-09  Nick Clifton  <nickc@redhat.com>
 
        * lib/ld-lib.exp (check_shared_lib_support): Note that the RL78
index 3d7d76173d0267c4510f5f953169652b60b088ee..4c0f8026244b85af09805b93c3e958e340fdd775 100644 (file)
@@ -836,4 +836,5 @@ run_dump_test "unresolved-1"
 if { ![istarget "arm*-*-nacl*"] } {
     run_dump_test "unresolved-1-dyn"
 }
+run_dump_test "unresolved-2"
 run_dump_test "gc-hidden-1"
index ae48b326cff7ee2b7bc5cf66a7cb2d70b811d3b8..611d82668f6e3002984f1e4e6e5a5525bde73a22 100644 (file)
@@ -1,4 +1,4 @@
 #name: LDR group relocations failure test
 #source: group-relocs-ldr-bad-2.s
 #ld: -Ttext 0x8000 --section-start foo=0x8001000
-#error: .*Overflow whilst splitting 0x123456 for group relocation.*
+#error: .*Overflow whilst splitting 0x7ff9000 for group relocation.*
index 02d01c2985ffd14c1a0863df3166f75e66d6b77e..3aec8eec6cc6e0caaa12d4b0f06c0227a16b287c 100644 (file)
@@ -6,12 +6,13 @@
        .globl _start
 
 _start:
-       add     r0, r0, #:sb_g0_nc:(bar)
-       ldr     r1, [r0, #:sb_g1:(bar)]
+       add     r0, r0, #:pc_g0_nc:(bar)
+       ldr     r1, [r0, #:pc_g1:(bar + 4)]
 
-@ We will place the section foo at 0x8001000 but that should be irrelevant
-@ for sb_g* relocations.
+@ We will place the section foo at 0x8001000.
 
        .section foo
-       .set bar,foo + 0x123456
+
+bar:
+       mov r0, #0
 
index 88e6ee9ccab3b96cfd24a2039a74ba8c85c1d100..76f3df1f841b45b7bd8b0123634f775874a3d7b9 100644 (file)
@@ -1,4 +1,4 @@
 #name: LDR group relocations failure test
 #source: group-relocs-ldr-bad.s
 #ld: -Ttext 0x8000 --section-start foo=0x8001000
-#error: .*Overflow whilst splitting 0x7ff9000 for group relocation.*
+#error: .*Overflow whilst splitting 0x123456 for group relocation.*
index 3aec8eec6cc6e0caaa12d4b0f06c0227a16b287c..02d01c2985ffd14c1a0863df3166f75e66d6b77e 100644 (file)
@@ -6,13 +6,12 @@
        .globl _start
 
 _start:
-       add     r0, r0, #:pc_g0_nc:(bar)
-       ldr     r1, [r0, #:pc_g1:(bar + 4)]
+       add     r0, r0, #:sb_g0_nc:(bar)
+       ldr     r1, [r0, #:sb_g1:(bar)]
 
-@ We will place the section foo at 0x8001000.
+@ We will place the section foo at 0x8001000 but that should be irrelevant
+@ for sb_g* relocations.
 
        .section foo
-
-bar:
-       mov r0, #0
+       .set bar,foo + 0x123456
 
index 0674a15b5504c7da77d2dd9eddda42fbdfa40b07..9d1c90086f69361fc776fad1d9aef949bc66d391 100644 (file)
@@ -1,4 +1,4 @@
 #name: LDRS group relocations failure test
 #source: group-relocs-ldrs-bad-2.s
 #ld: -Ttext 0x8000 --section-start foo=0x8000100
-#error: Overflow whilst splitting 0x123456 for group relocation
+#error: Overflow whilst splitting 0x7ff8100 for group relocation
index 02cf5604bd9ac0a1e7e2e1a78e76580c77ed3a0e..3578060b93ab21a0a180d5fc0062e5cb2992527c 100644 (file)
@@ -6,12 +6,12 @@
        .globl _start
 
 _start:
-       add     r0, r0, #:sb_g0_nc:(bar)
-       ldrd    r2, [r0, #:sb_g1:(bar)]
+       add     r0, r0, #:pc_g0_nc:(bar)
+       ldrd    r2, [r0, #:pc_g1:(bar + 4)]
 
-@ We will place the section foo at 0x8000100 but that should be irrelevant
-@ for sb_g* relocations.
+@ We will place the section foo at 0x8000100.
 
        .section foo
-       .set bar,foo + 0x123456
 
+bar:
+       mov r0, #0
index ac7815b8c19ca0742a42b70cc2c7c20c8090b1d7..e5296f993e30b0a42f4c8755eb853f3dfa0825fd 100644 (file)
@@ -1,4 +1,4 @@
 #name: LDRS group relocations failure test
 #source: group-relocs-ldrs-bad.s
 #ld: -Ttext 0x8000 --section-start foo=0x8000100
-#error: Overflow whilst splitting 0x7ff8100 for group relocation
+#error: Overflow whilst splitting 0x123456 for group relocation
index 3578060b93ab21a0a180d5fc0062e5cb2992527c..02cf5604bd9ac0a1e7e2e1a78e76580c77ed3a0e 100644 (file)
@@ -6,12 +6,12 @@
        .globl _start
 
 _start:
-       add     r0, r0, #:pc_g0_nc:(bar)
-       ldrd    r2, [r0, #:pc_g1:(bar + 4)]
+       add     r0, r0, #:sb_g0_nc:(bar)
+       ldrd    r2, [r0, #:sb_g1:(bar)]
 
-@ We will place the section foo at 0x8000100.
+@ We will place the section foo at 0x8000100 but that should be irrelevant
+@ for sb_g* relocations.
 
        .section foo
+       .set bar,foo + 0x123456
 
-bar:
-       mov r0, #0
diff --git a/ld/testsuite/ld-arm/unresolved-2.d b/ld/testsuite/ld-arm/unresolved-2.d
new file mode 100644 (file)
index 0000000..cd5e013
--- /dev/null
@@ -0,0 +1,5 @@
+#name: SB relocations failure test
+#source: unresolved-2.s
+#ld: 
+#error: \(\.text\+0x0\): undefined reference to `foo'
+
diff --git a/ld/testsuite/ld-arm/unresolved-2.s b/ld/testsuite/ld-arm/unresolved-2.s
new file mode 100644 (file)
index 0000000..92b7f7f
--- /dev/null
@@ -0,0 +1,5 @@
+       .text
+       .globl  _start
+_start:
+       ldr     r1, [r0, #:sb_g0:(foo)]
+