Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
ELF/InputSection.cpp
Show First 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | case R_PPC_OPD: { | ||||
return SymVA - P; | return SymVA - P; | ||||
} | } | ||||
case R_PC: | case R_PC: | ||||
case R_RELAX_GOT_PC: | case R_RELAX_GOT_PC: | ||||
return Body.getVA<ELFT>(A) - P; | return Body.getVA<ELFT>(A) - P; | ||||
case R_PLT_PAGE_PC: | case R_PLT_PAGE_PC: | ||||
case R_PAGE_PC: | case R_PAGE_PC: | ||||
return getAArch64Page(Body.getVA<ELFT>(A)) - getAArch64Page(P); | return getAArch64Page(Body.getVA<ELFT>(A)) - getAArch64Page(P); | ||||
case R_PPC_SDA: { | |||||
auto CheckReturn = [](int64_t Val, uint32_t Reg) -> typename ELFT::uint { | |||||
if (Val > 32767 || Val < -32768) | |||||
error("Small data relocation delta exceeds 16-bit value"); | |||||
return (Val & 0xffff) | (Reg << 16); | |||||
}; | |||||
const DefinedRegular<ELFT> *RelSym = dyn_cast<DefinedRegular<ELFT>>(&Body); | |||||
if (RelSym && RelSym->Section) { | |||||
const InputSectionBase<ELFT> *Section = RelSym->Section; | |||||
if (Section->OutSec) { | |||||
// Relocate relative to _SDA_BASE_ or _SDA2_BASE_ synthetic symbols. | |||||
const OutputSectionBase<ELFT> *OutSec = RelSym->Section->OutSec; | |||||
if (ElfSym<ELFT>::SdaBase && | |||||
(OutSec->getName() == ".sdata" || OutSec->getName() == ".sbss")) | |||||
return CheckReturn(Body.getVA<ELFT>(A) - | |||||
int64_t(ElfSym<ELFT>::SdaBase->Value), 13); | |||||
if (ElfSym<ELFT>::Sda2Base && OutSec->getName() == ".sdata2") | |||||
return CheckReturn(Body.getVA<ELFT>(A) - | |||||
int64_t(ElfSym<ELFT>::Sda2Base->Value), 2); | |||||
} | |||||
} | |||||
error("Unable to perform small data relocation without designated section"); | |||||
return 0; | |||||
} | |||||
} | } | ||||
llvm_unreachable("Invalid expression"); | llvm_unreachable("Invalid expression"); | ||||
} | } | ||||
// This function applies relocations to sections without SHF_ALLOC bit. | // This function applies relocations to sections without SHF_ALLOC bit. | ||||
// Such sections are never mapped to memory at runtime. Debug sections are | // Such sections are never mapped to memory at runtime. Debug sections are | ||||
// an example. Relocations in non-alloc sections are much easier to | // an example. Relocations in non-alloc sections are much easier to | ||||
// handle than in allocated sections because it will never need complex | // handle than in allocated sections because it will never need complex | ||||
▲ Show 20 Lines • Show All 471 Lines • Show Last 20 Lines |