Directly compute the right value for R_RELAX_TLS_GD_TO_IE.

This avoid doing math in Target.cpp to compensate.

llvm-svn: 270266
This commit is contained in:
Rafael Espindola 2016-05-20 20:09:35 +00:00
parent 3eded68bef
commit 74f3dbe438
2 changed files with 2 additions and 3 deletions

View File

@ -168,10 +168,10 @@ getSymVA(uint32_t Type, typename ELFT::uint A, typename ELFT::uint P,
case R_GOTREL:
return Body.getVA<ELFT>(A) - Out<ELFT>::Got->getVA();
case R_GOT_FROM_END:
case R_RELAX_TLS_GD_TO_IE:
return Body.getGotOffset<ELFT>() + A -
Out<ELFT>::Got->getNumEntries() * sizeof(uintX_t);
case R_GOT:
case R_RELAX_TLS_GD_TO_IE:
return Body.getGotVA<ELFT>() + A;
case R_GOT_PAGE_PC:
return getAArch64Page(Body.getGotVA<ELFT>() + A) - getAArch64Page(P);

View File

@ -416,8 +416,7 @@ void X86TargetInfo::relaxTlsGdToIe(uint8_t *Loc, uint32_t Type,
0x03, 0x83, 0x00, 0x00, 0x00, 0x00 // addl 0(%ebx), %eax
};
memcpy(Loc - 3, Inst, sizeof(Inst));
relocateOne(Loc + 5, R_386_32, Val - Out<ELF32LE>::Got->getVA() -
Out<ELF32LE>::Got->getNumEntries() * 4);
relocateOne(Loc + 5, R_386_32, Val);
}
// In some conditions, relocations can be optimized to avoid using GOT.