<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Mar 6, 2018 at 6:45 PM Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Rui Ueyama via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
<br>
> +// What we are doing here is to read defined symbols from a given ELF<br>
> +// file and add them as absolute symbols.<br>
> +template <class ELFT> void elf::readJustSymbolsFile(MemoryBufferRef MB) {<br>
> +  typedef typename ELFT::Shdr Elf_Shdr;<br>
> +  typedef typename ELFT::Sym Elf_Sym;<br>
> +  typedef typename ELFT::SymRange Elf_Sym_Range;<br>
> +<br>
> +  StringRef ObjName = MB.getBufferIdentifier();<br>
> +  ELFFile<ELFT> Obj = check(ELFFile<ELFT>::create(MB.getBuffer()));<br>
> +  ArrayRef<Elf_Shdr> Sections = CHECK(Obj.sections(), ObjName);<br>
> +<br>
> +  for (const Elf_Shdr &Sec : Sections) {<br>
> +    if (Sec.sh_type != SHT_SYMTAB)<br>
> +      continue;<br>
> +<br>
> +    Elf_Sym_Range Syms = CHECK(Obj.symbols(&Sec), ObjName);<br>
> +    uint32_t FirstNonLocal = Sec.sh_info;<br>
<br>
There are now 3 places in this file that use the fact that sh_info is<br>
the first non-local symbol. I wonder if we could move that to a helper<br>
function.<br></blockquote><div><br></div><div>I'll try to do that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I still think we should error if someone uses --just-symbols foo.o. In<br>
object files st_value is an offset, not an address.<br></blockquote><div><br></div><div>I actually missed a few of your last comments as that's not on Phabricator. And yes, we should do that too.</div></div></div>