On Armv6-M the branch may not able to reach the _Unwind_Resume function because it's relocation(R_ARM_THM_JUMP11) is in -2048, 2047 range only.
Details
- Reviewers
chill miyuki stuij lenary - Group Reviewers
Restricted Project - Commits
- rGc5c4bac6c03d: Reland "[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M"
rG3255578ee1db: [libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxxabi/src/cxa_exception.cpp | ||
---|---|---|
385–386 | I'm not entirely convinced. ... push {r1, r2, r3, lr} bl __cxa_end_cleanup_impl ldr r3, =_Unwind_Resume mov r12, r3 pop {r1, r2, r3, r4} mov lr, r4 bx r12 ... |
libcxxabi/src/cxa_exception.cpp | ||
---|---|---|
385–386 | This clobbers r3 - was that your intention (given you pushed and popped it)? r4 is clobbered by the function already, so maybe that would be better if you need to preserve as many registers as possible for unwinding? |
libcxxabi/src/cxa_exception.cpp | ||
---|---|---|
385–386 | "Shouldn't the linker take care if the branch is too far away?" sadly not: R_ARM_THM_JUMP11 (the relocation on this b in armv6m) is not one of the relocations the ABI lets the linker insert a veneer for. Unlike aarch64 where veneers are allowed anywhere, on aarch32 veneers are only allowed to be used with specific relocations. |
libcxxabi/src/cxa_exception.cpp | ||
---|---|---|
385–386 | Right, r4 is just saved to align the stack so it could be reused here. |
This breaks out build.
[104/58411] SOLINK ./libc++_chrome.cr.so FAILED: libc++_chrome.cr.so libc++_chrome.cr.so.TOC lib.unstripped/libc++_chrome.cr.so python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Releas...(too long) ld.lld: error: relocation R_ARM_ABS32 cannot be used against symbol '_Unwind_Resume'; recompile with -fPIC >>> defined in obj/buildtools/third_party/libunwind/libunwind/Unwind-EHABI.o >>> referenced by cxa_exception.cpp >>> obj/buildtools/third_party/libc++abi/libc++abi/cxa_exception.o:(.text.__cxa_end_cleanup+0x10) clang++: error: linker command failed with exit code 1 (use -v to see invocation)
(https://bugs.chromium.org/p/chromium/issues/detail?id=1267270)
Please take a look.
Thanks for the report, the above proposed change works for chrome and embedded targets too.
I'll reland the patch end of Monday.
libcxxabi/src/cxa_exception.cpp | ||
---|---|---|
385–386 |
Hi @danielkiss,
same as for @thakis, these changes have broken the armv7 toolchain builder
11.219 [3/3/902] Linking CXX shared library C:\buildbot\as-builder-1\x-armv7l\build\lib\armv7-unknown-linux-gnueabihf\libc++abi.so.1.0 FAILED: C:/buildbot/as-builder-1/x-armv7l/build/lib/armv7-unknown-linux-gnueabihf/libc++abi.so.1.0 cmd.exe /C "cd . && C:\buildbot\as-builder-1\x-armv7l\build\.\bin\clang++.exe --target=armv7-unknown-linux-gnueabihf -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections --target=armv7-unknown-linux-gnueabihf --sysroot=C:/buildbot/.arm-ubuntu -O3 -DNDEBUG -Wl,-z,nodelete -Wl,--color-diagnostics --target=armv7-unknown-linux-gnueabihf --sysroot=C:/buildbot/.arm-ubuntu -nostdlib++ -shared -Wl,-soname,libc++abi.so.1 -o C:\buildbot\as-builder-1\x-armv7l\build\lib\armv7-unknown-linux-gnueabihf\libc++abi.so.1.0 libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_aux_runtime.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_default_handlers.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_demangle.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_exception_storage.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_guard.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_handlers.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_vector.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_virtual.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/stdlib_exception.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/stdlib_stdexcept.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/stdlib_typeinfo.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/abort_message.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/fallback_malloc.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/private_typeinfo.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_exception.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_personality.cpp.o libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_thread_atexit.cpp.o -Wl,-rpath,$ORIGIN/../lib C:/buildbot/as-builder-1/x-armv7l/build/lib/clang/14.0.0/lib/armv7-unknown-linux-gnueabihf/libclang_rt.builtins.a C:/buildbot/as-builder-1/x-armv7l/build/lib/armv7-unknown-linux-gnueabihf/libunwind.a -lpthread -lc C:/buildbot/as-builder-1/x-armv7l/build/lib/clang/14.0.0/lib/armv7-unknown-linux-gnueabihf/libclang_rt.builtins.a -ldl -lpthread && cd ." ld.lld: error: relocation R_ARM_ABS32 cannot be used against symbol '_Unwind_Resume'; recompile with -fPIC >>> defined in C:/buildbot/as-builder-1/x-armv7l/build/lib/armv7-unknown-linux-gnueabihf/libunwind.a(Unwind-EHABI.cpp.o) >>> referenced by cxa_exception.cpp >>> libcxxabi/src/CMakeFiles/cxxabi_shared.dir/cxa_exception.cpp.o:(.text.__cxa_end_cleanup+0x18) clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Hi @danielkiss,
The buildbot's build is broken already for more than one day without attention. Sorry, but I'm going to revert this commit.
I'm not entirely convinced.
Isn't this function supposed to preserve r3 ?
Shouldn't the linker take care if the branch is too far away?
If not the linker, couldn't we use r12/ip for the call ?
e.g.