[llvm-commits] [llvm] r114339 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/basic-elf.ll test/MC/ELF/relocation.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Sep 20 12:20:47 PDT 2010
Author: rafael
Date: Mon Sep 20 14:20:47 2010
New Revision: 114339
URL: http://llvm.org/viewvc/llvm-project?rev=114339&view=rev
Log:
Produce a R_X86_64_32 when the value is >=0.
Added:
llvm/trunk/test/MC/ELF/relocation.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ELF/basic-elf.ll
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=114339&r1=114338&r2=114339&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Sep 20 14:20:47 2010
@@ -541,10 +541,13 @@
case X86::reloc_pcrel_4byte:
case FK_Data_4:
// check that the offset fits within a signed long
- if (isInt<32>(Target.getConstant()))
+ if (Target.getConstant() < 0) {
+ assert(isInt<32>(Target.getConstant()));
Type = ELF::R_X86_64_32S;
- else
+ } else {
+ assert(isUInt<32>(Target.getConstant()));
Type = ELF::R_X86_64_32;
+ }
break;
case FK_Data_2: Type = ELF::R_X86_64_16; break;
case X86::reloc_pcrel_1byte:
Modified: llvm/trunk/test/MC/ELF/basic-elf.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/basic-elf.ll?rev=114339&r1=114338&r2=114339&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/basic-elf.ll (original)
+++ llvm/trunk/test/MC/ELF/basic-elf.ll Mon Sep 20 14:20:47 2010
@@ -72,7 +72,7 @@
; 64: ('_relocations', [
; 64: # Relocation 0
; 64: (('r_offset', 5)
-; 64: ('r_type', 11)
+; 64: ('r_type', 10)
; 64: ('r_addend', 0)
; 64: ),
; 64: # Relocation 1
@@ -82,7 +82,7 @@
; 64: ),
; 64: # Relocation 2
; 64: (('r_offset', 15)
-; 64: ('r_type', 11)
+; 64: ('r_type', 10)
; 64: ('r_addend', 6)
; 64: ),
; 64: # Relocation 3
Added: llvm/trunk/test/MC/ELF/relocation.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation.s?rev=114339&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation.s (added)
+++ llvm/trunk/test/MC/ELF/relocation.s Mon Sep 20 14:20:47 2010
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
+
+// Test that we produce a R_X86_64_32.
+
+ .long Lset1
+
+
+// CHECK: # Relocation 0
+// CHECK-NEXT: (('r_offset', 0)
+// CHECK-NEXT: ('r_sym', 4)
+// CHECK-NEXT: ('r_type', 10)
+// CHECK-NEXT: ('r_addend', 0)
More information about the llvm-commits
mailing list