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

[PATCH, bfd] Fix incorrect initialization of function pointer variable with -Bsymbolic-functions


To decide whether a static data should be bound symbolically, ld checks (among other things) the value of info->symbolic. However this value is only true if the user specified -Bsymbolic so if the user specified -Bsymbolic-function and the data is a function pointer it will resolved globally. The solution is to use the SYMBOLIC_BIND () macro to check what to do.

ChangeLog entry is as follows:

bfd/ChangeLog

2015-01-06 Thomas Preud'homme thomas.preudhomme@arm.com

    * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use
    SYMBOLIC_BIND to check if a symbol should be bound symbolically.


ld/testsuite/ChangeLog

2015-01-09 Thomas Preud'homme thomas.preudhomme@arm.com

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

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 3554a87..b059a90 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -4337,7 +4337,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 	    memset (&outrel, 0, sizeof outrel);
 	  else if (h != NULL
 		   && h->dynindx != -1
-		   && (!info->shared || !info->symbolic || !h->def_regular))
+		   && (!info->shared || !SYMBOLIC_BIND (info, h) || !h->def_regular))
 	    outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
 	  else
 	    {
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 0eae20a..d4b5e06 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -175,6 +175,7 @@ run_dump_test "ifunc-21"
 run_dump_test "ifunc-22"
 
 run_dump_test "relasz"
+run_dump_test "relocs-257-symbolic-func"
 
 set aarch64elflinktests {
   {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
diff --git a/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.d b/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.d
new file mode 100644
index 0000000..810fd43
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.d
@@ -0,0 +1,5 @@
+#source: relocs-257-symbolic-func.s
+#ld: -shared -Bsymbolic-functions
+#readelf: -r --wide
+#...
+.* +R_AARCH64_RELATIVE +.*
diff --git a/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.s b/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.s
new file mode 100644
index 0000000..35d5ba8
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relocs-257-symbolic-func.s
@@ -0,0 +1,11 @@
+	.text
+	.global tempy
+	.type   tempy, %function
+tempy:
+	.size   tempy, .-tempy
+	.section	.data.rel
+	.align 3
+	.type   tempy_ptr, %object
+	.size   tempy_ptr, 8
+tempy_ptr:
+	.xword	tempy

Is this ok for trunk?

Best regards,

Thomas




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