[lld] r297278 - Remove redundant member of InputSectionBase. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 06:12:53 PST 2017


Author: rafael
Date: Wed Mar  8 08:12:52 2017
New Revision: 297278

URL: http://llvm.org/viewvc/llvm-project?rev=297278&view=rev
Log:
Remove redundant member of InputSectionBase. NFC.

With this InputSectionBase is now 144 bytes.

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=297278&r1=297277&r2=297278&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Mar  8 08:12:52 2017
@@ -107,7 +107,7 @@ std::string elf::ObjectFile<ELFT>::getLi
   // 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 "";

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=297278&r1=297277&r2=297278&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Mar  8 08:12:52 2017
@@ -84,7 +84,6 @@ InputSectionBase::InputSectionBase(elf::
                        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 InputSectio
   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;

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=297278&r1=297277&r2=297278&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Mar  8 08:12:52 2017
@@ -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()

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=297278&r1=297277&r2=297278&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Wed Mar  8 08:12:52 2017
@@ -1733,7 +1733,8 @@ static InputSectionBase *findSection(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, Inp
 
     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;




More information about the llvm-commits mailing list