forked from OSchip/llvm-project
ELF2: Create a function to get VA from Elf_Rel.
And remove git getLocalSymVA because there's no user of the function anymore. llvm-svn: 250095
This commit is contained in:
parent
436256a713
commit
126d08f891
|
@ -41,10 +41,7 @@ void InputSection<ELFT>::relocate(
|
|||
// resolved so we don't allocate a SymbolBody.
|
||||
const Elf_Shdr *SymTab = File.getSymbolTable();
|
||||
if (SymIndex < SymTab->sh_info) {
|
||||
const Elf_Sym *Sym = File.getObj().getRelocationSymbol(&RI, SymTab);
|
||||
if (!Sym)
|
||||
continue;
|
||||
SymVA = getLocalSymVA(Sym, File);
|
||||
SymVA = getLocalRelTarget(File, RI);
|
||||
} else {
|
||||
SymbolBody &Body = *File.getSymbolBody(SymIndex)->repl();
|
||||
SymVA = getSymVA<ELFT>(Body);
|
||||
|
|
|
@ -117,7 +117,6 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
|
||||
const ObjectFile<ELFT> &File = *C.getFile();
|
||||
SymbolBody *Body = File.getSymbolBody(SymIndex);
|
||||
const ELFFile<ELFT> &Obj = File.getObj();
|
||||
if (Body)
|
||||
Body = Body->repl();
|
||||
|
||||
|
@ -130,8 +129,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
if (Body)
|
||||
Addend += getSymVA<ELFT>(cast<ELFSymbolBody<ELFT>>(*Body));
|
||||
else
|
||||
Addend += getLocalSymVA(
|
||||
Obj.getRelocationSymbol(&RI, File.getSymbolTable()), File);
|
||||
Addend += getLocalRelTarget(File, RI);
|
||||
}
|
||||
P->setSymbolAndType(0, Target->getRelativeReloc(), IsMips64EL);
|
||||
}
|
||||
|
@ -423,10 +421,18 @@ typename ELFFile<ELFT>::uintX_t lld::elf2::getSymVA(const SymbolBody &S) {
|
|||
|
||||
template <class ELFT>
|
||||
typename ELFFile<ELFT>::uintX_t
|
||||
lld::elf2::getLocalSymVA(const typename ELFFile<ELFT>::Elf_Sym *Sym,
|
||||
const ObjectFile<ELFT> &File) {
|
||||
uint32_t SecIndex = Sym->st_shndx;
|
||||
lld::elf2::getLocalRelTarget(const ObjectFile<ELFT> &File,
|
||||
const typename ELFFile<ELFT>::Elf_Rel &RI) {
|
||||
typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
|
||||
const Elf_Sym *Sym =
|
||||
File.getObj().getRelocationSymbol(&RI, File.getSymbolTable());
|
||||
|
||||
// For certain special relocations, such as R_PPC64_TOC, there's no
|
||||
// corresponding symbol. Just return 0 in that case.
|
||||
if (!Sym)
|
||||
return 0;
|
||||
|
||||
uint32_t SecIndex = Sym->st_shndx;
|
||||
if (SecIndex == SHN_XINDEX)
|
||||
SecIndex = File.getObj().getExtendedSymbolTableIndex(
|
||||
Sym, File.getSymbolTable(), File.getSymbolTableShndx());
|
||||
|
@ -736,16 +742,20 @@ template ELFFile<ELF64LE>::uintX_t getSymVA<ELF64LE>(const SymbolBody &);
|
|||
template ELFFile<ELF64BE>::uintX_t getSymVA<ELF64BE>(const SymbolBody &);
|
||||
|
||||
template ELFFile<ELF32LE>::uintX_t
|
||||
getLocalSymVA(const ELFFile<ELF32LE>::Elf_Sym *, const ObjectFile<ELF32LE> &);
|
||||
getLocalRelTarget(const ObjectFile<ELF32LE> &,
|
||||
const ELFFile<ELF32LE>::Elf_Rel &);
|
||||
|
||||
template ELFFile<ELF32BE>::uintX_t
|
||||
getLocalSymVA(const ELFFile<ELF32BE>::Elf_Sym *, const ObjectFile<ELF32BE> &);
|
||||
getLocalRelTarget(const ObjectFile<ELF32BE> &,
|
||||
const ELFFile<ELF32BE>::Elf_Rel &);
|
||||
|
||||
template ELFFile<ELF64LE>::uintX_t
|
||||
getLocalSymVA(const ELFFile<ELF64LE>::Elf_Sym *, const ObjectFile<ELF64LE> &);
|
||||
getLocalRelTarget(const ObjectFile<ELF64LE> &,
|
||||
const ELFFile<ELF64LE>::Elf_Rel &);
|
||||
|
||||
template ELFFile<ELF64BE>::uintX_t
|
||||
getLocalSymVA(const ELFFile<ELF64BE>::Elf_Sym *, const ObjectFile<ELF64BE> &);
|
||||
getLocalRelTarget(const ObjectFile<ELF64BE> &,
|
||||
const ELFFile<ELF64BE>::Elf_Rel &);
|
||||
|
||||
template bool includeInSymtab<ELF32LE>(const SymbolBody &);
|
||||
template bool includeInSymtab<ELF32BE>(const SymbolBody &);
|
||||
|
|
|
@ -37,8 +37,8 @@ typename llvm::object::ELFFile<ELFT>::uintX_t getSymVA(const SymbolBody &S);
|
|||
|
||||
template <class ELFT>
|
||||
typename llvm::object::ELFFile<ELFT>::uintX_t
|
||||
getLocalSymVA(const typename llvm::object::ELFFile<ELFT>::Elf_Sym *Sym,
|
||||
const ObjectFile<ELFT> &File);
|
||||
getLocalRelTarget(const ObjectFile<ELFT> &File,
|
||||
const typename llvm::object::ELFFile<ELFT>::Elf_Rel &Sym);
|
||||
bool canBePreempted(const SymbolBody *Body);
|
||||
template <class ELFT> bool includeInSymtab(const SymbolBody &B);
|
||||
|
||||
|
|
Loading…
Reference in New Issue