Closed
Description
Sometimes we might want to rename sections in relocatable object files with a linker script.
By convention, a name of relocation section is based on the section which the relocations apply, for example, the relocation section for ".foo" would have the name ".rel[a].foo".
Linker Script:
SECTIONS {
.foo : {
*(.bar)
}
}
Input relocatable object file's section headers:
[Nr] Name Type Flg Lk Inf Al
[ 0] NULL 0 0 0
[ 1] .foo PROGBITS AX 0 0 4
[ 2] .rela.foo RELA I 8 1 8
...
Output relocatable object file's section headers:
ld.bfd
/ ld.gold
:
[Nr] Name Type Flg Lk Inf Al
[ 0] NULL 0 0 0
[ 1] .bar PROGBITS AX 0 0 4
[ 2] .rela.bar RELA I 8 1 8
...
ld.lld
:
[Nr] Name Type Flg Lk Inf Al
[ 0] NULL 0 0 0
[ 1] .bar PROGBITS AX 0 0 4
[ 2] .rela.foo RELA I 8 1 8
...