mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 22:17:23 +08:00
[ELF] InputFile: change symbols to unique_ptr<Symbol *[]>
We may try a custom allocator in the future.
This commit is contained in:
@@ -1036,7 +1036,10 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
|
||||
template <class ELFT>
|
||||
void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
|
||||
ArrayRef<Elf_Sym> eSyms = this->getELFSyms<ELFT>();
|
||||
symbols.resize(eSyms.size());
|
||||
if (numSymbols == 0) {
|
||||
numSymbols = eSyms.size();
|
||||
symbols = std::make_unique<Symbol *[]>(numSymbols);
|
||||
}
|
||||
|
||||
// Some entries have been filled by LazyObjFile.
|
||||
for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i)
|
||||
@@ -1675,7 +1678,10 @@ void BitcodeFile::parse() {
|
||||
.second);
|
||||
}
|
||||
|
||||
symbols.resize(obj->symbols().size());
|
||||
if (numSymbols == 0) {
|
||||
numSymbols = obj->symbols().size();
|
||||
symbols = std::make_unique<Symbol *[]>(numSymbols);
|
||||
}
|
||||
// Process defined symbols first. See the comment in
|
||||
// ObjFile<ELFT>::initializeSymbols.
|
||||
for (auto [i, irSym] : llvm::enumerate(obj->symbols()))
|
||||
@@ -1690,7 +1696,8 @@ void BitcodeFile::parse() {
|
||||
}
|
||||
|
||||
void BitcodeFile::parseLazy() {
|
||||
symbols.resize(obj->symbols().size());
|
||||
numSymbols = obj->symbols().size();
|
||||
symbols = std::make_unique<Symbol *[]>(numSymbols);
|
||||
for (auto [i, irSym] : llvm::enumerate(obj->symbols()))
|
||||
if (!irSym.isUndefined()) {
|
||||
auto *sym = symtab.insert(saver().save(irSym.getName()));
|
||||
@@ -1766,7 +1773,8 @@ ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,
|
||||
|
||||
template <class ELFT> void ObjFile<ELFT>::parseLazy() {
|
||||
const ArrayRef<typename ELFT::Sym> eSyms = this->getELFSyms<ELFT>();
|
||||
symbols.resize(eSyms.size());
|
||||
numSymbols = eSyms.size();
|
||||
symbols = std::make_unique<Symbol *[]>(numSymbols);
|
||||
for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i)
|
||||
if (eSyms[i].st_shndx != SHN_UNDEF)
|
||||
symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this));
|
||||
@@ -1776,7 +1784,7 @@ template <class ELFT> void ObjFile<ELFT>::parseLazy() {
|
||||
// resolve() may trigger this->extract() if an existing symbol is an undefined
|
||||
// symbol. If that happens, this function has served its purpose, and we can
|
||||
// exit from the loop early.
|
||||
for (Symbol *sym : makeArrayRef(symbols).slice(firstGlobal))
|
||||
for (Symbol *sym : getGlobalSymbols())
|
||||
if (sym) {
|
||||
sym->resolve(LazyObject{*this});
|
||||
if (!lazy)
|
||||
|
||||
Reference in New Issue
Block a user