[PATCH] Subclass DynamicTable for each targets to factor out handling of target dependent part of a dynamic table
Simon Atanasyan
simon at atanasyan.com
Thu Jan 30 06:32:47 PST 2014
Here is another solution for the problem. The patch is small as possible and solves the only problem - allows to override the dynamic table tag used for .got.plt section referencing.
Hi shankarke, ruiu,
http://llvm-reviews.chandlerc.com/D2643
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2643?vs=6724&id=6772#toc
Files:
lib/ReaderWriter/ELF/Mips/MipsDynamicTable.h
lib/ReaderWriter/ELF/SectionChunks.h
test/elf/Mips/exe-dynamic.test
Index: lib/ReaderWriter/ELF/Mips/MipsDynamicTable.h
===================================================================
--- lib/ReaderWriter/ELF/Mips/MipsDynamicTable.h
+++ lib/ReaderWriter/ELF/Mips/MipsDynamicTable.h
@@ -89,6 +89,8 @@
_mipsTargetLayout.findOutputSection(".got")->virtualAddr();
}
+ virtual int64_t getGotPltTag() { return DT_MIPS_PLTGOT; }
+
private:
std::size_t _dt_symtabno;
std::size_t _dt_localgot;
Index: lib/ReaderWriter/ELF/SectionChunks.h
===================================================================
--- lib/ReaderWriter/ELF/SectionChunks.h
+++ lib/ReaderWriter/ELF/SectionChunks.h
@@ -1080,7 +1080,7 @@
if (_layout.hasPLTRelocationTable()) {
dyn.d_tag = DT_PLTRELSZ;
_dt_pltrelsz = addEntry(dyn);
- dyn.d_tag = DT_PLTGOT;
+ dyn.d_tag = getGotPltTag();
_dt_pltgot = addEntry(dyn);
dyn.d_tag = DT_PLTREL;
dyn.d_un.d_val = isRela ? DT_RELA : DT_REL;
@@ -1091,6 +1091,10 @@
}
}
+ /// \brief Dynamic table tag for .got.plt section referencing.
+ /// Usually but not always targets use DT_PLTGOT for that.
+ virtual int64_t getGotPltTag() { return DT_PLTGOT; }
+
virtual void finalize() {
StringTable<ELFT> *dynamicStringTable =
_dynamicSymbolTable->getStringTable();
Index: test/elf/Mips/exe-dynamic.test
===================================================================
--- test/elf/Mips/exe-dynamic.test
+++ test/elf/Mips/exe-dynamic.test
@@ -24,15 +24,16 @@
# CHECK: 0x0000001A FINI_ARRAY 0x0
# CHECK: 0x0000001C FINI_ARRAYSZ 0 (bytes)
# CHECK: 0x00000002 PLTRELSZ 8 (bytes)
-# CHECK: 0x00000003 PLTGOT 0x402000
+# CHECK: 0x70000032 MIPS_PLTGOT 0x402000
# CHECK: 0x00000014 PLTREL REL
# CHECK: 0x00000017 JMPREL 0x400162
# CHECK: 0x70000001 MIPS_RLD_VERSION 1
# CHECK: 0x70000005 MIPS_FLAGS 0x2
# CHECK: 0x70000006 MIPS_BASE_ADDRESS 0x400000
# CHECK: 0x7000000A MIPS_LOCAL_GOTNO 2
# CHECK: 0x70000011 MIPS_SYMTABNO 2
# CHECK: 0x70000013 MIPS_GOTSYM 0x2
+# CHECK: 0x00000003 PLTGOT 0x401000
# CHECK: 0x00000001 NEEDED SharedLibrary (exe-dynamic.test.{{.*}})
# CHECK: 0x00000000 NULL 0x0
# CHECK: ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2643.2.patch
Type: text/x-patch
Size: 2341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140130/d0804063/attachment.bin>
More information about the llvm-commits
mailing list