[lld] r247838 - Move code computing NumEntries to finalize.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 12:26:31 PDT 2015
Author: rafael
Date: Wed Sep 16 14:26:31 2015
New Revision: 247838
URL: http://llvm.org/viewvc/llvm-project?rev=247838&view=rev
Log:
Move code computing NumEntries to finalize.
When DynamicSection is constructed we still don't know if there will be
any dynamic relocations or not.
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/elf2/dynamic-reloc.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=247838&r1=247837&r2=247838&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Sep 16 14:26:31 2015
@@ -336,9 +336,13 @@ public:
typename Base::HeaderT &Header = this->Header;
Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
Header.sh_entsize = ELFT::Is64Bits ? 16 : 8;
+ }
- unsigned NumEntries = 0;
+ void finalize() override {
+ typename Base::HeaderT &Header = this->Header;
+ Header.sh_link = DynStrSec.getSectionIndex();
+ unsigned NumEntries = 0;
if (RelaDynSec.hasReocs()) {
++NumEntries; // DT_RELA
++NumEntries; // DT_RELASZ
@@ -365,10 +369,6 @@ public:
Header.sh_size = NumEntries * Header.sh_entsize;
}
- void finalize() override {
- this->Header.sh_link = DynStrSec.getSectionIndex();
- }
-
void writeTo(uint8_t *Buf) override {
auto *P = reinterpret_cast<Elf_Dyn *>(Buf);
Modified: lld/trunk/test/elf2/dynamic-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dynamic-reloc.s?rev=247838&r1=247837&r2=247838&view=diff
==============================================================================
--- lld/trunk/test/elf2/dynamic-reloc.s (original)
+++ lld/trunk/test/elf2/dynamic-reloc.s Wed Sep 16 14:26:31 2015
@@ -44,6 +44,14 @@
// CHECK-NEXT: Tag Type Name/Value
// CHECK-NEXT: 0x0000000000000007 RELA [[RELAADDR]]
// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELASIZE]] (bytes)
+// CHECK-NEXT: 0x0000000000000006 SYMTAB 0x12000
+// CHECK-NEXT: 0x0000000000000005 STRTAB 0x15000
+// CHECK-NEXT: 0x000000000000000A STRSZ 90 (bytes)
+// CHECK-NEXT: 0x0000000000000004 HASH 0x13000
+// CHECK-NEXT: 0x0000000000000001 NEEDED SharedLibrary ({{.*}}2.so)
+// CHECK-NEXT: 0x0000000000000000 NULL 0x0
+// CHECK-NEXT: ]
+
.global _start
_start:
More information about the llvm-commits
mailing list