Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/InputSection.cpp
Show First 20 Lines • Show All 485 Lines • ▼ Show 20 Lines | if (sym.type == STT_SECTION) { | ||||
// individual "gp" values used by each input object file. | // individual "gp" values used by each input object file. | ||||
// As a workaround we add the "gp" value to the relocation | // As a workaround we add the "gp" value to the relocation | ||||
// addend and save it back to the file. | // addend and save it back to the file. | ||||
addend += sec->getFile<ELFT>()->mipsGp0; | addend += sec->getFile<ELFT>()->mipsGp0; | ||||
} | } | ||||
if (RelTy::IsRela) | if (RelTy::IsRela) | ||||
p->r_addend = sym.getVA(addend) - section->getOutputSection()->addr; | p->r_addend = sym.getVA(addend) - section->getOutputSection()->addr; | ||||
else if (config->relocatable && type != target->noneRel) | else if (config->relocatable) { | ||||
// For STT_SECTION symbols, BPF llvm target already wrote the | |||||
// section offset in each relocation instruction, so | |||||
// pushing to section relocations is not needed any more. | |||||
if (config->emachine != EM_BPF && type != target->noneRel) | |||||
sec->relocations.push_back({R_ABS, type, rel.r_offset, addend, &sym}); | sec->relocations.push_back({R_ABS, type, rel.r_offset, addend, &sym}); | ||||
} | |||||
} else if (config->emachine == EM_PPC && type == R_PPC_PLTREL24 && | } else if (config->emachine == EM_PPC && type == R_PPC_PLTREL24 && | ||||
p->r_addend >= 0x8000) { | p->r_addend >= 0x8000) { | ||||
// Similar to R_MIPS_GPREL{16,32}. If the addend of R_PPC_PLTREL24 | // Similar to R_MIPS_GPREL{16,32}. If the addend of R_PPC_PLTREL24 | ||||
// indicates that r30 is relative to the input section .got2 | // indicates that r30 is relative to the input section .got2 | ||||
// (r_addend>=0x8000), after linking, r30 should be relative to the output | // (r_addend>=0x8000), after linking, r30 should be relative to the output | ||||
// section .got2 . To compensate for the shift, adjust r_addend by | // section .got2 . To compensate for the shift, adjust r_addend by | ||||
// ppc32Got2OutSecOff. | // ppc32Got2OutSecOff. | ||||
p->r_addend += sec->file->ppc32Got2OutSecOff; | p->r_addend += sec->file->ppc32Got2OutSecOff; | ||||
▲ Show 20 Lines • Show All 979 Lines • Show Last 20 Lines |