On 10 January 2014 08:32, Giuseppe D'Angelo <giuseppe.dang...@kdab.com> wrote:
Hi Guiseppe, > the attached program changes the output from "true" to "false" when the > -Bsymbolic / -Bsymbolic-functions options are passed to GCC. This happens on > ARM -- on x86-64 output is always "true". > > The program involves a comparison, within a shared library, of a PMF defined > inside the shared library itself with the same PMF passed by the > application. > > At this stage I still don't know if it's a GCC problem, a ld.so problem, ABI > constraints, undefined behaviour, or whatnot; but any help is appreciated. > > Compile with: > >> g++ -fPIC -shared -Wall -o libshared.so -Wl,-Bsymbolic shared.cpp >> g++ -fPIE -Wall -o main main.cpp -L. -lshared > > (The long story is that Qt 5 is taking PMFs in its public API, and the > comparison failing inside of Qt shared libraries is breaking code on ARM, as > -Bsymbolic is set by default there.) Thanks for the report and testcase. The attached patch to ld may help. I am not yet sure whether or not it is the correct approach but if it works for you that would be interesting. -- Will Newton Toolchain Working Group, Linaro
From 8f083d831cc7441d5fddcb1a883ae1f1372cd287 Mon Sep 17 00:00:00 2001 From: Will Newton <will.new...@linaro.org> Date: Fri, 10 Jan 2014 14:38:58 +0000 Subject: [PATCH] bfd/elf32-arm.c: Set st_value to zero for undefined symbols. Unless point_equality_needed is set then set st_value to be zero for undefined symbols. bfd/ChangeLog: 2014-01-10 Will Newton <will.new...@linaro.org> * elf32-arm.c (elf32_arm_check_relocs): Set pointer_equality_needed for absolute references within executable links. (elf32_arm_finish_dynamic_symbol): Set st_value to zero unless pointer_equality_needed is set. ld/testsuite/ChangeLog: 2014-01-10 Will Newton <will.new...@linaro.org> * ld-arm/ifunc-14.rd: Update symbol values. --- bfd/elf32-arm.c | 7 ++++++- ld/testsuite/ld-arm/ifunc-14.rd | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 6a9e60f..3451a66 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -12675,6 +12675,11 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, /* Fall through. */ case R_ARM_ABS32: case R_ARM_ABS32_NOI: + if (h != NULL && info->executable) + { + h->pointer_equality_needed = 1; + } + /* Fall through. */ case R_ARM_REL32: case R_ARM_REL32_NOI: case R_ARM_MOVW_PREL_NC: @@ -14040,7 +14045,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, Otherwise, the PLT entry would provide a definition for the symbol even if the symbol wasn't defined anywhere, and so the symbol would never be NULL. */ - if (!h->ref_regular_nonweak) + if (!h->ref_regular_nonweak || !h->pointer_equality_needed) sym->st_value = 0; } else if (eh->is_iplt && eh->plt.noncall_refcount != 0) diff --git a/ld/testsuite/ld-arm/ifunc-14.rd b/ld/testsuite/ld-arm/ifunc-14.rd index 59ea29b..9c44092 100644 --- a/ld/testsuite/ld-arm/ifunc-14.rd +++ b/ld/testsuite/ld-arm/ifunc-14.rd @@ -8,5 +8,5 @@ Relocation section '\.rel\.dyn' at offset 0x8000 contains 4 entries: Relocation section '\.rel\.plt' at offset 0x8020 contains 2 entries: Offset Info Type Sym\.Value Sym\. Name -0001100c ......16 R_ARM_JUMP_SLOT 00009014 f2t -00011010 ......16 R_ARM_JUMP_SLOT 00009020 f2 +0001100c ......16 R_ARM_JUMP_SLOT 00000000 f2t +00011010 ......16 R_ARM_JUMP_SLOT 00000000 f2 -- 1.8.1.4
_______________________________________________ linaro-toolchain mailing list linaro-toolchain@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-toolchain