[PATCH] D14955: [ELF] - Lazy relocations support for x86 target.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 04:04:29 PST 2015


grimar added inline comments.

================
Comment at: ELF/Target.cpp:196
@@ +195,3 @@
+void X86TargetInfo::writeGotPltHeaderEntries(uint8_t *Buf) const {
+  write32le(Buf, Out<ELF32LE>::Dynamic->getVA());
+}
----------------
ikudrin wrote:
> The address of the .dynamic section has to be stored at the location which is pointed to by the _GLOBAL_OFFSET_TABLE_ symbol. Although we don't use this symbol explicitly, the same effect is achieved in the method InputSectionBase<ELFT>::relocate() in the branch "if (Target->relocPointsToGot(Type))".  But in that branch, the address of .got section is used, not .got.plt's.
According to gold source code _GLOBAL_OFFSET_TABLE_ points to got.plt for x86. So if address of .dynamic section should be placed there then .. its already there :)

Just note about relocPointsToGot() - I will review this one. It is not clear for me why we need it as separate method if we have relocNeedsGot(). relocPointsToGot() is used only for x86 now and I think we can combine it with relocNeedsGot().

================
Comment at: ELF/Writer.cpp:248-250
@@ -247,2 +247,5 @@
           continue;
-        Out<ELFT>::Plt->addEntry(Body);
+        unsigned RelOff = Target->supportsLazyRelocations()
+                              ? Out<ELFT>::RelaPlt->getRelocOffset()
+                              : Out<ELFT>::RelaDyn->getRelocOffset();
+        Out<ELFT>::Plt->addEntry(Body, RelOff);
----------------
ruiu wrote:
> This piece of code does not depends on any local context of Writer.cpp, so I think you can move this into a function that handles i386 PLT entries instead of propagating this unsigned value all the way to the consumer.
What I need is a accordance of PLT entry and the offset in relocation table for its relocation. **It can be calculated only here I think.**

That its only needed for x86 now, thats true. But what is the way to move it from here ? Function that handles i386 PLT entries is 

```
writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr, uint64_t PltEntryAddr, int32_t Index, unsigned RelOff).
```
It does not know anything about conformity of relocations and PLT entries.
I added RelOff for it since I dont know the easier/shorter way to do what is needed.


http://reviews.llvm.org/D14955





More information about the llvm-commits mailing list