0

我正在从编译器-rt(https://github.com/llvm/llvm-project )构建 libasan.so,在使用https://patches.linaro.org/patch/129368/修补源之后,所有 cpp 都可以正确构建。但是我被 ASM (asan/asan_interceptors_vfork.S) 阻止了,在 aarch64 中,这指的是https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc。年代

错误信息:

aarch64_be-linux-gnu/bin/ld: warning: alignment 4 of symbol `_ZN14__interception10real_vforkE' in CMakeFiles/asan.dir/asan/asan_interceptors.cpp.o is smaller than 8 in CMakeFiles/asan.dir/asan/asan_interceptors_vfork.S.o
aarch64_be-linux-gnu/7.3.0/../../../../aarch64_be-linux-gnu/bin/ld: CMakeFiles/asan.dir/asan/asan_interceptors_vfork.S.o: relocation R_AARCH64_P32_ADR_PREL_PG_HI21 against symbol `_ZN14__interception10real_vforkE' which may bind externally can not be used when making a shared object; recompile with -fPIC
CMakeFiles/asan.dir/asan/asan_interceptors_vfork.S.o: in function `__interceptor_vfork':
llvm-project/compiler-rt/lib/./sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S:19:(.text+0x10): dangerous relocation: unsupported relocation
llvm-project/compiler-rt/lib/./sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S:20:(.text+0x14): relocation truncated to fit: R_AARCH64_P32_LDST64_ABS_LO12_NC against symbol `__interception::real_vfork' defined in .bss section in CMakeFiles/asan.dir/asan/asan_interceptors.cpp.o
aarch64_be-linux-gnu/7.3.0/../../../../aarch64_be-linux-gnu/bin/ld: /cdev/ASAN/llvm-project/compiler-rt/lib/./sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S:20: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined
collect2: error: ld returned 1 exit status
lib/CMakeFiles/asan.dir/build.make:1770: recipe for target 'lib/libasan.so' failed

我猜背后的原因是 asan_interceptors_vfork.S 是默认的 ILP64 格式?

ps:我在构建 asan_interceptors_vfork.So 时确实有 -fPIC

4

1 回答 1

0

你需要修改compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S:

ldr     x0, [x0, :lo12:_ZN14__interception10real_vforkE]

应该

ldr     w0, [x0, :lo12:_ZN14__interception10real_vforkE]

在构建 ILP32 代码时。

于 2021-01-21T02:53:13.873 回答