[lld] 85e50c1 - [ELF] Inline InputSection::getOffset into callers and remove it. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 28 16:09:10 PST 2021
Author: Fangrui Song
Date: 2021-11-28T16:09:04-08:00
New Revision: 85e50c10807f8d3ddd4d092afc23e75b818d0462
URL: https://github.com/llvm/llvm-project/commit/85e50c10807f8d3ddd4d092afc23e75b818d0462
DIFF: https://github.com/llvm/llvm-project/commit/85e50c10807f8d3ddd4d092afc23e75b818d0462.diff
LOG: [ELF] Inline InputSection::getOffset into callers and remove it. NFC
This is an unneeded abstraction which may cause confusion:
SectionBase::getOffset has the same name but hard codes -1 as the size of OutputSection.
Added:
Modified:
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
lld/ELF/MapFile.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 74d4dd309c79..4d5bd1f1e5f2 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -187,7 +187,7 @@ uint64_t SectionBase::getOffset(uint64_t offset) const {
}
case Regular:
case Synthetic:
- return cast<InputSection>(this)->getOffset(offset);
+ return cast<InputSection>(this)->outSecOff + offset;
case EHFrame:
// The file crtbeginT.o has relocations pointing to the start of an empty
// .eh_frame that is known to be the first in the link. It does that to
@@ -196,7 +196,7 @@ uint64_t SectionBase::getOffset(uint64_t offset) const {
case Merge:
const MergeInputSection *ms = cast<MergeInputSection>(this);
if (InputSection *isec = ms->getParent())
- return isec->getOffset(ms->getParentOffset(offset));
+ return isec->outSecOff + ms->getParentOffset(offset);
return ms->getParentOffset(offset);
}
llvm_unreachable("invalid section kind");
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 4bd1f410e388..afbb657806ce 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -352,8 +352,6 @@ class InputSection : public InputSectionBase {
// beginning of the output section.
template <class ELFT> void writeTo(uint8_t *buf);
- uint64_t getOffset(uint64_t offset) const { return outSecOff + offset; }
-
OutputSection *getParent() const;
// This variable has two usages. Initially, it represents an index in the
diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp
index 325c3b322663..7b8db004de95 100644
--- a/lld/ELF/MapFile.cpp
+++ b/lld/ELF/MapFile.cpp
@@ -187,7 +187,7 @@ void elf::writeMapFile() {
continue;
}
- writeHeader(os, isec->getVA(0), osec->getLMA() + isec->getOffset(0),
+ writeHeader(os, isec->getVA(), osec->getLMA() + isec->outSecOff,
isec->getSize(), isec->alignment);
os << indent8 << toString(isec) << '\n';
for (Symbol *sym : sectionSyms[isec])
More information about the llvm-commits
mailing list