[PATCH, ld, arm] Fix broken -Bsymbolic-functions
Thomas Preud'homme
thomas.preudhomme@arm.com
Fri Jul 24 09:06:00 GMT 2015
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:
arm
hppa
m68k
nios2
tic6x
This patch fixes the issue for ARM targets.
ChangeLog entries are as follow:
*** bfd/ChangeLog ***
2015-07-20 Thomas Preud'homme <thomas.preudhomme@arm.com>
* 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 <thomas.preudhomme@arm.com>
* 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);
else
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
+#...
+.* +R_ARM_RELATIVE +.*
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
+tempy:
+ .size tempy, .-tempy
+ .section .data.rel
+ .align 2
+ .type tempy_ptr, %object
+ .size tempy_ptr, 4
+tempy_ptr:
+ .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,
Thomas
More information about the Binutils
mailing list