Add a helper for getting the output offset of an input offset.
This will get a non st_value use shortly.
llvm-svn: 252753
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index ec66fc9..d84c2b3 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -43,10 +43,19 @@
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.