[lld] r248952 - ELF2: Add DT_REL{,A}ENT and DT_SYMENT.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 14:57:53 PDT 2015
Author: ruiu
Date: Wed Sep 30 16:57:53 2015
New Revision: 248952
URL: http://llvm.org/viewvc/llvm-project?rev=248952&view=rev
Log:
ELF2: Add DT_REL{,A}ENT and DT_SYMENT.
According to the ELF specification, these dynamic array entries are mandatory.
http://reviews.llvm.org/D13303
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/test/elf2/dynamic-reloc.s
lld/trunk/test/elf2/shared.s
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=248952&r1=248951&r2=248952&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Sep 30 16:57:53 2015
@@ -189,9 +189,11 @@ template <class ELFT> void DynamicSectio
unsigned NumEntries = 0;
if (RelaDynSec.hasRelocs()) {
++NumEntries; // DT_RELA / DT_REL
- ++NumEntries; // DT_RELASZ / DTRELSZ
+ ++NumEntries; // DT_RELASZ / DT_RELSZ
+ ++NumEntries; // DT_RELAENT / DT_RELENT
}
++NumEntries; // DT_SYMTAB
+ ++NumEntries; // DT_SYMENT
++NumEntries; // DT_STRTAB
++NumEntries; // DT_STRSZ
++NumEntries; // DT_HASH
@@ -227,12 +229,20 @@ template <class ELFT> void DynamicSectio
P->d_tag = IsRela ? DT_RELASZ : DT_RELSZ;
P->d_un.d_val = RelaDynSec.getSize();
++P;
+
+ P->d_tag = IsRela ? DT_RELAENT : DT_RELENT;
+ P->d_un.d_val = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
+ ++P;
}
P->d_tag = DT_SYMTAB;
P->d_un.d_ptr = DynSymSec.getVA();
++P;
+ P->d_tag = DT_SYMENT;
+ P->d_un.d_ptr = sizeof(Elf_Sym);
+ ++P;
+
P->d_tag = DT_STRTAB;
P->d_un.d_ptr = DynStrSec.getVA();
++P;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=248952&r1=248951&r2=248952&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Wed Sep 30 16:57:53 2015
@@ -313,6 +313,9 @@ template <class ELFT>
class DynamicSection final : public OutputSectionBase<ELFT::Is64Bits> {
typedef OutputSectionBase<ELFT::Is64Bits> Base;
typedef typename Base::HeaderT HeaderT;
+ typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel;
+ typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela;
+ typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym;
public:
DynamicSection(SymbolTable &SymTab, HashTableSection<ELFT> &HashSec,
Modified: lld/trunk/test/elf2/dynamic-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dynamic-reloc.s?rev=248952&r1=248951&r2=248952&view=diff
==============================================================================
--- lld/trunk/test/elf2/dynamic-reloc.s (original)
+++ lld/trunk/test/elf2/dynamic-reloc.s Wed Sep 30 16:57:53 2015
@@ -45,7 +45,9 @@
// CHECK-NEXT: Tag Type Name/Value
// CHECK-NEXT: 0x0000000000000007 RELA [[RELAADDR]]
// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELASIZE]] (bytes)
+// CHECK-NEXT: 0x0000000000000009 RELAENT 24 (bytes)
// CHECK-NEXT: 0x0000000000000006 SYMTAB
+// CHECK-NEXT: 0x000000000000000B SYMENT 24 (bytes)
// CHECK-NEXT: 0x0000000000000005 STRTAB
// CHECK-NEXT: 0x000000000000000A STRSZ
// CHECK-NEXT: 0x0000000000000004 HASH
Modified: lld/trunk/test/elf2/shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/shared.s?rev=248952&r1=248951&r2=248952&view=diff
==============================================================================
--- lld/trunk/test/elf2/shared.s (original)
+++ lld/trunk/test/elf2/shared.s Wed Sep 30 16:57:53 2015
@@ -117,7 +117,22 @@
// CHECK-NEXT: Address: [[RELADDR:.*]]
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: [[RELSIZE:.*]]
+// CHECK-NEXT: Link:
+// CHECK-NEXT: Info:
+// CHECK-NEXT: AddressAlignment:
+// CHECK-NEXT: EntrySize: [[RELENT:.*]]
+// CHECK: Name: .symtab
+// CHECK-NEXT: Type: SHT_SYMTAB
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size:
+// CHECK-NEXT: Link:
+// CHECK-NEXT: Info:
+// CHECK-NEXT: AddressAlignment:
+// CHECK-NEXT: EntrySize: [[SYMENT:.*]]
// CHECK: Symbols [
// CHECK-NEXT: Symbol {
@@ -231,7 +246,9 @@
// CHECK-NEXT: Tag Type Name/Value
// CHECK-NEXT: 0x00000011 REL [[RELADDR]]
// CHECK-NEXT: 0x00000012 RELSZ [[RELSIZE]] (bytes)
+// CHECK-NEXT: 0x00000013 RELENT [[RELENT]] (bytes)
// CHECK-NEXT: 0x00000006 SYMTAB [[DYNSYMADDR]]
+// CHECK-NEXT: 0x0000000B SYMENT [[SYMENT]] (bytes)
// CHECK-NEXT: 0x00000005 STRTAB [[DYNSTRADDR]]
// CHECK-NEXT: 0x0000000A STRSZ
// CHECK-NEXT: 0x00000004 HASH [[HASHADDR]]
More information about the llvm-commits
mailing list