[lld] r249729 - ELF2: Do not pass GotVA because it's accessible as Out<ELFT>::Got->getVA().

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 13:06:08 PDT 2015


Author: ruiu
Date: Thu Oct  8 15:06:07 2015
New Revision: 249729

URL: http://llvm.org/viewvc/llvm-project?rev=249729&view=rev
Log:
ELF2: Do not pass GotVA because it's accessible as Out<ELFT>::Got->getVA().

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

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=249729&r1=249728&r2=249729&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Oct  8 15:06:07 2015
@@ -35,7 +35,6 @@ void InputSection<ELFT>::relocate(
   for (const RelType &RI : Rels) {
     uint32_t SymIndex = RI.getSymbol(IsMips64EL);
     uint32_t Type = RI.getType(IsMips64EL);
-    uintX_t GotVA = Out<ELFT>::Got->getVA();
     uintX_t SymVA;
 
     // Handle relocations for local symbols -- they never get
@@ -56,7 +55,7 @@ void InputSection<ELFT>::relocate(
         SymVA = Out<ELFT>::Got->getEntryAddr(Body);
         Type = Target->getGotRefReloc();
       } else if (Target->relocPointsToGot(Type)) {
-        SymVA = GotVA;
+        SymVA = Out<ELFT>::Got->getVA();
         Type = Target->getPCRelReloc();
       } else if (isa<SharedSymbol<ELFT>>(Body)) {
         continue;
@@ -64,7 +63,7 @@ void InputSection<ELFT>::relocate(
     }
 
     Target->relocateOne(Buf, reinterpret_cast<const void *>(&RI), Type,
-                        BaseAddr, SymVA, GotVA);
+                        BaseAddr, SymVA);
   }
 }
 

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=249729&r1=249728&r2=249729&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Oct  8 15:06:07 2015
@@ -9,6 +9,7 @@
 
 #include "Target.h"
 #include "Error.h"
+#include "OutputSections.h"
 #include "Symbols.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -63,8 +64,7 @@ static void add32le(uint8_t *L, int32_t
 static void or32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) | V); }
 
 void X86TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                uint64_t BaseAddr, uint64_t SymVA,
-                                uint64_t GotVA) const {
+                                uint64_t BaseAddr, uint64_t SymVA) const {
   typedef ELFFile<ELF32LE>::Elf_Rel Elf_Rel;
   auto &Rel = *reinterpret_cast<const Elf_Rel *>(RelP);
 
@@ -72,7 +72,7 @@ void X86TargetInfo::relocateOne(uint8_t
   uint8_t *Loc = Buf + Offset;
   switch (Type) {
   case R_386_GOT32:
-    add32le(Loc, SymVA - GotVA);
+    add32le(Loc, SymVA - Out<ELF32LE>::Got->getVA());
     break;
   case R_386_PC32:
     add32le(Loc, SymVA - (BaseAddr + Offset));
@@ -158,7 +158,7 @@ bool X86_64TargetInfo::isRelRelative(uin
 
 void X86_64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP,
                                    uint32_t Type, uint64_t BaseAddr,
-                                   uint64_t SymVA, uint64_t GotVA) const {
+                                   uint64_t SymVA) const {
   typedef ELFFile<ELF64LE>::Elf_Rela Elf_Rela;
   auto &Rel = *reinterpret_cast<const Elf_Rela *>(RelP);
 
@@ -202,8 +202,7 @@ bool PPC64TargetInfo::relocNeedsPlt(uint
   return false;
 }
 void PPC64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                  uint64_t BaseAddr, uint64_t SymVA,
-                                  uint64_t GotVA) const {
+                                  uint64_t BaseAddr, uint64_t SymVA) const {
   typedef ELFFile<ELF64BE>::Elf_Rela Elf_Rela;
   auto &Rel = *reinterpret_cast<const Elf_Rela *>(RelP);
 
@@ -235,8 +234,7 @@ bool PPCTargetInfo::relocNeedsPlt(uint32
   return false;
 }
 void PPCTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                uint64_t BaseAddr, uint64_t SymVA,
-                                uint64_t GotVA) const {}
+                                uint64_t BaseAddr, uint64_t SymVA) const {}
 
 ARMTargetInfo::ARMTargetInfo() {
   // PCRelReloc = FIXME
@@ -251,8 +249,7 @@ bool ARMTargetInfo::relocNeedsPlt(uint32
   return false;
 }
 void ARMTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                uint64_t BaseAddr, uint64_t SymVA,
-                                uint64_t GotVA) const {}
+                                uint64_t BaseAddr, uint64_t SymVA) const {}
 
 AArch64TargetInfo::AArch64TargetInfo() {
   // PCRelReloc = FIXME
@@ -285,7 +282,7 @@ static uint64_t getAArch64Page(uint64_t
 
 void AArch64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP,
                                     uint32_t Type, uint64_t BaseAddr,
-                                    uint64_t SymVA, uint64_t GotVA) const {
+                                    uint64_t SymVA) const {
   typedef ELFFile<ELF64LE>::Elf_Rela Elf_Rela;
   auto &Rel = *reinterpret_cast<const Elf_Rela *>(RelP);
 
@@ -350,7 +347,6 @@ bool MipsTargetInfo::relocNeedsPlt(uint3
 }
 
 void MipsTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                 uint64_t BaseAddr, uint64_t SymVA,
-                                 uint64_t GotVA) const {}
+                                 uint64_t BaseAddr, uint64_t SymVA) const {}
 }
 }

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=249729&r1=249728&r2=249729&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Oct  8 15:06:07 2015
@@ -32,8 +32,7 @@ public:
   virtual bool relocPointsToGot(uint32_t Type) const;
   virtual bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const = 0;
   virtual void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                           uint64_t BaseAddr, uint64_t SymVA,
-                           uint64_t GotVA) const = 0;
+                           uint64_t BaseAddr, uint64_t SymVA) const = 0;
 
   virtual ~TargetInfo();
 
@@ -54,8 +53,7 @@ public:
   bool relocPointsToGot(uint32_t Type) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 class X86_64TargetInfo final : public TargetInfo {
@@ -66,8 +64,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
   bool isRelRelative(uint32_t Type) const override;
 };
 
@@ -79,8 +76,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 class PPCTargetInfo final : public TargetInfo {
@@ -91,8 +87,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 class ARMTargetInfo final : public TargetInfo {
@@ -103,8 +98,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 class AArch64TargetInfo final : public TargetInfo {
@@ -115,8 +109,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 class MipsTargetInfo final : public TargetInfo {
@@ -127,8 +120,7 @@ public:
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                   uint64_t BaseAddr, uint64_t SymVA,
-                   uint64_t GotVA) const override;
+                   uint64_t BaseAddr, uint64_t SymVA) const override;
 };
 
 extern std::unique_ptr<TargetInfo> Target;




More information about the llvm-commits mailing list