mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
[ELF] Move init from ELFFileBase constructor to a separate function. NFC
This commit is contained in:
@@ -449,22 +449,6 @@ Optional<DILineInfo> ObjFile<ELFT>::getDILineInfo(InputSectionBase *s,
|
||||
ELFFileBase::ELFFileBase(Kind k, ELFKind ekind, MemoryBufferRef mb)
|
||||
: InputFile(k, mb) {
|
||||
this->ekind = ekind;
|
||||
switch (ekind) {
|
||||
case ELF32LEKind:
|
||||
init<ELF32LE>(k);
|
||||
break;
|
||||
case ELF32BEKind:
|
||||
init<ELF32BE>(k);
|
||||
break;
|
||||
case ELF64LEKind:
|
||||
init<ELF64LE>(k);
|
||||
break;
|
||||
case ELF64BEKind:
|
||||
init<ELF64BE>(k);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("getELFKind");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Elf_Shdr>
|
||||
@@ -475,6 +459,25 @@ static const Elf_Shdr *findSection(ArrayRef<Elf_Shdr> sections, uint32_t type) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ELFFileBase::init() {
|
||||
switch (ekind) {
|
||||
case ELF32LEKind:
|
||||
init<ELF32LE>(fileKind);
|
||||
break;
|
||||
case ELF32BEKind:
|
||||
init<ELF32BE>(fileKind);
|
||||
break;
|
||||
case ELF64LEKind:
|
||||
init<ELF64LE>(fileKind);
|
||||
break;
|
||||
case ELF64BEKind:
|
||||
init<ELF64BE>(fileKind);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("getELFKind");
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT> void ELFFileBase::init(InputFile::Kind k) {
|
||||
using Elf_Shdr = typename ELFT::Shdr;
|
||||
using Elf_Sym = typename ELFT::Sym;
|
||||
@@ -1233,6 +1236,7 @@ template <class ELFT>
|
||||
static bool isNonCommonDef(ELFKind ekind, MemoryBufferRef mb, StringRef symName,
|
||||
StringRef archiveName) {
|
||||
ObjFile<ELFT> *obj = make<ObjFile<ELFT>>(ekind, mb, archiveName);
|
||||
obj->init();
|
||||
StringRef stringtable = obj->getStringTable();
|
||||
|
||||
for (auto sym : obj->template getGlobalELFSyms<ELFT>()) {
|
||||
@@ -1754,6 +1758,7 @@ ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,
|
||||
default:
|
||||
llvm_unreachable("getELFKind");
|
||||
}
|
||||
f->init();
|
||||
f->lazy = lazy;
|
||||
return f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user