[lld] r257596 - Reapply r257588

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 05:04:46 PST 2016


Author: grimar
Date: Wed Jan 13 07:04:46 2016
New Revision: 257596

URL: http://llvm.org/viewvc/llvm-project?rev=257596&view=rev
Log:
Reapply r257588
Fix: Added missed input file.

Initial commit message:
[ELF/AArch64] - Implemented R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 and R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC relocations

* R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 is calculated as Page(G(GTPREL(S+A))) – Page(P), set an ADRP immediate field to bits [32:12] of X; check –2^32 ≤ X < 2^32;
* R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC is calculated as G(GTPREL(S+A)), set an LD offset field to bits [11:3] of X. No overflow check; check that X&7 = 0.

Differential revision: http://reviews.llvm.org/D16117

Added:
    lld/trunk/test/ELF/Inputs/aarch64-tls-ie.s
    lld/trunk/test/ELF/aarch64-tls-ie.s
      - copied unchanged from r257594, lld/trunk/test/ELF/aarch64-tls-ie.s
Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=257596&r1=257595&r2=257596&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed Jan 13 07:04:46 2016
@@ -198,6 +198,8 @@ public:
   void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
                      uint64_t PltEntryAddr, int32_t Index,
                      unsigned RelOff) const override;
+  unsigned getTlsGotReloc(unsigned Type = -1) const override;
+  bool isTlsDynReloc(unsigned Type, const SymbolBody &S) const override;
   bool needsCopyRel(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
   bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
@@ -1179,6 +1181,7 @@ AArch64TargetInfo::AArch64TargetInfo() {
   IRelativeReloc = R_AARCH64_IRELATIVE;
   GotReloc = R_AARCH64_GLOB_DAT;
   PltReloc = R_AARCH64_JUMP_SLOT;
+  TlsGotReloc = R_AARCH64_TLS_TPREL64;
   LazyRelocations = true;
   PltEntrySize = 16;
   PltZeroEntrySize = 32;
@@ -1238,6 +1241,19 @@ void AArch64TargetInfo::writePltEntry(ui
               GotEntryAddr);
 }
 
+unsigned AArch64TargetInfo::getTlsGotReloc(unsigned Type) const {
+  if (Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
+      Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC)
+    return Type;
+  return TlsGotReloc;
+}
+
+bool AArch64TargetInfo::isTlsDynReloc(unsigned Type,
+                                      const SymbolBody &S) const {
+  return Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
+         Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
+}
+
 bool AArch64TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const {
   if (Config->Shared)
     return false;
@@ -1261,8 +1277,15 @@ bool AArch64TargetInfo::needsCopyRel(uin
 
 bool AArch64TargetInfo::relocNeedsGot(uint32_t Type,
                                       const SymbolBody &S) const {
-  return Type == R_AARCH64_ADR_GOT_PAGE || Type == R_AARCH64_LD64_GOT_LO12_NC ||
-         relocNeedsPlt(Type, S);
+  switch (Type) {
+  case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+  case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+  case R_AARCH64_ADR_GOT_PAGE:
+  case R_AARCH64_LD64_GOT_LO12_NC:
+    return true;
+  default:
+    return relocNeedsPlt(Type, S);
+  }
 }
 
 bool AArch64TargetInfo::relocNeedsPlt(uint32_t Type,
@@ -1328,7 +1351,8 @@ void AArch64TargetInfo::relocateOne(uint
     updateAArch64Adr(Loc, X & 0x1FFFFF);
     break;
   }
-  case R_AARCH64_ADR_PREL_PG_HI21: {
+  case R_AARCH64_ADR_PREL_PG_HI21:
+  case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: {
     uint64_t X = getAArch64Page(SA) - getAArch64Page(P);
     checkInt<33>(X, Type);
     updateAArch64Adr(Loc, (X >> 12) & 0x1FFFFF); // X[32:12]
@@ -1348,6 +1372,7 @@ void AArch64TargetInfo::relocateOne(uint
     break;
   }
   case R_AARCH64_LD64_GOT_LO12_NC:
+  case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
     checkAlignment<8>(SA, Type);
     or32le(Loc, (SA & 0xFF8) << 7);
     break;

Added: lld/trunk/test/ELF/Inputs/aarch64-tls-ie.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/aarch64-tls-ie.s?rev=257596&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/aarch64-tls-ie.s (added)
+++ lld/trunk/test/ELF/Inputs/aarch64-tls-ie.s Wed Jan 13 07:04:46 2016
@@ -0,0 +1,19 @@
+.text
+ .global foo
+ .section .tdata,"awT",%progbits
+ .align 2
+ .type foo, %object
+ .size foo, 4
+foo:
+ .word 5
+ .text
+
+.text
+ .global bar
+ .section .tdata,"awT",%progbits
+ .align 2
+ .type bar, %object
+ .size bar, 4
+bar:
+ .word 5
+ .text




More information about the llvm-commits mailing list