[PATCH] [lld][ELF][Writer] Add dynamic relocation tables.
Michael Spencer
bigcheesegs at gmail.com
Tue Feb 26 12:53:07 PST 2013
================
Comment at: lib/ReaderWriter/ELF/SectionChunks.h:771-783
@@ +770,15 @@
+
+ bool getRelocationIndex(const Reference &r, uint32_t &res) {
+ auto rel = std::find_if(
+ _relocs.begin(), _relocs.end(),
+ [&](const std::pair<const DefinedAtom *, const Reference *> &p) {
+ if (p.second == &r)
+ return true;
+ return false;
+ });
+ if (rel == _relocs.end())
+ return false;
+ res = std::distance(_relocs.begin(), rel);
+ return true;
+ }
+
----------------
Shankar Kalpathi Easwaran wrote:
> How is this function used, I dont see a call to this.
It will be used by the next patch. For x86-64 PLT entries you have to write the index of the GOT JUMP_SLOT relocation into the PLT.
================
Comment at: lib/ReaderWriter/ELF/SectionChunks.h:798-799
@@ -761,3 +797,4 @@
Elf_Rela *r = reinterpret_cast<Elf_Rela *>(dest);
- r->setSymbolAndType(0, rel.second->kind());
+ r->setSymbolAndType(_symbolTable->getSymbolTableIndex(
+ rel.second->target()), rel.second->kind());
r->r_offset =
----------------
Shankar Kalpathi Easwaran wrote:
> Do you need to check if the dynamic symbol table exists, not sure, if there is a case where the dynamic symbol table may not exist(You already check in finalize to check if the symbol table exists, same logic may apply here).
Yep, I ran into and fixed this while working on the next patch.
http://llvm-reviews.chandlerc.com/D461
More information about the llvm-commits
mailing list