summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputFiles.cpp2
-rw-r--r--lld/ELF/InputSection.cpp7
-rw-r--r--lld/ELF/InputSection.h3
-rw-r--r--lld/ELF/SyntheticSections.cpp7
4 files changed, 13 insertions, 6 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 30ebe925dbe..60182e5d119 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -107,7 +107,7 @@ std::string elf::ObjectFile<ELFT>::getLineInfo(InputSectionBase *S,
// section. See comments for ObjectInfo class.
DILineInfo Info;
Tbl->getFileLineInfoForAddress(
- S->Offset + Offset, nullptr,
+ S->getOffset() + Offset, nullptr,
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Info);
if (Info.Line == 0)
return "";
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 027ade90310..60b421c0c6a 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -84,7 +84,6 @@ InputSectionBase::InputSectionBase(elf::ObjectFile<ELFT> *File,
Hdr->sh_entsize, Hdr->sh_link, Hdr->sh_info,
Hdr->sh_addralign, getSectionContents(File, Hdr), Name,
SectionKind) {
- this->Offset = Hdr->sh_offset;
}
template <class ELFT> size_t InputSectionBase::getSize() const {
@@ -94,6 +93,12 @@ template <class ELFT> size_t InputSectionBase::getSize() const {
return Data.size();
}
+uint64_t InputSectionBase::getOffset() const {
+ const uint8_t *FileStart = (const uint8_t *)File->MB.getBufferStart();
+ const uint8_t *SecStart = Data.begin();
+ return SecStart - FileStart;
+}
+
template <class ELFT>
uint64_t InputSectionBase::getOffset(uint64_t Offset) const {
typedef typename ELFT::uint uintX_t;
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index a9ef978e526..78bd576c290 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -58,12 +58,13 @@ public:
// These corresponds to the fields in Elf_Shdr.
uint64_t Flags;
- uint64_t Offset = 0;
uint64_t Entsize;
uint32_t Type;
uint32_t Link;
uint32_t Info;
+ uint64_t getOffset() const;
+
static InputSectionBase Discarded;
InputSectionBase()
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 97d2d3ae2aa..6a93079b85b 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1733,7 +1733,8 @@ static InputSectionBase *findSection(ArrayRef<InputSectionBase *> Arr,
uint64_t Offset) {
for (InputSectionBase *S : Arr)
if (S && S != &InputSection::Discarded)
- if (Offset >= S->Offset && Offset < S->Offset + S->getSize<ELFT>())
+ if (Offset >= S->getOffset() &&
+ Offset < S->getOffset() + S->getSize<ELFT>())
return S;
return nullptr;
}
@@ -1752,8 +1753,8 @@ readAddressArea(DWARFContext &Dwarf, InputSection *Sec, size_t CurrentCU) {
for (std::pair<uint64_t, uint64_t> &R : Ranges)
if (InputSectionBase *S = findSection<ELFT>(Sections, R.first))
- Ret.push_back(
- {S, R.first - S->Offset, R.second - S->Offset, CurrentCU});
+ Ret.push_back({S, R.first - S->getOffset(), R.second - S->getOffset(),
+ CurrentCU});
++CurrentCU;
}
return Ret;
OpenPOWER on IntegriCloud