This is the mail archive of the binutils-cvs@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]

[binutils-gdb] [ARM] Bind defined symbol locally in PIE


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1dcb9720d62cd053a72c31881b7724ce9f74332c

commit 1dcb9720d62cd053a72c31881b7724ce9f74332c
Author: Jiong Wang <jiong.wang@arm.com>
Date:   Thu Nov 24 14:01:53 2016 +0000

    [ARM] Bind defined symbol locally in PIE
    
    bfd/
    	PR target/20737
    	* elf32-arm.c (elf32_arm_final_link_relocate): Bind defined symbol
    	locally in PIE.
    
    ld/
    	* testsuite/ld-arm/pie-bind-locally-a.s: New test source.
    	* testsuite/ld-arm/pie-bind-locally-b.s: Likewise.
    	* testsuite/ld-arm/pie-bind-locally.d: New testcase.
    	* testsuite/ld-arm/arm-elf.exp: Run new testcase.

Diff:
---
 bfd/ChangeLog                            | 6 ++++++
 bfd/elf32-arm.c                          | 3 ++-
 ld/ChangeLog                             | 8 ++++++++
 ld/testsuite/ld-arm/arm-elf.exp          | 1 +
 ld/testsuite/ld-arm/pie-bind-locally-a.s | 5 +++++
 ld/testsuite/ld-arm/pie-bind-locally-b.s | 6 ++++++
 ld/testsuite/ld-arm/pie-bind-locally.d   | 9 +++++++++
 7 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d7a5693..a680896 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-11-24  Jiong Wang  <jiong.wang@arm.com>
+
+	PR target/20737
+	* elf32-arm.c (elf32_arm_final_link_relocate): Bind defined symbol
+	locally in PIE.
+
 2016-11-24  Kuan-Lin Chen  <kuanlinchentw@gmail.com>
 
 	* bfd/elfxx-riscv.c (howto_table): Fix bitsize of R_RISCV_ADD8.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b1bec39..8a20260 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -10147,7 +10147,8 @@ elf32_arm_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 = ELF32_R_INFO (h->dynindx, r_type);
 	  else
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0747409..f236615 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2016-11-24  Jiong Wang  <jiong.wang@arm.com>
+
+	PR target/20737
+	* testsuite/ld-arm/pie-bind-locally-a.s: New test source.
+	* testsuite/ld-arm/pie-bind-locally-b.s: Likewise.
+	* testsuite/ld-arm/pie-bind-locally.d: New testcase.
+	* testsuite/ld-arm/arm-elf.exp: Run new testcase.
+
 2016-11-24  Nick Clifton  <nickc@redhat.com>
 
 	PR ld/20858
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 02a35f4..2b1e5b8 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -345,6 +345,7 @@ run_dump_test "movw-shared-3"
 run_dump_test "movw-shared-4"
 run_dump_test "rel32-reject"
 run_dump_test "rel32-reject-pie"
+run_dump_test "pie-bind-locally"
 
 # Exclude non-ARM-EABI targets.
 
diff --git a/ld/testsuite/ld-arm/pie-bind-locally-a.s b/ld/testsuite/ld-arm/pie-bind-locally-a.s
new file mode 100644
index 0000000..76a2f67
--- /dev/null
+++ b/ld/testsuite/ld-arm/pie-bind-locally-a.s
@@ -0,0 +1,5 @@
+	.text
+	.align	2
+	.global	_start
+_start:
+	.word	_start(GOT)
diff --git a/ld/testsuite/ld-arm/pie-bind-locally-b.s b/ld/testsuite/ld-arm/pie-bind-locally-b.s
new file mode 100644
index 0000000..8e6ff4f
--- /dev/null
+++ b/ld/testsuite/ld-arm/pie-bind-locally-b.s
@@ -0,0 +1,6 @@
+	.section	.data.rel,"aw",%progbits
+	.align	2
+	.type	q, %object
+	.size	q, 4
+q:
+	.word	_start
diff --git a/ld/testsuite/ld-arm/pie-bind-locally.d b/ld/testsuite/ld-arm/pie-bind-locally.d
new file mode 100644
index 0000000..7ea031c
--- /dev/null
+++ b/ld/testsuite/ld-arm/pie-bind-locally.d
@@ -0,0 +1,9 @@
+#source: pie-bind-locally-a.s
+#source: pie-bind-locally-b.s
+#ld: -pie
+#readelf: -Wr
+
+Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_ARM_RELATIVE[ ].*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_ARM_RELATIVE[ ].*


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