summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-05-26 17:48:27 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-05-26 17:48:27 +0000
commit43e76cd489250329cddb1fd575cf9fc9c17ea334 (patch)
treec6df977c38f0f88595e9569c7b74f7cb9c9d5e27
parenta40b38a637d305b4f406312ca11f8a861591aef9 (diff)
downloadbcm5719-llvm-43e76cd489250329cddb1fd575cf9fc9c17ea334.tar.gz
bcm5719-llvm-43e76cd489250329cddb1fd575cf9fc9c17ea334.zip
Avoid a couple uses of OutputSections.
After fabricateDefaultCommands we can look at the script commands. llvm-svn: 304014
-rw-r--r--lld/ELF/Writer.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7e0b0f1d3c7..e539d8ffce6 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -81,7 +81,8 @@ private:
void addStartStopSymbols(OutputSection *Sec);
uint64_t getEntryAddr();
OutputSection *findSection(StringRef Name);
- OutputSectionCommand *findSectionInScript(StringRef Name);
+ OutputSection *findSectionInScript(StringRef Name);
+ OutputSectionCommand *findSectionCommand(StringRef Name);
std::vector<PhdrEntry> Phdrs;
@@ -1313,7 +1314,7 @@ void Writer<ELFT>::addStartStopSymbols(OutputSection *Sec) {
}
template <class ELFT>
-OutputSectionCommand *Writer<ELFT>::findSectionInScript(StringRef Name) {
+OutputSectionCommand *Writer<ELFT>::findSectionCommand(StringRef Name) {
for (BaseCommand *Base : Script->Opt.Commands)
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
if (Cmd->Name == Name)
@@ -1321,6 +1322,12 @@ OutputSectionCommand *Writer<ELFT>::findSectionInScript(StringRef Name) {
return nullptr;
}
+template <class ELFT> OutputSection *Writer<ELFT>::findSectionInScript(StringRef Name) {
+ if (OutputSectionCommand *Cmd = findSectionCommand(Name))
+ return Cmd->Sec;
+ return nullptr;
+}
+
template <class ELFT> OutputSection *Writer<ELFT>::findSection(StringRef Name) {
for (OutputSection *Sec : OutputSections)
if (Sec->Name == Name)
@@ -1607,7 +1614,7 @@ template <class ELFT> uint64_t Writer<ELFT>::getEntryAddr() {
return Addr;
// Case 4
- if (OutputSection *Sec = findSection(".text")) {
+ if (OutputSection *Sec = findSectionInScript(".text")) {
if (Config->WarnMissingEntry)
warn("cannot find entry symbol " + Config->Entry + "; defaulting to 0x" +
utohexstr(Sec->Addr));
@@ -1670,7 +1677,7 @@ template <class ELFT> void Writer<ELFT>::fixPredefinedSymbols() {
}
if (ElfSym::Bss)
- ElfSym::Bss->Section = findSection(".bss");
+ ElfSym::Bss->Section = findSectionInScript(".bss");
// Setup MIPS _gp_disp/__gnu_local_gp symbols which should
// be equal to the _gp symbol's value.
@@ -1778,7 +1785,7 @@ template <class ELFT> void Writer<ELFT>::writeSections() {
// PPC64 needs to process relocations in the .opd section
// before processing relocations in code-containing sections.
- if (auto *OpdCmd = findSectionInScript(".opd")) {
+ if (auto *OpdCmd = findSectionCommand(".opd")) {
Out::Opd = OpdCmd->Sec;
Out::OpdBuf = Buf + Out::Opd->Offset;
OpdCmd->template writeTo<ELFT>(Buf + Out::Opd->Offset);
OpenPOWER on IntegriCloud