[lld] r247758 - [elf2] Add R_X86_64_32S.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 17:24:20 PDT 2015


Author: mspencer
Date: Tue Sep 15 19:24:19 2015
New Revision: 247758

URL: http://llvm.org/viewvc/llvm-project?rev=247758&view=rev
Log:
[elf2] Add R_X86_64_32S.

Added:
    lld/trunk/test/elf2/relocation-32S-error.s
Modified:
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/elf2/relocation.s

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=247758&r1=247757&r2=247758&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Sep 15 19:24:19 2015
@@ -501,12 +501,18 @@ template <class ELFT> void OutputSection
           support::endian::write64le(Location, SymVA + RI.r_addend);
           break;
         case llvm::ELF::R_X86_64_32: {
+        case llvm::ELF::R_X86_64_32S:
           APInt VA(64, SymVA);
           APInt Addend(64, RI.r_addend, true);
           APInt Result64 = VA + Addend;
           APInt Result = Result64.trunc(32);
-          if (Result.zext(64) != Result64)
-            error("Relocation out of range");
+          if (Type == llvm::ELF::R_X86_64_32) {
+            if (Result.zext(64) != Result64)
+              error("Relocation out of range");
+          } else
+            if (Result.sext(64) != Result64)
+              error("R_X86_64_32S out of range");
+
           support::endian::write32le(Location, Result.getZExtValue());
           break;
         }

Added: lld/trunk/test/elf2/relocation-32S-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-32S-error.s?rev=247758&view=auto
==============================================================================
--- lld/trunk/test/elf2/relocation-32S-error.s (added)
+++ lld/trunk/test/elf2/relocation-32S-error.s Tue Sep 15 19:24:19 2015
@@ -0,0 +1,9 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: not lld -flavor gnu2 %t -o %t2 2>&1 | FileCheck %s
+// REQUIRES: x86
+
+.global _start
+_start:
+  movq _start - 0x1000000000000, %rdx
+
+#CHECK: R_X86_64_32S out of range

Modified: lld/trunk/test/elf2/relocation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation.s?rev=247758&r1=247757&r2=247758&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation.s (original)
+++ lld/trunk/test/elf2/relocation.s Tue Sep 15 19:24:19 2015
@@ -35,10 +35,19 @@ R_X86_64_32:
 // CHECK-NEXT: R_X86_64_32:
 // CHECK-NEXT:  12000: {{.*}} movl $73728, %edx
 
+.section .R_X86_64_32S,"ax", at progbits
+.global R_X86_64_32S
+R_X86_64_32S:
+  movq lulz - 0x100000, %rdx
+
+// CHECK: Disassembly of section .R_X86_64_32S:
+// CHECK-NEXT: R_X86_64_32S:
+// CHECK-NEXT:  {{.*}}: {{.*}} movq -978935, %rdx
+
 .section .R_X86_64_64,"a", at progbits
 .global R_X86_64_64
 R_X86_64_64:
  .quad R_X86_64_64
 
 // CHECK:      Contents of section .R_X86_64_64:
-// CHECK-NEXT:   13000 00300100 00000000
+// CHECK-NEXT:   14000 00400100 00000000




More information about the llvm-commits mailing list