[llvm-commits] [llvm] r116711 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/relocation-386.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 18 09:38:05 PDT 2010
Author: rafael
Date: Mon Oct 18 11:38:04 2010
New Revision: 116711
URL: http://llvm.org/viewvc/llvm-project?rev=116711&view=rev
Log:
Handle GOTOFF correctly on i386.
Added:
llvm/trunk/test/MC/ELF/relocation-386.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=116711&r1=116710&r2=116711&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Oct 18 11:38:04 2010
@@ -556,17 +556,19 @@
if (SD.isExternal())
return true;
- if (Section.getFlags() & MCSectionELF::SHF_MERGE)
- return Target.getConstant() != 0;
-
MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind();
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());
if (&Sec2 != &Section &&
- (Kind == MCSymbolRefExpr::VK_PLT || Kind == MCSymbolRefExpr::VK_GOTPCREL))
+ (Kind == MCSymbolRefExpr::VK_PLT ||
+ Kind == MCSymbolRefExpr::VK_GOTPCREL ||
+ Kind == MCSymbolRefExpr::VK_GOTOFF))
return true;
+ if (Section.getFlags() & MCSectionELF::SHF_MERGE)
+ return Target.getConstant() != 0;
+
return false;
}
@@ -663,7 +665,7 @@
case MCSymbolRefExpr::VK_GOT:
Type = ELF::R_X86_64_GOT32;
break;
- case llvm::MCSymbolRefExpr::VK_GOTPCREL:
+ case MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
default:
@@ -689,6 +691,14 @@
// instead?
case X86::reloc_signed_4byte:
case X86::reloc_pcrel_4byte:
+ switch (Modifier) {
+ case MCSymbolRefExpr::VK_GOTOFF:
+ Type = ELF::R_386_GOTOFF;
+ break;
+ default:
+ llvm_unreachable("Unimplemented");
+ }
+ break;
case FK_Data_4: Type = ELF::R_386_32; break;
case FK_Data_2: Type = ELF::R_386_16; break;
case X86::reloc_pcrel_1byte:
Added: llvm/trunk/test/MC/ELF/relocation-386.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation-386.s?rev=116711&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation-386.s (added)
+++ llvm/trunk/test/MC/ELF/relocation-386.s Mon Oct 18 11:38:04 2010
@@ -0,0 +1,20 @@
+// RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
+
+// Test that we produce a GOTOFF and that the relocation uses the symbol and not
+// the section.
+
+
+// CHECK: # Symbol 1
+// CHECK-NEXT: (('st_name', 5) # '.Lfoo'
+
+// CHECK: # Relocation 0
+// CHECK-NEXT: (('r_offset', 2)
+// CHECK-NEXT: ('r_sym', 1)
+// CHECK-NEXT: ('r_type', 9)
+
+ .text
+bar:
+ leal .Lfoo at GOTOFF(%ebx), %eax
+ .section .rodata.str1.16,"aMS", at progbits,1
+.Lfoo:
+ .asciz "bool llvm::llvm_start_multithreaded()"
More information about the llvm-commits
mailing list