x86_64: Use addend on relocs

Traditional behaviour on x86-64 is to encode the relocation
addend in r_addend, not in the relocated field (after all,
that's the reason to use RELA relocs to begin with).  Our
linker can deal with both, other linkers as well.  But using
e.g. the GNU assembler one can detect differences (equivalent
code in the end, but still a difference).

Now there's only a trivial difference in tests/asmtest.S
(having to do with ordering of prefixes).
This commit is contained in:
Michael Matz
2016-05-09 23:09:55 +02:00
parent 5e47b08dc8
commit 9645b62a65
2 changed files with 14 additions and 19 deletions

View File

@ -927,7 +927,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
qrel->r_offset = rel->r_offset;
qrel->r_info = ELFW(R_INFO)(esym_index, R_X86_64_PC32);
/* Use sign extension! */
qrel->r_addend = (int)read32le(ptr);
qrel->r_addend = (int)read32le(ptr) + rel->r_addend;
qrel++;
break;
}