summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorPeter Smith <peter.smith@linaro.org>2016-10-10 10:10:27 +0000
committerPeter Smith <peter.smith@linaro.org>2016-10-10 10:10:27 +0000
commit0760605ac5c482f917de5eb11560a86672ec995d (patch)
treec0af9adac532304ebbe2fa03f9c36bec952103bd /lld/ELF/InputFiles.cpp
parent50188b2771c7ef81c4d439ac6133d51bdfa775a0 (diff)
downloadbcm5719-llvm-0760605ac5c482f917de5eb11560a86672ec995d.tar.gz
bcm5719-llvm-0760605ac5c482f917de5eb11560a86672ec995d.zip
[ELF][ARM] Garbage collection support for .ARM.exidx sections
.ARM.exidx sections have a reverse dependency on the section they have a SHF_LINK_ORDER dependency on. In other words a .ARM.exidx section is live only if the executable section it describes is live. We implement this with a reverse dependency field in InputSection. Adding the dependency to InputSection is the simplest implementation but it could be moved out to a separate map if it were found to decrease performance for non ARM targets. Differential revision: https://reviews.llvm.org/D25234 llvm-svn: 283734
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index d9630790e2c..aa6a53cdbd4 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -145,6 +145,8 @@ void elf::ObjectFile<ELFT>::parse(DenseSet<StringRef> &ComdatGroups) {
// Read section and symbol tables.
initializeSections(ComdatGroups);
initializeSymbols();
+ if (Config->GcSections && Config->EMachine == EM_ARM )
+ initializeReverseDependencies();
}
// Sections with SHT_GROUP and comdat bits define comdat section groups.
@@ -270,6 +272,24 @@ void elf::ObjectFile<ELFT>::initializeSections(
}
}
+// .ARM.exidx sections have a reverse dependency on the InputSection they
+// have a SHF_LINK_ORDER dependency, this is identified by the sh_link.
+template <class ELFT>
+void elf::ObjectFile<ELFT>::initializeReverseDependencies() {
+ unsigned I = -1;
+ for (const Elf_Shdr &Sec : this->ELFObj.sections()) {
+ ++I;
+ if ((Sections[I] == &InputSection<ELFT>::Discarded) ||
+ !(Sec.sh_flags & SHF_LINK_ORDER))
+ continue;
+ if (Sec.sh_link >= Sections.size())
+ fatal(getFilename(this) + ": invalid sh_link index: " +
+ Twine(Sec.sh_link));
+ auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
+ IS->DependentSection = Sections[I];
+ }
+}
+
template <class ELFT>
InputSectionBase<ELFT> *
elf::ObjectFile<ELFT>::getRelocTarget(const Elf_Shdr &Sec) {
OpenPOWER on IntegriCloud