summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-09-15 15:44:00 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-09-15 15:44:00 +0000
commit3580ef112091599b555cf70fa758a953f3e89774 (patch)
tree99048455c0db56ead7c048295cd276e5ed417537
parent16807db3d46ce311ca75cc3b383f5aea28c83b79 (diff)
downloadbcm5719-llvm-3580ef112091599b555cf70fa758a953f3e89774.tar.gz
bcm5719-llvm-3580ef112091599b555cf70fa758a953f3e89774.zip
[ELF] - Remove one of OutputSectionFactory::addInputSec().
Patch removes one of OutputSectionFactory::addInputSec methods. That allows to simplify reporting of discarded sections and should help to D37561. Differential revision: https://reviews.llvm.org/D37735 llvm-svn: 313361
-rw-r--r--lld/ELF/OutputSections.cpp86
-rw-r--r--lld/ELF/OutputSections.h3
2 files changed, 47 insertions, 42 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 0e5aa32d338..e8b78815966 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -205,46 +205,8 @@ void elf::reportDiscarded(InputSectionBase *IS) {
IS->File->getName() + "'");
}
-void OutputSectionFactory::addInputSec(InputSectionBase *IS,
- StringRef OutsecName) {
- // Sections with the SHT_GROUP attribute reach here only when the - r option
- // is given. Such sections define "section groups", and InputFiles.cpp has
- // dedup'ed section groups by their signatures. For the -r, we want to pass
- // through all SHT_GROUP sections without merging them because merging them
- // creates broken section contents.
- if (IS->Type == SHT_GROUP) {
- OutputSection *Out = nullptr;
- addInputSec(IS, OutsecName, Out);
- return;
- }
-
- // Imagine .zed : { *(.foo) *(.bar) } script. Both foo and bar may have
- // relocation sections .rela.foo and .rela.bar for example. Most tools do
- // not allow multiple REL[A] sections for output section. Hence we
- // should combine these relocation sections into single output.
- // We skip synthetic sections because it can be .rela.dyn/.rela.plt or any
- // other REL[A] sections created by linker itself.
- if (!isa<SyntheticSection>(IS) &&
- (IS->Type == SHT_REL || IS->Type == SHT_RELA)) {
- auto *Sec = cast<InputSection>(IS);
- OutputSection *Out = Sec->getRelocatedSection()->getOutputSection();
- addInputSec(IS, OutsecName, Out->RelocationSection);
- return;
- }
-
- SectionKey Key = createKey(IS, OutsecName);
- OutputSection *&Sec = Map[Key];
- addInputSec(IS, OutsecName, Sec);
-}
-
-void OutputSectionFactory::addInputSec(InputSectionBase *IS,
- StringRef OutsecName,
- OutputSection *&Sec) {
- if (!IS->Live) {
- reportDiscarded(IS);
- return;
- }
-
+static OutputSection *addSection(InputSectionBase *IS, StringRef OutsecName,
+ OutputSection *Sec) {
if (Sec && Sec->Live) {
if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
error("incompatible section flags for " + Sec->Name + "\n>>> " +
@@ -272,6 +234,50 @@ void OutputSectionFactory::addInputSec(InputSectionBase *IS,
}
Sec->addSection(cast<InputSection>(IS));
+ return Sec;
+}
+
+void OutputSectionFactory::addInputSec(InputSectionBase *IS,
+ StringRef OutsecName,
+ OutputSection *OS) {
+ if (!IS->Live) {
+ reportDiscarded(IS);
+ return;
+ }
+
+ // If we have destination output section - use it directly.
+ if (OS) {
+ addSection(IS, OutsecName, OS);
+ return;
+ }
+
+ // Sections with the SHT_GROUP attribute reach here only when the - r option
+ // is given. Such sections define "section groups", and InputFiles.cpp has
+ // dedup'ed section groups by their signatures. For the -r, we want to pass
+ // through all SHT_GROUP sections without merging them because merging them
+ // creates broken section contents.
+ if (IS->Type == SHT_GROUP) {
+ addSection(IS, OutsecName, nullptr);
+ return;
+ }
+
+ // Imagine .zed : { *(.foo) *(.bar) } script. Both foo and bar may have
+ // relocation sections .rela.foo and .rela.bar for example. Most tools do
+ // not allow multiple REL[A] sections for output section. Hence we
+ // should combine these relocation sections into single output.
+ // We skip synthetic sections because it can be .rela.dyn/.rela.plt or any
+ // other REL[A] sections created by linker itself.
+ if (!isa<SyntheticSection>(IS) &&
+ (IS->Type == SHT_REL || IS->Type == SHT_RELA)) {
+ auto *Sec = cast<InputSection>(IS);
+ OutputSection *Out = Sec->getRelocatedSection()->getOutputSection();
+ Out->RelocationSection = addSection(IS, OutsecName, Out->RelocationSection);
+ return;
+ }
+
+ SectionKey Key = createKey(IS, OutsecName);
+ OutputSection *&Sec = Map[Key];
+ Sec = addSection(IS, OutsecName, Sec);
}
OutputSectionFactory::~OutputSectionFactory() {}
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 1fe793be0c8..bf970db7cd0 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -161,9 +161,8 @@ public:
OutputSectionFactory();
~OutputSectionFactory();
- void addInputSec(InputSectionBase *IS, StringRef OutsecName);
void addInputSec(InputSectionBase *IS, StringRef OutsecName,
- OutputSection *&Sec);
+ OutputSection *OS = nullptr);
private:
llvm::SmallDenseMap<SectionKey, OutputSection *> Map;
OpenPOWER on IntegriCloud