[AArch64] Bind defined symbol locally in PIE
authorJiong Wang <jiong.wang@arm.com>
Thu, 10 Nov 2016 09:25:17 +0000 (09:25 +0000)
committerJiong Wang <jiong.wang@arm.com>
Thu, 10 Nov 2016 09:25:17 +0000 (09:25 +0000)
bfd/
PR target/20737
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined
symbol locally in PIE.

ld/
* testsuite/ld-aarch64/pie-bind-locally-a.s: New test source.
* testsuite/ld-aarch64/pie-bind-locally-b.s: Likewise.
* testsuite/ld-aarch64/pie-bind-locally.d: New testcase.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new testcase.

bfd/ChangeLog
bfd/elfnn-aarch64.c
ld/ChangeLog
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/pie-bind-locally-a.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/pie-bind-locally-b.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/pie-bind-locally.d [new file with mode: 0644]

index 9fd5841136d2c3c602a8056099c0cb09045aaaa7..9d97c64d356c78d5ffb49d0385032a3ed24a911d 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-10  Jiong Wang  <jiong.wang@arm.com>
+
+       PR target/20737
+       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined
+       symbol locally in PIE.
+
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
        * dwarf2.c (struct funcinfo) <is_linkage>: Type is bfd_boolean,
index 544a8ea19dfb9197f13e41b8517aa56935c87a4a..4ebdbe20d7178ce46e6b8f2a77784ec00c2fff92 100644 (file)
@@ -5193,7 +5193,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
          else if (h != NULL
                   && h->dynindx != -1
                   && (!bfd_link_pic (info)
-                      || !SYMBOLIC_BIND (info, h)
+                      || !(bfd_link_pie (info)
+                           || SYMBOLIC_BIND (info, h))
                       || !h->def_regular))
            outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
          else
index 9d04123a2f1d353ec2bfaf8ade1ab854700a527f..e1cdb05dbcdef32e9492a57aae36fb94e1056920 100644 (file)
@@ -1,3 +1,11 @@
+2016-11-10  Jiong Wang  <jiong.wang@arm.com>
+
+       PR target/20737
+       * testsuite/ld-aarch64/pie-bind-locally-a.s: New test source.
+       * testsuite/ld-aarch64/pie-bind-locally-b.s: Likewise.
+       * testsuite/ld-aarch64/pie-bind-locally.d: New testcase.
+       * testsuite/ld-aarch64/aarch64-elf.exp: Run new testcase.
+
 2016-11-07  Nick Clifton  <nickc@redhat.com>
 
        PR ld/20784
index ab84f01258dffdfac7d86843247d50a1de400a85..d4d7f5a0b8fa5626158eff4727b729d64398d206 100644 (file)
@@ -287,6 +287,8 @@ run_dump_test "rela-abs-relative"
 run_dump_test "rela-abs-relative-be"
 run_dump_test "rela-abs-relative-opt"
 
+run_dump_test "pie-bind-locally"
+
 set aarch64elflinktests {
   {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
     {} "copy-reloc-so.so"}
diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally-a.s b/ld/testsuite/ld-aarch64/pie-bind-locally-a.s
new file mode 100644 (file)
index 0000000..f64d48d
--- /dev/null
@@ -0,0 +1,5 @@
+       .text
+       .align  2
+       .global _start
+_start:
+       ldr     x0, [x0, #:got_lo12:_start]
diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally-b.s b/ld/testsuite/ld-aarch64/pie-bind-locally-b.s
new file mode 100644 (file)
index 0000000..6083941
--- /dev/null
@@ -0,0 +1,6 @@
+       .section        .data.rel,"aw",%progbits
+       .align  3
+       .type   q, %object
+       .size   q, 8
+q:
+       .xword  _start
diff --git a/ld/testsuite/ld-aarch64/pie-bind-locally.d b/ld/testsuite/ld-aarch64/pie-bind-locally.d
new file mode 100644 (file)
index 0000000..3689543
--- /dev/null
@@ -0,0 +1,9 @@
+#source: pie-bind-locally-a.s
+#source: pie-bind-locally-b.s
+#ld: -pie
+#readelf: -Wr
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_AARCH64_RELATIVE[ ].*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_AARCH64_RELATIVE[ ].*