Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Medium
-
Resolution: Done
-
Component/s: None
-
Labels:None
-
Environment:
Arch Linux (4.4.5-1-ARCH)
Clang version 3.7.1 (tags/RELEASE_371/final)
GNU ld (GNU Binutils) 2.26.0.20160302
Description
Linking libswiftCore.so using binutils 2.26 fails during the relocation of a protected symbol. This issue is not present in 2.25 of binutils.
[511/536] Linking CXX shared library lib/swift/linux/x86_64/libswiftCore.so FAILED: : && /usr/bin/clang++ -fPIC -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -O3 -Wl,-z,defs -target x86_64-unknown-linux-gnu -isysroot / -lpthread -ldl -L/home/ryan/build/Ninja-ReleaseAssert/swift-linux-x86_64/./lib/swift/linux/x86_64 -L/home/ryan/build/Ninja-ReleaseAssert/swift-linux-x86_64/./bin/../lib/swift/linux/x86_64 -L/home/ryan/build/Ninja-ReleaseAssert/swift-linux-x86_64/./bin/../lib/swift/linux -shared -Wl,-soname,libswiftCore.so -o lib/swift/linux/x86_64/libswiftCore.so lib/swift/linux/x86_64/swift_begin.o stdlib/public/core/linux/x86_64/Swift.o lib/swift/linux/x86_64/swift_end.o -L/home/ryan/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib -L/home/ryan/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib lib/swift/linux/x86_64/libswiftRuntime.a lib/swift/linux/x86_64/libswiftStdlibStubs.a -licuuc -licui18n -lbsd -Wl,-rpath,"\$ORIGIN:/usr/lib/swift/linux" && : /usr/bin/ld: stdlib/public/core/linux/x86_64/Swift.o: relocation R_X86_64_PC32 against protected symbol `_TMPSa' can not be used when making a shared object /usr/bin/ld: final link failed: Bad value
Using git bisect I was able to determine the commit that introduced the behavior of binutils between 2.25 and 2.26 to be ca3fe95e469b9daec153caa2c90665f5daaec2b5.
ca3fe95e469b9daec153caa2c90665f5daaec2b5 is the first bad commit commit ca3fe95e469b9daec153caa2c90665f5daaec2b5 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Mar 5 06:34:39 2015 -0800 Add extern_protected_data and set it for x86 With copy relocation, address of protected data defined in the shared library may be external. This patch adds extern_protected_data and changes _bfd_elf_symbol_refs_local_p to return false for protected data if extern_protected_data is true. bfd/ PR ld/pr15228 PR ld/pr17709 * elf-bfd.h (elf_backend_data): Add extern_protected_data. * elf32-i386.c (elf_backend_extern_protected_data): New. Defined to 1. * elf64-x86-64.c (elf_backend_extern_protected_data): Likewise. * elflink.c (_bfd_elf_adjust_dynamic_copy): Don't error on copy relocs against protected symbols if extern_protected_data is true. (_bfd_elf_symbol_refs_local_p): Don't return true on protected non-function symbols if extern_protected_data is true. * elfxx-target.h (elf_backend_extern_protected_data): New. Default to 0. (elfNN_bed): Initialize extern_protected_data with elf_backend_extern_protected_data. ld/testsuite/ PR ld/pr15228 PR ld/pr17709 * ld-i386/i386.exp (i386tests): Add a test for PR ld/17709. * ld-i386/pr17709-nacl.rd: New file. * ld-i386/pr17709.rd: Likewise. * ld-i386/pr17709a.s: Likewise. * ld-i386/pr17709b.s: Likewise. * ld-i386/protected3.d: Updated. * ld-i386/protected3.s: Likewise. * ld-x86-64/pr17709-nacl.rd: New file. * ld-x86-64/pr17709.rd: Likewise. * ld-x86-64/pr17709a.s: Likewise. * ld-x86-64/pr17709b.s: Likewise. * ld-x86-64/protected3.d: Updated. * ld-x86-64/protected3.s: Likewise. * ld-x86-64/x86-64.exp (x86_64tests): Add a test for PR ld/17709. :040000 040000 7fc861c288f9bed44c6444d1b04e2f6e688aeeaf fca3f6ce979e7c00ed44c04f506880015235806d M bfd :040000 040000 a5e358abb99b2b4089765f16904f9ebc496c0f12 7ccba1e77448a0155e56e8155073b40804b00daa M ld
To perform the bisect I used 2bd25930221dea4bf33c13a89c111514491440e2 as the last known good commit and 71090e7a9dde8d28ff5c4b44d6d83e270d1088e4 as the last known bad commit.