[lld] r270274 - Document some constants. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri May 20 14:09:59 PDT 2016
Author: rafael
Date: Fri May 20 16:09:59 2016
New Revision: 270274
URL: http://llvm.org/viewvc/llvm-project?rev=270274&view=rev
Log:
Document some constants. NFC.
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=270274&r1=270273&r2=270274&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Fri May 20 16:09:59 2016
@@ -601,6 +601,8 @@ void X86_64TargetInfo::relaxTlsGdToLe(ui
0x48, 0x8d, 0x80, 0x00, 0x00, 0x00, 0x00 // lea x at tpoff,%rax
};
memcpy(Loc - 4, Inst, sizeof(Inst));
+ // The original code used a pc relative relocation and so we have to
+ // compensate for the -4 in had in the addend.
relocateOne(Loc + 8, R_X86_64_TPOFF32, Val + 4);
}
@@ -620,6 +622,8 @@ void X86_64TargetInfo::relaxTlsGdToIe(ui
0x48, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00 // addq x at tpoff,%rax
};
memcpy(Loc - 4, Inst, sizeof(Inst));
+ // Both code sequences are PC relatives, but since we are moving the constant
+ // forward by 8 bytes we have to subtract the value by 8.
relocateOne(Loc + 8, R_X86_64_PC32, Val - 8);
}
@@ -653,6 +657,8 @@ void X86_64TargetInfo::relaxTlsIeToLe(ui
if (*Prefix == 0x4c)
*Prefix = (IsMov || RspAdd) ? 0x49 : 0x4d;
*RegSlot = (IsMov || RspAdd) ? (0xc0 | Reg) : (0x80 | Reg | (Reg << 3));
+ // The original code used a pc relative relocation and so we have to
+ // compensate for the -4 in had in the addend.
relocateOne(Loc, R_X86_64_TPOFF32, Val + 4);
}
More information about the llvm-commits
mailing list