diff options
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 27 | ||||
-rw-r--r-- | lld/ELF/LinkerScript.h | 3 |
2 files changed, 14 insertions, 16 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index bbe0e45816c..67dda41a6d6 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -91,6 +91,19 @@ OutputSection *LinkerScriptBase::getOutputSection(const Twine &Loc, return &FakeSec; } +// This function is essentially the same as getOutputSection(Name)->Size, +// but it won't print out an error message if a given section is not found. +// +// Linker script does not create an output section if its content is empty. +// We want to allow SIZEOF(.foo) where .foo is a section which happened to +// be empty. That is why this function is different from getOutputSection(). +uint64_t LinkerScriptBase::getOutputSectionSize(StringRef Name) { + for (OutputSection *Sec : *OutputSections) + if (Sec->Name == Name) + return Sec->Size; + return 0; +} + template <class ELFT> void LinkerScript<ELFT>::setDot(Expr E, const Twine &Loc, bool InSec) { uint64_t Val = E(); @@ -914,20 +927,6 @@ template <class ELFT> int LinkerScript<ELFT>::getSectionIndex(StringRef Name) { return INT_MAX; } -// This function is essentially the same as getOutputSection(Name)->Size, -// but it won't print out an error message if a given section is not found. -// -// Linker script does not create an output section if its content is empty. -// We want to allow SIZEOF(.foo) where .foo is a section which happened to -// be empty. That is why this function is different from getOutputSection(). -template <class ELFT> -uint64_t LinkerScript<ELFT>::getOutputSectionSize(StringRef Name) { - for (OutputSection *Sec : *OutputSections) - if (Sec->Name == Name) - return Sec->Size; - return 0; -} - template <class ELFT> uint64_t LinkerScript<ELFT>::getSymbolValue(const Twine &Loc, StringRef S) { if (S == ".") diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 51f8a06554f..fa8b4ce4ebd 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -241,12 +241,12 @@ public: bool hasPhdrsCommands() { return !Opt.PhdrsCommands.empty(); } uint64_t getDot() { return Dot; } OutputSection *getOutputSection(const Twine &Loc, StringRef S); + uint64_t getOutputSectionSize(StringRef S); virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0; virtual bool isDefined(StringRef S) = 0; virtual bool isAbsolute(StringRef S) = 0; virtual OutputSection *getSymbolSection(StringRef S) = 0; - virtual uint64_t getOutputSectionSize(StringRef S) = 0; std::vector<OutputSection *> *OutputSections; }; @@ -277,7 +277,6 @@ public: bool isDefined(StringRef S) override; bool isAbsolute(StringRef S) override; OutputSection *getSymbolSection(StringRef S) override; - uint64_t getOutputSectionSize(StringRef S) override; int getSectionIndex(StringRef Name); |