Reputation: 416
There's an old project which needs to redefine symbol in build progress. I want to enable -flto, but it seems unable to redefine symbol now.
echo "int foo(){return 0;}" > foo.c
clang -c foo.c
llvm-objcopy --redefine-sym foo=bar foo.o
file foo.o
#> foo.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
clang -flto -c foo.c
llvm-objcopy --redefine-sym foo=bar foo.o
#> llvm-objcopy: error: 'foo.o': The file was not recognized as a valid object file
file foo.o
#> foo.o: LLVM IR bitcode
Or, can I do something to solve the problem in other way? What I need is clang -o abc abc.c foo.o
but let the function call in abc.c
resolved to correct function in foo.o
.
Environment info:
root@codespaces-251304:/bind# clang --version
Ubuntu clang version 19.1.0 (++20240815083225+4d4a4100f68d-1~exp1~20240815083357.22)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
root@codespaces-251304:/bind# llvm-objcopy --version
llvm-objcopy, compatible with GNU objcopy
Ubuntu LLVM version 19.1.0
Optimized build.
Upvotes: 0
Views: 86