[llvm-dev] [lld][ELF] Addends adjustment for relocatable object
Simon Atanasyan via llvm-dev
llvm-dev at lists.llvm.org
Tue Sep 27 08:28:03 PDT 2016
Hi,
Now in case of relocatable object generation LLD merges and copies
REL/RELA sections as is and does not touch any addends. But it is
incorrect. If we have a relocation which targets a section, we have to
adjust the relocation's addend to take in account that the section
might be merged with other ones.
Here is the reproduction script:
% cat t1.s
.data
.long 0
.text
bar:
movl $1, .data
% cat t2.s
.data
.long 0
.text
foo:
movl $1, .data
% as t1.s -o t1.o
% as t2.s -o t2.o
% lld -flavor gnu -r t1.o t2.o
% llvm-readobj -r a.out
0x3 R_X86_64_32S .data 0x0
0xE R_X86_64_32S .data 0x0
% ld -r t1.o t2.o
% llvm-readobj -r a.out
0x3 R_X86_64_32S .data 0x0
0xE R_X86_64_32S .data 0x4
Are there any plans to fix this problem? I think it is rather easy to
fix it for RELA sections, but the case is more complicated for REL
sections. IMHO an alternative solution would be not to merge sections
while generate a relocatable object.
--
Simon Atanasyan
More information about the llvm-dev
mailing list