[lld] r248321 - Add a token ppc64 reloc just to have a test showing that we handle BE.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 14:12:56 PDT 2015


Author: rafael
Date: Tue Sep 22 16:12:55 2015
New Revision: 248321

URL: http://llvm.org/viewvc/llvm-project?rev=248321&view=rev
Log:
Add a token ppc64 reloc just to have a test showing that we handle BE.

Modified:
    lld/trunk/ELF/Target.cpp
    lld/trunk/test/elf2/basic64be.s

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248321&r1=248320&r2=248321&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Sep 22 16:12:55 2015
@@ -162,6 +162,23 @@ void PPC64TargetInfo::writePltEntry(uint
 bool PPC64TargetInfo::relocNeedsGot(uint32_t Type) const { return false; }
 bool PPC64TargetInfo::relocNeedsPlt(uint32_t Type) const { return false; }
 void PPC64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
-                                  uint64_t BaseAddr, uint64_t SymVA) const {}
+                                  uint64_t BaseAddr, uint64_t SymVA) const {
+  typedef ELFFile<ELF64BE>::Elf_Rela Elf_Rela;
+  auto &Rel = *reinterpret_cast<const Elf_Rela *>(RelP);
+
+  uint64_t Offset = Rel.r_offset;
+  uint8_t *Location = Buf + Offset;
+  switch (Type) {
+  case R_PPC64_ADDR64:
+    support::endian::write64be(Location, SymVA + Rel.r_addend);
+    break;
+  case R_PPC64_TOC:
+    // We don't create a TOC yet.
+    break;
+  default:
+    error(Twine("unrecognized reloc ") + Twine(Type));
+    break;
+  }
+}
 }
 }

Modified: lld/trunk/test/elf2/basic64be.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=248321&r1=248320&r2=248321&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic64be.s (original)
+++ lld/trunk/test/elf2/basic64be.s Tue Sep 22 16:12:55 2015
@@ -1,6 +1,6 @@
 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
 # RUN: lld -flavor gnu2 -discard-all %t -o %t2
-# RUN: llvm-readobj -file-headers -sections -program-headers %t2 | FileCheck %s
+# RUN: llvm-readobj -file-headers -sections -section-data -program-headers %t2 | FileCheck %s
 # REQUIRES: ppc
 
 # exits with return code 42 on linux
@@ -54,6 +54,8 @@ _start:
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 0
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
@@ -70,6 +72,8 @@ _start:
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
@@ -86,6 +90,8 @@ _start:
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 3
@@ -118,6 +124,10 @@ _start:
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 1
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK-NEXT:      0000: 00000000 00011000 00000000 00000000  |................|
+# CHECK-NEXT:      0010: 00000000 00000000                    |........|
+# CHECK-NEXT:     )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 5
@@ -132,6 +142,8 @@ _start:
 # CHECK-NEXT:     Info: 1
 # CHECK-NEXT:     AddressAlignment: 8
 # CHECK-NEXT:     EntrySize: 24
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 6
@@ -146,6 +158,8 @@ _start:
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 1
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 # CHECK-NEXT: ProgramHeaders [




More information about the llvm-commits mailing list