diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 9109ced45e8d62599e62d88f8181833a8f8b4f38..7b1342eca5331822bd52e5d5c9a5ffbb3ba68097 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -925,12 +925,6 @@ void MergeInputSection::splitIntoPieces() { getSectionPiece(Off)->Live = true; } -// Do binary search to get a section piece at a given input offset. -SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) { - auto *This = static_cast(this); - return const_cast(This->getSectionPiece(Offset)); -} - template static It fastUpperBound(It First, It Last, const T &Value, Compare Comp) { size_t Size = std::distance(First, Last); @@ -944,7 +938,8 @@ static It fastUpperBound(It First, It Last, const T &Value, Compare Comp) { return Comp(Value, *First) ? First : First + 1; } -const SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) const { +// Do binary search to get a section piece at a given input offset. +SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) { if (Data.size() <= Offset) fatal(toString(this) + ": entry is past the end of the section"); diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index ab6158018092e519be7f37fd719c79b84c399606..714439b2dbf5749af61a22e0ca1685654642f279 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -251,7 +251,9 @@ public: // Returns the SectionPiece at a given input section offset. SectionPiece *getSectionPiece(uint64_t Offset); - const SectionPiece *getSectionPiece(uint64_t Offset) const; + const SectionPiece *getSectionPiece(uint64_t Offset) const { + return const_cast(this)->getSectionPiece(Offset); + } SyntheticSection *getParent() const;