CompCert
CompCert copied to clipboard
LLVM linker, dynamic relocation against local symbol in readonly segment
static int toto;
int *const p = &toto;
int main() { return 0; }
fails to link under OpenBSD x86_64 with LLVM 13.0.0 (but I suspect this may apply to any system using the LLVM linker? perhaps even MacOS X?) with the following message:
ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
The static and const bits are necessary.
This can be fixed by using in compcert.ini:
prepro=clang
linker=clang
asm=clang
linker_options=-m64 -Wl,-z,notext
I'm unsure if something has to be done inside CompCert proper, or if one should just write that somewhere in documentation.
This is the problem that #385 addressed a while ago, but only for macOS so far. The fix needs to be propagated to other configurations.