[llvm] [Bolt] fix a wrong relocation update issue with weak references (PR #69136)
Selin Dag via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 15:57:24 PDT 2024
s-dag wrote:
Hi,
Wanted to report this seems to be the same issue we ran into while trying to apply BOLT to an Aarch64 binary dynamically linked with musl. So it is a very important use case for embedded software world and we expect more people will run into it as BOLT Aarch64/embedded usage picks up. It can be reproduced with a simple hello_world. Reproduction steps are below:
```
cat hello.c
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
```
1- `aarch64-unknown-linux-musl-gcc hello.c -Wl,-dynamic-linker=ld-musl-aarch64.so.1 -Wl,-emit-relocs -o hello_aarch64`
2- `llvm-bolt hello_aarch64 -o hello_bolted_skip --skip-funcs=.* --use-gnu-stack`
`hello_bolted_skip` segfaults at start. When we compared disassembly, we saw .rodata had differences which boiled down to `<__register_frame_info at plt>` /`<__deregister_frame_info at plt>` relocs added by BOLT that are actually undefined weak references and are not defined in musl.
The patch in https://github.com/llvm/llvm-project/pull/69136/commits/2acdf00a1882efe43b3efec778b2d68600bfb807 does fix this reproducer as well as our own binary. We hope to see it merged soon.
https://github.com/llvm/llvm-project/pull/69136
More information about the llvm-commits
mailing list