diff options
Diffstat (limited to 'lld/ELF/InputSection.cpp')
| -rw-r--r-- | lld/ELF/InputSection.cpp | 15 |
1 files changed, 12 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. |

