summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputSection.cpp15
-rw-r--r--lld/ELF/InputSection.h5
2 files changed, 17 insertions, 3 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index ec66fc94853..d84c2b3325a 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -43,10 +43,19 @@ ArrayRef<uint8_t> InputSectionBase<ELFT>::getSectionData() const {
template <class ELFT>
typename ELFFile<ELFT>::uintX_t
+InputSectionBase<ELFT>::getOffset(uintX_t Offset) {
+ switch (SectionKind) {
+ case Regular:
+ return cast<InputSection<ELFT>>(this)->OutSecOff + Offset;
+ case Merge:
+ return cast<MergeInputSection<ELFT>>(this)->getOffset(Offset);
+ }
+}
+
+template <class ELFT>
+typename ELFFile<ELFT>::uintX_t
InputSectionBase<ELFT>::getOffset(const Elf_Sym &Sym) {
- if (auto *S = dyn_cast<InputSection<ELFT>>(this))
- return S->OutSecOff + Sym.st_value;
- return cast<MergeInputSection<ELFT>>(this)->getOffset(Sym.st_value);
+ return getOffset(Sym.st_value);
}
// Returns a section that Rel relocation is pointing to.
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 33584745989..fe3c8e054bd 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -64,6 +64,11 @@ public:
}
uintX_t getOffset(const Elf_Sym &Sym);
+
+ // Translate an offset in the input section to an offset in the output
+ // section.
+ uintX_t getOffset(uintX_t Offset);
+
ArrayRef<uint8_t> getSectionData() const;
// Returns a section that Rel is pointing to. Used by the garbage collector.
OpenPOWER on IntegriCloud