summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2016-02-02 09:07:47 +0000
committerSimon Atanasyan <simon@atanasyan.com>2016-02-02 09:07:47 +0000
commit40d25f33589a9db7a10f3390d7a792d559bd9f53 (patch)
tree319755f9bbce3db9b6abe42203374d9fd6eeff63
parent542625eb6e4fe3de1bcb4413af9b65cf81d469d1 (diff)
downloadbcm5719-llvm-40d25f33589a9db7a10f3390d7a792d559bd9f53.tar.gz
bcm5719-llvm-40d25f33589a9db7a10f3390d7a792d559bd9f53.zip
[ELF] Finalize .dynamic section at the end
Some dynamic table tags like RELSZ and PLTRELSZ depens on result of finalizing corresponding relocation sections. Therefore we have to finalize .dynamic section at the end. Differential Revision: http://reviews.llvm.org/D16799 llvm-svn: 259478
-rw-r--r--lld/ELF/Writer.cpp12
-rw-r--r--lld/test/ELF/mips-relocs.s9
2 files changed, 16 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 5ab32f61c5c..f9d030371da 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -967,11 +967,17 @@ template <class ELFT> bool Writer<ELFT>::createSections() {
if (isOutputDynamic())
Out<ELFT>::DynSymTab->finalize();
- // Fill other section headers. The dynamic string table in finalized
- // once the .dynamic finalizer has added a few last strings.
+ // Fill other section headers. The dynamic table is finalized
+ // at the end because some tags like RELSZ depend on result
+ // of finalizing other sections. The dynamic string table is
+ // finalized once the .dynamic finalizer has added a few last
+ // strings. See DynamicSection::finalize()
for (OutputSectionBase<ELFT> *Sec : OutputSections)
- if (Sec != Out<ELFT>::DynStrTab)
+ if (Sec != Out<ELFT>::DynStrTab && Sec != Out<ELFT>::Dynamic)
Sec->finalize();
+
+ if (isOutputDynamic())
+ Out<ELFT>::Dynamic->finalize();
return true;
}
diff --git a/lld/test/ELF/mips-relocs.s b/lld/test/ELF/mips-relocs.s
index b05647af5b3..987a6a43699 100644
--- a/lld/test/ELF/mips-relocs.s
+++ b/lld/test/ELF/mips-relocs.s
@@ -4,13 +4,13 @@
# RUN: ld.lld -shared %t-be.o -o %t-be.so
# RUN: llvm-objdump -t %t-be.so | FileCheck %s
# RUN: llvm-objdump -s %t-be.so | FileCheck -check-prefix=BE %s
-# RUN: llvm-readobj -relocations %t-be.so | FileCheck -check-prefix=REL %s
+# RUN: llvm-readobj -r -dynamic-table %t-be.so | FileCheck -check-prefix=REL %s
# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
# RUN: ld.lld -shared %t-el.o -o %t-el.so
# RUN: llvm-objdump -t %t-el.so | FileCheck %s
# RUN: llvm-objdump -s %t-el.so | FileCheck -check-prefix=EL %s
-# RUN: llvm-readobj -relocations %t-el.so | FileCheck -check-prefix=REL %s
+# RUN: llvm-readobj -r -dynamic-table %t-el.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips
@@ -49,3 +49,8 @@ v2:
# REL-NEXT: 0x30008 R_MIPS_REL32 - 0x0
# REL-NEXT: }
# REL-NEXT: ]
+
+# REL: DynamicSection [
+# REL: Tag Type Name/Value
+# REL: 0x00000012 RELSZ 16 (bytes)
+# REL: 0x00000013 RELENT 8 (bytes)
OpenPOWER on IntegriCloud