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

[PATCH, ld, arm] Fix broken -Bsymbolic-functions

GNU ld generates absolute relocation for non function call references to functions (eg. initialization of function pointer) despite the presence of -Bsymbolic-functions. This issue has already been dealt with in Aarch64 some time ago but although a check for similar issues in other targets was done, it was done incorrectly (probably by looking for the whole condition on a single line instead of just grepping for !.*->dynamic).

Target that appears to be affected:


This patch fixes the issue for ARM targets.

ChangeLog entries are as follow:

*** bfd/ChangeLog ***

2015-07-20  Thomas Preud'homme  <>

        * elf32-arm.c (elf32_arm_final_link_relocate): Use SYMBOLIC_BIND to
        check if a symbol should be bound symbolically.

*** ld/testsuite/ChangeLog ***

2015-07-10  Thomas Preud'homme  <>

        * ld-arm/arm-elf.exp: Added relocs-23-symbolic-func test.
        * ld-arm/relocs-23-symbolic-func.d: New file.
        * ld-arm/relocs-23-symbolic-func.s: Likewise.

diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 113f4eb..82a5a6f 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -8449,7 +8449,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  else if (h != NULL
 		   && h->dynindx != -1
 		   && (!info->shared
-		       || !info->symbolic
+		       || !SYMBOLIC_BIND (info, h)
 		       || !h->def_regular))
 	    outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 28b41ca..8c8fa8f 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -301,6 +301,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 "relocs-23-symbolic-func"
 # Exclude non-ARM-EABI targets.
diff --git a/ld/testsuite/ld-arm/relocs-23-symbolic-func.d b/ld/testsuite/ld-arm/relocs-23-symbolic-func.d
new file mode 100644
index 0000000..c10e291
--- /dev/null
+++ b/ld/testsuite/ld-arm/relocs-23-symbolic-func.d
@@ -0,0 +1,5 @@
+#source: relocs-23-symbolic-func.s
+#ld: -shared -Bsymbolic-functions
+#readelf: -r --wide
diff --git a/ld/testsuite/ld-arm/relocs-23-symbolic-func.s b/ld/testsuite/ld-arm/relocs-23-symbolic-func.s
new file mode 100644
index 0000000..1ee50d8
--- /dev/null
+++ b/ld/testsuite/ld-arm/relocs-23-symbolic-func.s
@@ -0,0 +1,11 @@
+	.text
+	.global tempy
+	.type   tempy, %function
+	.size   tempy, .-tempy
+	.section	.data.rel
+	.align 2
+	.type   tempy_ptr, %object
+	.size   tempy_ptr, 4
+	.word	tempy

No regression was observed when running testsuite for arm-none-eabi

Is this ok for master as well as 2.24 and 2.25 stable branches?

Best regards,


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