[JITLink][ELF][x86-64] Adjust addends for R_X86_64_PLT32 relocations.
authorLang Hames <lhames@gmail.com>
Sun, 5 Dec 2021 09:31:03 +0000 (20:31 +1100)
committerLang Hames <lhames@gmail.com>
Sun, 5 Dec 2021 09:37:55 +0000 (20:37 +1100)
commit21562c03ed17ce288a0de095e0f2ae4f452d3359
treed3fd3bbbbfd857d8946ca716ea44a15afd8d5f4e
parent57ff805a6da7a54434646af589455069459c667e
[JITLink][ELF][x86-64] Adjust addends for R_X86_64_PLT32 relocations.

R_X86_64_PLT32 explicitly represents the '-4' PC-adjustment in the relocation's
addend, but JITLink's x86_64::Branch32PCRel includes the PC-adjustment
implicitly. We have been zeroing the addend to account for the difference, but
this breaks for branches to non-zero offsets past labels. This patch updates the
relocation parsing code to unconditionally adjust the offset by '+4' instead.
For branches directly to labels the result is still 0, for branches to offsets
past labels the result is the correct addend for x86_64::Branch32PCRel.
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_small_pic_relocations.s