[lld] r321126 - Use references instead of pointers. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 15:59:35 PST 2017


Author: rafael
Date: Tue Dec 19 15:59:35 2017
New Revision: 321126

URL: http://llvm.org/viewvc/llvm-project?rev=321126&view=rev
Log:
Use references instead of pointers. NFC.

These values are trivially never null. While at it, also use
InputSection instead of InputSectionBase when possible.

Modified:
    lld/trunk/ELF/AArch64ErrataFix.cpp
    lld/trunk/ELF/Arch/ARM.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/SyntheticSections.h
    lld/trunk/ELF/Target.h
    lld/trunk/ELF/Thunks.cpp

Modified: lld/trunk/ELF/AArch64ErrataFix.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/AArch64ErrataFix.cpp?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/AArch64ErrataFix.cpp (original)
+++ lld/trunk/ELF/AArch64ErrataFix.cpp Tue Dec 19 15:59:35 2017
@@ -400,8 +400,8 @@ lld::elf::Patch843419Section::Patch84341
   this->Parent = P->getParent();
   PatchSym = addSyntheticLocal(
       Saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())), STT_FUNC, 0,
-      getSize(), this);
-  addSyntheticLocal(Saver.save("$x"), STT_NOTYPE, 0, 0, this);
+      getSize(), *this);
+  addSyntheticLocal(Saver.save("$x"), STT_NOTYPE, 0, 0, *this);
 }
 
 uint64_t lld::elf::Patch843419Section::getLDSTAddr() const {

Modified: lld/trunk/ELF/Arch/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/ARM.cpp?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/ARM.cpp (original)
+++ lld/trunk/ELF/Arch/ARM.cpp Tue Dec 19 15:59:35 2017
@@ -37,8 +37,8 @@ public:
   void writePltHeader(uint8_t *Buf) const override;
   void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr,
                 int32_t Index, unsigned RelOff) const override;
-  void addPltSymbols(InputSectionBase *IS, uint64_t Off) const override;
-  void addPltHeaderSymbols(InputSectionBase *ISD) const override;
+  void addPltSymbols(InputSection &IS, uint64_t Off) const override;
+  void addPltHeaderSymbols(InputSection &ISD) const override;
   bool needsThunk(RelExpr Expr, RelType Type, const InputFile *File,
                   uint64_t BranchAddr, const Symbol &S) const override;
   bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const override;
@@ -232,8 +232,7 @@ void ARM::writePltHeader(uint8_t *Buf) c
   write32le(Buf + 28, TrapInstr);
 }
 
-void ARM::addPltHeaderSymbols(InputSectionBase *ISD) const {
-  auto *IS = cast<InputSection>(ISD);
+void ARM::addPltHeaderSymbols(InputSection &IS) const {
   addSyntheticLocal("$a", STT_NOTYPE, 0, 0, IS);
   addSyntheticLocal("$d", STT_NOTYPE, 16, 0, IS);
 }
@@ -282,8 +281,7 @@ void ARM::writePlt(uint8_t *Buf, uint64_
   write32le(Buf + 12, TrapInstr); // Pad to 16-byte boundary
 }
 
-void ARM::addPltSymbols(InputSectionBase *ISD, uint64_t Off) const {
-  auto *IS = cast<InputSection>(ISD);
+void ARM::addPltSymbols(InputSection &IS, uint64_t Off) const {
   addSyntheticLocal("$a", STT_NOTYPE, Off, 0, IS);
   addSyntheticLocal("$d", STT_NOTYPE, Off + 12, 0, IS);
 }

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Dec 19 15:59:35 2017
@@ -275,9 +275,9 @@ InputSection *elf::createInterpSection()
 }
 
 Symbol *elf::addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
-                               uint64_t Size, InputSectionBase *Section) {
-  auto *S = make<Defined>(Section->File, Name, STB_LOCAL, STV_DEFAULT, Type,
-                          Value, Size, Section);
+                               uint64_t Size, InputSectionBase &Section) {
+  auto *S = make<Defined>(Section.File, Name, STB_LOCAL, STV_DEFAULT, Type,
+                          Value, Size, &Section);
   if (InX::SymTab)
     InX::SymTab->addSymbol(S);
   return S;
@@ -1893,10 +1893,10 @@ size_t PltSection::getSize() const {
 void PltSection::addSymbols() {
   // The PLT may have symbols defined for the Header, the IPLT has no header
   if (HeaderSize != 0)
-    Target->addPltHeaderSymbols(this);
+    Target->addPltHeaderSymbols(*this);
   size_t Off = HeaderSize;
   for (size_t I = 0; I < Entries.size(); ++I) {
-    Target->addPltSymbols(this, Off);
+    Target->addPltSymbols(*this, Off);
     Off += Target->PltEntrySize;
   }
 }

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Dec 19 15:59:35 2017
@@ -814,7 +814,7 @@ void decompressSections();
 void mergeSections();
 
 Symbol *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
-                          uint64_t Size, InputSectionBase *Section);
+                          uint64_t Size, InputSectionBase &Section);
 
 // Linker generated sections which can be used as inputs.
 struct InX {

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Tue Dec 19 15:59:35 2017
@@ -40,8 +40,8 @@ public:
   virtual void writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
                         uint64_t PltEntryAddr, int32_t Index,
                         unsigned RelOff) const {}
-  virtual void addPltHeaderSymbols(InputSectionBase *IS) const {}
-  virtual void addPltSymbols(InputSectionBase *IS, uint64_t Off) const {}
+  virtual void addPltHeaderSymbols(InputSection &IS) const {}
+  virtual void addPltSymbols(InputSection &IS, uint64_t Off) const {}
 
   // Returns true if a relocation only uses the low bits of a value such that
   // all those bits are in in the same page. For example, if the relocation

Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=321126&r1=321125&r2=321126&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Tue Dec 19 15:59:35 2017
@@ -164,9 +164,9 @@ void AArch64ABSLongThunk::writeTo(uint8_
 void AArch64ABSLongThunk::addSymbols(ThunkSection &IS) {
   ThunkSym = addSyntheticLocal(
       Saver.save("__AArch64AbsLongThunk_" + Destination.getName()), STT_FUNC,
-      Offset, size(), &IS);
-  addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, &IS);
-  addSyntheticLocal("$d", STT_NOTYPE, Offset + 8, 0, &IS);
+      Offset, size(), IS);
+  addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, IS);
+  addSyntheticLocal("$d", STT_NOTYPE, Offset + 8, 0, IS);
 }
 
 // This Thunk has a maximum range of 4Gb, this is sufficient for all programs
@@ -192,8 +192,8 @@ void AArch64ADRPThunk::addSymbols(ThunkS
 {
   ThunkSym = addSyntheticLocal(
       Saver.save("__AArch64ADRPThunk_" + Destination.getName()), STT_FUNC,
-      Offset, size(), &IS);
-  addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, &IS);
+      Offset, size(), IS);
+  addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, IS);
 }
 
 // ARM Target Thunks
@@ -217,8 +217,8 @@ void ARMV7ABSLongThunk::writeTo(uint8_t
 void ARMV7ABSLongThunk::addSymbols(ThunkSection &IS) {
   ThunkSym = addSyntheticLocal(
       Saver.save("__ARMv7ABSLongThunk_" + Destination.getName()), STT_FUNC,
-      Offset, size(), &IS);
-  addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, &IS);
+      Offset, size(), IS);
+  addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, IS);
 }
 
 bool ARMV7ABSLongThunk::isCompatibleWith(RelType Type) const {
@@ -241,8 +241,8 @@ void ThumbV7ABSLongThunk::writeTo(uint8_
 void ThumbV7ABSLongThunk::addSymbols(ThunkSection &IS) {
   ThunkSym = addSyntheticLocal(
       Saver.save("__Thumbv7ABSLongThunk_" + Destination.getName()), STT_FUNC,
-      Offset | 0x1, size(), &IS);
-  addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, &IS);
+      Offset | 0x1, size(), IS);
+  addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, IS);
 }
 
 bool ThumbV7ABSLongThunk::isCompatibleWith(RelType Type) const {
@@ -268,8 +268,8 @@ void ARMV7PILongThunk::writeTo(uint8_t *
 void ARMV7PILongThunk::addSymbols(ThunkSection &IS) {
   ThunkSym = addSyntheticLocal(
       Saver.save("__ARMV7PILongThunk_" + Destination.getName()), STT_FUNC,
-      Offset, size(), &IS);
-  addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, &IS);
+      Offset, size(), IS);
+  addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, IS);
 }
 
 bool ARMV7PILongThunk::isCompatibleWith(RelType Type) const {
@@ -295,8 +295,8 @@ void ThumbV7PILongThunk::writeTo(uint8_t
 void ThumbV7PILongThunk::addSymbols(ThunkSection &IS) {
   ThunkSym = addSyntheticLocal(
       Saver.save("__ThumbV7PILongThunk_" + Destination.getName()), STT_FUNC,
-      Offset | 0x1, size(), &IS);
-  addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, &IS);
+      Offset | 0x1, size(), IS);
+  addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, IS);
 }
 
 bool ThumbV7PILongThunk::isCompatibleWith(RelType Type) const {
@@ -318,7 +318,7 @@ void MipsThunk::writeTo(uint8_t *Buf, Th
 void MipsThunk::addSymbols(ThunkSection &IS) {
   ThunkSym =
       addSyntheticLocal(Saver.save("__LA25Thunk_" + Destination.getName()),
-                        STT_FUNC, Offset, size(), &IS);
+                        STT_FUNC, Offset, size(), IS);
 }
 
 InputSection *MipsThunk::getTargetInputSection() const {
@@ -342,7 +342,7 @@ void MicroMipsThunk::writeTo(uint8_t *Bu
 void MicroMipsThunk::addSymbols(ThunkSection &IS) {
   ThunkSym =
       addSyntheticLocal(Saver.save("__microLA25Thunk_" + Destination.getName()),
-                        STT_FUNC, Offset, size(), &IS);
+                        STT_FUNC, Offset, size(), IS);
   ThunkSym->StOther |= STO_MIPS_MICROMIPS;
 }
 
@@ -367,7 +367,7 @@ void MicroMipsR6Thunk::writeTo(uint8_t *
 void MicroMipsR6Thunk::addSymbols(ThunkSection &IS) {
   ThunkSym =
       addSyntheticLocal(Saver.save("__microLA25Thunk_" + Destination.getName()),
-                        STT_FUNC, Offset, size(), &IS);
+                        STT_FUNC, Offset, size(), IS);
   ThunkSym->StOther |= STO_MIPS_MICROMIPS;
 }
 




More information about the llvm-commits mailing list