From dc1ed12015addaf5a81013935b34cc8b81756b17 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 10 May 2017 14:12:02 +0000 Subject: [PATCH] Remove another use of section names. NFC. llvm-svn: 302662 --- lld/ELF/LinkerScript.cpp | 4 ++-- lld/ELF/LinkerScript.h | 2 +- lld/ELF/Writer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 78531dbc93e6..e0e8069bfea5 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1057,10 +1057,10 @@ void LinkerScript::writeDataBytes(OutputSection *Sec, uint8_t *Buf) { writeInt(Buf + Data->Offset, Data->Expression().getValue(), Data->Size); } -bool LinkerScript::hasLMA(StringRef Name) { +bool LinkerScript::hasLMA(OutputSection *Sec) { for (BaseCommand *Base : Opt.Commands) if (auto *Cmd = dyn_cast(Base)) - if (Cmd->LMAExpr && Cmd->Name == Name) + if (Cmd->LMAExpr && Cmd->Sec == Sec) return true; return false; } diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 5a464cef8492..75783fc748c5 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -263,7 +263,7 @@ public: bool ignoreInterpSection(); llvm::Optional getFiller(OutputSection *Sec); - bool hasLMA(StringRef Name); + bool hasLMA(OutputSection *Sec); bool shouldKeep(InputSectionBase *S); void assignOffsets(OutputSectionCommand *Cmd); void placeOrphanSections(); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6c06fed1fa0c..5d810a79c522 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1335,7 +1335,7 @@ template std::vector Writer::createPhdrs() { // different flags or is loaded at a discontiguous address using AT linker // script command. uint64_t NewFlags = computeFlags(Sec->getPhdrFlags()); - if (Script->hasLMA(Sec->Name) || Flags != NewFlags) { + if (Script->hasLMA(Sec) || Flags != NewFlags) { Load = AddHdr(PT_LOAD, NewFlags); Flags = NewFlags; } @@ -1398,7 +1398,7 @@ template std::vector Writer::createPhdrs() { PhdrEntry *Note = nullptr; for (OutputSection *Sec : OutputSections) { if (Sec->Type == SHT_NOTE) { - if (!Note || Script->hasLMA(Sec->Name)) + if (!Note || Script->hasLMA(Sec)) Note = AddHdr(PT_NOTE, PF_R); Note->add(Sec); } else { -- 2.34.1