summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-03-12 20:58:34 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-03-12 20:58:34 +0000
commit8a28673a2ebcf47f5217bb939e3aaff14b303b03 (patch)
tree2bae18fbbf3133150cc94864749e3afd295cfccd
parent1d6c47ad2bb2ed6aef76107fb345fbf4cb024cb4 (diff)
downloadbcm5719-llvm-8a28673a2ebcf47f5217bb939e3aaff14b303b03.tar.gz
bcm5719-llvm-8a28673a2ebcf47f5217bb939e3aaff14b303b03.zip
ELF: Don't add .dynamic strings to .dynstr early.
This does not appear to be necessary because StringTableSection does not need to be finalized, which also means that we can remove the call to finalizeSynthetic on .dynstr. Differential Revision: https://reviews.llvm.org/D59240 llvm-svn: 355977
-rw-r--r--lld/ELF/SyntheticSections.cpp36
-rw-r--r--lld/ELF/Writer.cpp1
-rw-r--r--lld/test/ELF/verneed.s6
3 files changed, 20 insertions, 23 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index a31ef9ad50e..5e60482c421 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1205,25 +1205,6 @@ DynamicSection<ELFT>::DynamicSection()
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
if (Config->EMachine == EM_MIPS || Config->ZRodynamic)
this->Flags = SHF_ALLOC;
-
- // Add strings to .dynstr early so that .dynstr's size will be
- // fixed early.
- for (StringRef S : Config->FilterList)
- addInt(DT_FILTER, In.DynStrTab->addString(S));
- for (StringRef S : Config->AuxiliaryList)
- addInt(DT_AUXILIARY, In.DynStrTab->addString(S));
-
- if (!Config->Rpath.empty())
- addInt(Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH,
- In.DynStrTab->addString(Config->Rpath));
-
- for (InputFile *File : SharedFiles) {
- SharedFile<ELFT> *F = cast<SharedFile<ELFT>>(File);
- if (F->IsNeeded)
- addInt(DT_NEEDED, In.DynStrTab->addString(F->SoName));
- }
- if (!Config->SoName.empty())
- addInt(DT_SONAME, In.DynStrTab->addString(Config->SoName));
}
template <class ELFT>
@@ -1277,6 +1258,23 @@ static uint64_t addPltRelSz() {
// Add remaining entries to complete .dynamic contents.
template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
+ for (StringRef S : Config->FilterList)
+ addInt(DT_FILTER, In.DynStrTab->addString(S));
+ for (StringRef S : Config->AuxiliaryList)
+ addInt(DT_AUXILIARY, In.DynStrTab->addString(S));
+
+ if (!Config->Rpath.empty())
+ addInt(Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH,
+ In.DynStrTab->addString(Config->Rpath));
+
+ for (InputFile *File : SharedFiles) {
+ SharedFile<ELFT> *F = cast<SharedFile<ELFT>>(File);
+ if (F->IsNeeded)
+ addInt(DT_NEEDED, In.DynStrTab->addString(F->SoName));
+ }
+ if (!Config->SoName.empty())
+ addInt(DT_SONAME, In.DynStrTab->addString(Config->SoName));
+
// Set DT_FLAGS and DT_FLAGS_1.
uint32_t DtFlags = 0;
uint32_t DtFlags1 = 0;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c8e6a837df8..d856bd11282 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1792,7 +1792,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
finalizeSynthetic(In.ShStrTab);
finalizeSynthetic(In.StrTab);
finalizeSynthetic(In.VerDef);
- finalizeSynthetic(In.DynStrTab);
finalizeSynthetic(In.Got);
finalizeSynthetic(In.MipsGot);
finalizeSynthetic(In.IgotPlt);
diff --git a/lld/test/ELF/verneed.s b/lld/test/ELF/verneed.s
index e8b65c40663..3ec255f7466 100644
--- a/lld/test/ELF/verneed.s
+++ b/lld/test/ELF/verneed.s
@@ -68,9 +68,9 @@
# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 00766572 6E656564 312E736F 2E300076 |.verneed1.so.0.v|
-# CHECK-NEXT: 0010: 65726E65 6564322E 736F2E30 00663100 |erneed2.so.0.f1.|
-# CHECK-NEXT: 0020: 76330066 32007632 00673100 763100 |v3.f2.v2.g1.v1.|
+# CHECK-NEXT: 0000: 00663100 7665726E 65656431 2E736F2E |.f1.verneed1.so.|
+# CHECK-NEXT: 0010: 30007633 00663200 76320067 31007665 |0.v3.f2.v2.g1.ve|
+# CHECK-NEXT: 0020: 726E6565 64322E73 6F2E3000 763100 |rneed2.so.0.v1.|
# CHECK-NEXT: )
# CHECK-NEXT: }
OpenPOWER on IntegriCloud