Reduce code duplication. NFC.

llvm-svn: 302155
This commit is contained in:
Rafael Espindola 2017-05-04 14:54:48 +00:00
parent 104e92a630
commit 808f2d3c62
4 changed files with 12 additions and 12 deletions

View File

@ -977,6 +977,13 @@ MemoryBufferRef LazyObjectFile::getBuffer() {
return MB;
}
InputFile *LazyObjectFile::fetch() {
MemoryBufferRef MBRef = getBuffer();
if (MBRef.getBuffer().empty())
return nullptr;
return createObjectFile(MBRef);
}
template <class ELFT> void LazyObjectFile::parse() {
for (StringRef Sym : getSymbols())
Symtab<ELFT>::X->addLazyObject(Sym, *this);

View File

@ -227,6 +227,7 @@ public:
template <class ELFT> void parse();
MemoryBufferRef getBuffer();
InputFile *fetch();
private:
std::vector<StringRef> getSymbols();

View File

@ -540,13 +540,10 @@ void SymbolTable<ELFT>::addLazyObject(StringRef Name, LazyObjectFile &Obj) {
return;
// See comment for addLazyArchive above.
if (S->isWeak()) {
if (S->isWeak())
replaceBody<LazyObject>(S, Name, Obj, S->body()->Type);
} else {
MemoryBufferRef MBRef = Obj.getBuffer();
if (!MBRef.getBuffer().empty())
addFile(createObjectFile(MBRef));
}
else if (InputFile *F = Obj.fetch())
addFile(F);
}
// Process undefined (-u) flags by loading lazy symbols named by those flags.

View File

@ -327,12 +327,7 @@ InputFile *LazyArchive::fetch() {
return createObjectFile(MBInfo.first, file()->getName(), MBInfo.second);
}
InputFile *LazyObject::fetch() {
MemoryBufferRef MBRef = file()->getBuffer();
if (MBRef.getBuffer().empty())
return nullptr;
return createObjectFile(MBRef);
}
InputFile *LazyObject::fetch() { return file()->fetch(); }
uint8_t Symbol::computeBinding() const {
if (Config->Relocatable)