This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol
ClosedPublic

Authored by arichardson on Aug 8 2022, 1:22 PM.

Details

Summary

This allows relaxing some relocations to symbol+offset instead of emitting
a relocation against a symbol.

Diff Detail

Event Timeline

arichardson created this revision.Aug 8 2022, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 1:22 PM
arichardson published this revision for review.Aug 8 2022, 1:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 1:27 PM
MaskRay accepted this revision.Aug 8 2022, 4:55 PM

LGTM.

This revision is now accepted and ready to land.Aug 8 2022, 4:55 PM

This allows relaxing some relocations to symbol+offset instead of emitting

a relocation against a symbol.

STT_SECTION symbol+offset

This revision was landed with ongoing or failed builds.Aug 9 2022, 2:55 AM
This revision was automatically updated to reflect the committed changes.
ayzhao added a subscriber: ayzhao.Aug 19 2022, 9:58 AM

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Repro made with -Wl,--reproduce=repro.tar: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

ayzhao added a comment.EditedAug 22 2022, 1:32 PM

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Repro made with -Wl,--reproduce=repro.tar: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

To repro:

  1. tar -xvf repro.tar.gz
  2. cd repro/
  3. bin/ld.lld @response.txt

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Repro made with -Wl,--reproduce=repro.tar: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

To repro:

  1. tar -xvf repro.tar.gz
  2. cd repro/
  3. bin/ld.lld @response.txt

Thanks for the reproducer. However, to confirm I'd a minimal set of source files since the archive of already has the bad symbol table encoded.

I believe this should be fixed by D131429. I will rebase that and adjust the test cases to allow these two patches to be committed in the inverse order.

arichardson reopened this revision.Aug 25 2022, 5:44 AM
This revision is now accepted and ready to land.Aug 25 2022, 5:44 AM

Rebased to be committed after D131429

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Repro made with -Wl,--reproduce=repro.tar: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

To repro:

  1. tar -xvf repro.tar.gz
  2. cd repro/
  3. bin/ld.lld @response.txt

Thanks for the reproducer. However, to confirm I'd a minimal set of source files since the archive of already has the bad symbol table encoded.

I believe this should be fixed by D131429. I will rebase that and adjust the test cases to allow these two patches to be committed in the inverse order.

Confirmed that D131429 fixes this.

This is causing linker failures in Android Chromium builds: https://crbug.com/1354305

Sample output:

[484/106609] LINK ./test_mixed_component_demo
FAILED: test_mixed_component_demo exe.unstripped/test_mixed_component_demo exe.unstripped/test_mixed_component_demo.map.gz
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./test_mixed_component_demo" --strip="../../third_party/llvm-build/Release+Asserts/bin/llvm-strip" --unstripped-file="./exe.unstripped/test_mixed_component_demo" --map-file "./exe.unstripped/test_mixed_component_demo.map.gz" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,--lto-O0 -pie -Bdynamic -Wl,-z,nocopyreloc -o "./exe.unstripped/test_mixed_component_demo" -Wl,--start-group @"./test_mixed_component_demo.rsp"  -Wl,--end-group  -landroid_support -ldl -lm
ld.lld: error: thinlto-cache/llvmcache-CFD42F77DBE4B29AA4645765DE7225F761BBE9DD:(function _Unwind_VRS_Pop: .text.unlikely._Unwind_VRS_Pop+0xcc): branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: .L_Unwind_VRS_Set$local interworking not performed; consider using directive '.type .L_Unwind_VRS_Set$local, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required; Unwind-EHABI.cpp:1120 (../../buildtools/third_party/libunwind/trunk/src/Unwind-EHABI.cpp:1120)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Repro made with -Wl,--reproduce=repro.tar: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

To repro:

  1. tar -xvf repro.tar.gz
  2. cd repro/
  3. bin/ld.lld @response.txt

Thanks for the reproducer. However, to confirm I'd a minimal set of source files since the archive of already has the bad symbol table encoded.

I believe this should be fixed by D131429. I will rebase that and adjust the test cases to allow these two patches to be committed in the inverse order.

Confirmed that D131429 fixes this.

Thank you for verifying!

This revision was landed with ongoing or failed builds.Aug 26 2022, 2:34 AM
This revision was automatically updated to reflect the committed changes.