[PATCH] D50204: [llvm-objdump] Label calls to the PLT

Paul Semel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 13:21:41 PDT 2018


paulsemel added inline comments.


================
Comment at: tools/llvm-objdump/llvm-objdump.cpp:1244
+          StringRef Str;
+          return !Section.getName(Str) && Str == ".plt";
+        });
----------------
pcc wrote:
> jgalenson wrote:
> > paulsemel wrote:
> > > pcc wrote:
> > > > paulsemel wrote:
> > > > > Not sure this is the correct way to get the PLT section. Here is how GNU readelf does : first, it searches in the dynamic entries, and then, if there is no dynamic tables, it tries to find by name.
> > > > > 
> > > > > There is a helper for getting dynamic entries in the libObject : `dynamicEntries()` in include/llvm/Object/ELF.h
> > > > > 
> > > > > Btw, I think it might be cool to have a helper that gets the PLT section in the libObject. And you might want to use it also in https://reviews.llvm.org/D50203.
> > > > Is there a DT tag for the PLT? At least I can't seem to see one in either an x86_64 or aarch64 binary, which makes sense to me because from the loader's perspective the PLT is just another block of code.
> > > Exact there is only one for the got I think.. this still look weird to search for the section name (even though 99% of the time the PLT will be called ".plt"
> > I also only found tags for the GOT (DT_PLTGOT) and the RelaPLT (DT_JMPREL) and couldn't find a PLT one for x86 or AArch64.  Should I only do this for those two and find the PLT as I'm doing now?
> > 
> > Just to be sure I understand how you want me to do this, the flow should be:
> > 
> > Call dynamicEntries().
> > Walk through the list looking for things with the above tags (or the PLT one if we can find it).
> > Once we find one we want, use its address to construct a DataRefImpl, which we can use to make a SectionRef.
> > 
> > Is that right?  Sorry about the question, but I've never used DynRanges before and there's not much documentation about them.
> I wouldn't worry about the dynamic table to be honest. Presumably the use case is being able to operate on files with stripped section headers, but if we need the section headers for the plt anyway, being able to look up the got/rela.plt via the dynamic table isn't buying us much.
Yes, I couldn't find a way to do it correctly anyway, @pcc is right, just let it like this :)


https://reviews.llvm.org/D50204





More information about the llvm-commits mailing list