[lld] r326835 - Implement --just-symbols.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 6 19:08:51 PST 2018


On Tue, Mar 6, 2018 at 6:45 PM Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
>
>
> > +// What we are doing here is to read defined symbols from a given ELF
> > +// file and add them as absolute symbols.
> > +template <class ELFT> void elf::readJustSymbolsFile(MemoryBufferRef MB)
> {
> > +  typedef typename ELFT::Shdr Elf_Shdr;
> > +  typedef typename ELFT::Sym Elf_Sym;
> > +  typedef typename ELFT::SymRange Elf_Sym_Range;
> > +
> > +  StringRef ObjName = MB.getBufferIdentifier();
> > +  ELFFile<ELFT> Obj = check(ELFFile<ELFT>::create(MB.getBuffer()));
> > +  ArrayRef<Elf_Shdr> Sections = CHECK(Obj.sections(), ObjName);
> > +
> > +  for (const Elf_Shdr &Sec : Sections) {
> > +    if (Sec.sh_type != SHT_SYMTAB)
> > +      continue;
> > +
> > +    Elf_Sym_Range Syms = CHECK(Obj.symbols(&Sec), ObjName);
> > +    uint32_t FirstNonLocal = Sec.sh_info;
>
> There are now 3 places in this file that use the fact that sh_info is
> the first non-local symbol. I wonder if we could move that to a helper
> function.
>

I'll try to do that.


> I still think we should error if someone uses --just-symbols foo.o. In
> object files st_value is an offset, not an address.
>

I actually missed a few of your last comments as that's not on Phabricator.
And yes, we should do that too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180307/d0a4adc2/attachment.html>


More information about the llvm-commits mailing list