[PATCH] D13566: [ELF2] PPC64 needs to delay local-call relocations until after the function-descriptor values are known

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 15:52:47 PDT 2015


ruiu added inline comments.

================
Comment at: ELF/Writer.cpp:479-480
@@ -475,1 +478,4 @@
+  // relocations.
+  PPC64TargetInfo::OpdPtr =
+    Map.lookup({".opd", SHT_PROGBITS, SHF_WRITE | SHF_ALLOC});
 }
----------------
hfinkel wrote:
> ruiu wrote:
> > hfinkel wrote:
> > > ruiu wrote:
> > > >   if (OutputSection<ELFT> *Sec = Map.lookup({".opd", ...))
> > > >     Target->Opd = reinterpret_cast<OutputSection<ELF64BE> *>(Sec);
> > > Do you want me to move Opd and OpdBuf into TargetInfo to make this work?
> > > 
> > Ah, then this?
> > 
> >   if (OutputSection<ELFT> *Sec = Map.lookup({".opd", ...))
> >     reinterpet_cast<PPC64TargetInfo *>(Target)->Opd = reinterpret_cast<OutputSection<ELF64BE> *>(Sec);
> > 
> No, because they any object file with a section names .opd, that happens not to be targeting ppc64, will cause us to corrupt our internal data structures. This does not seem all that far fetched to me, because when we also add support for little-endian ppc64 (power8 and later), that target will not use .opd, but I can certainly imagine some tools still producing .opd sections.
> 
> To think ahead a little bit, can I add a Target callback to enable it to inspect the Map (or maybe just the OutputSections array)? The target needs to grab .opd to do this function-descriptor indirection, but that's not the end of this. We'll also want to grab .toc and .tocbss to really get the TOC base address calculation right. We'll want .branch_lt (which we'll need to add if not already present) in order to generate long-branch stubs.
> 
I'm not confident if we really want to have that function. That might be useful, but can be a bit overkill. I'd just add Opd and OpdBuf (but I'd name OpdStart instead of OpdBuf) to Out for now, which is the previous code. Sorry for back-and-force.


http://reviews.llvm.org/D13566





More information about the llvm-commits mailing list