[lld] r330350 - Define InputSection::getOffset inline.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 11:00:46 PDT 2018


Author: rafael
Date: Thu Apr 19 11:00:46 2018
New Revision: 330350

URL: http://llvm.org/viewvc/llvm-project?rev=330350&view=rev
Log:
Define InputSection::getOffset inline.

This is much simpler than the other section types and there are many
places where the section type is statically know.

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

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=330350&r1=330349&r2=330350&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Apr 19 11:00:46 2018
@@ -143,7 +143,7 @@ uint64_t SectionBase::getOffset(uint64_t
   }
   case Regular:
   case Synthetic:
-    return cast<InputSection>(this)->OutSecOff + Offset;
+    return cast<InputSection>(this)->getOffset(Offset);
   case EHFrame:
     // The file crtbeginT.o has relocations pointing to the start of an empty
     // .eh_frame that is known to be the first in the link. It does that to
@@ -152,7 +152,7 @@ uint64_t SectionBase::getOffset(uint64_t
   case Merge:
     const MergeInputSection *MS = cast<MergeInputSection>(this);
     if (InputSection *IS = MS->getParent())
-      return IS->OutSecOff + MS->getParentOffset(Offset);
+      return IS->getOffset(MS->getParentOffset(Offset));
     return MS->getParentOffset(Offset);
   }
   llvm_unreachable("invalid section kind");

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=330350&r1=330349&r2=330350&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Thu Apr 19 11:00:46 2018
@@ -310,6 +310,8 @@ public:
   // beginning of the output section.
   template <class ELFT> void writeTo(uint8_t *Buf);
 
+  uint64_t getOffset(uint64_t Offset) const { return OutSecOff + Offset; }
+
   OutputSection *getParent() const;
 
   // This variable has two usages. Initially, it represents an index in the




More information about the llvm-commits mailing list