summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-11-11 16:50:37 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-11-11 16:50:37 +0000
commitdb9bf4dbfe5472876db327a9dfe3b9fbe39ffdb8 (patch)
treeb490e222f5ebdb36ef04491118f36b07ed0f543e /lld/ELF/InputSection.cpp
parent70dd2d7ab9ce89be79675a2a238059c56ff055d6 (diff)
downloadbcm5719-llvm-db9bf4dbfe5472876db327a9dfe3b9fbe39ffdb8.tar.gz
bcm5719-llvm-db9bf4dbfe5472876db327a9dfe3b9fbe39ffdb8.zip
Add a helper for getting the output offset of an input offset.
This will get a non st_value use shortly. llvm-svn: 252753
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp15
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.
OpenPOWER on IntegriCloud