CompCert icon indicating copy to clipboard operation
CompCert copied to clipboard

Use .data.rel.ro section for const data with relocatable inits on ELF targets

Open xavierleroy opened this issue 3 years ago • 0 comments

This is a follow-up to ed89275cb. With the Clang/LLVM linker and loader, "const" variables initialized with symbol addresses which may need relocation cannot go in a readonly section and must go in a special const_data (for macOS) or .data.rel.ro (for ELF) section. The GNU linker and loader support .data.rel.ro but can also manage if relocatable addresses are put in the .rodata section.

In this PR, AArch64, ARM, RISC-V and x86 ELF targets are changed to use .data.rel.ro.

PowerPC / ELF is unchanged because we use the EABI variant, which has no .data.rel.ro section as far as I can see in GCC's output. (The SVR4 variant has .data.rel.ro but does not have .sdata2, which CompCert uses.)

Fixes: #454

xavierleroy avatar Sep 25 '22 14:09 xavierleroy