This is an archive of the discontinued LLVM Phabricator instance.

Simplify LazyobjFile and readElfSymbols.
ClosedPublic

Authored by ruiu on Mar 6 2018, 8:06 PM.

Details

Summary

addElfSymbols and readJustSymbolsFile still has duplicate code, but
I didn't come up with a good idea to eliminate them. Since this patch
is an improvement, I'm sending this for review.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Mar 6 2018, 8:06 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 7 2018, 5:08 PM
This revision was automatically updated to reflect the committed changes.

Rui Ueyama via Phabricator via llvm-commits
<llvm-commits@lists.llvm.org> writes:

-template <class ELFT> std::vector<StringRef> LazyObjFile::getElfSymbols() {

  • typedef typename ELFT::Shdr Elf_Shdr;
  • typedef typename ELFT::Sym Elf_Sym;
  • typedef typename ELFT::SymRange Elf_Sym_Range;

+template <class ELFT> void LazyObjFile::addElfSymbols() {
+ StringRef ObjName = MB.getBufferIdentifier();
+ ELFFile<ELFT> Obj = check(ELFFile<ELFT>::create(MB.getBuffer()));
+ ArrayRef<typename ELFT::Shdr> Sections = CHECK(Obj.sections(), ObjName);

Why change CHECK(..., this) to CHECK(..., ObjName)?

LGTM with that.

Cheers,
Rafael