aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-10-18 16:58:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-10-18 16:58:03 +0000
commit9edab3a9e15c40c1c9bf70df81c6afdab1cd02c2 (patch)
tree5171f99db28b22f6d379b9c300f638412ab0e8ed
parent0f0127f4a686ed55e5b8344d576999259f8c2297 (diff)
Produce a R_386_PLT32 when needed. Moved the default cases of switches to the
start for consistency. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116715 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/ELFObjectWriter.cpp20
-rw-r--r--test/MC/ELF/relocation-386.s16
2 files changed, 26 insertions, 10 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index e003a5679f..1cc73aa890 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -639,6 +639,8 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
if (Is64Bit) {
if (IsPCRel) {
switch (Modifier) {
+ default:
+ llvm_unreachable("Unimplemented");
case MCSymbolRefExpr::VK_None:
Type = ELF::R_X86_64_PC32;
break;
@@ -648,8 +650,6 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case llvm::MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
- default:
- llvm_unreachable("Unimplemented");
}
} else {
switch ((unsigned)Fixup.getKind()) {
@@ -659,6 +659,8 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case X86::reloc_pcrel_4byte:
assert(isInt<32>(Target.getConstant()));
switch (Modifier) {
+ default:
+ llvm_unreachable("Unimplemented");
case MCSymbolRefExpr::VK_None:
Type = ELF::R_X86_64_32S;
break;
@@ -668,8 +670,6 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
- default:
- llvm_unreachable("Unimplemented");
}
break;
case FK_Data_4:
@@ -682,7 +682,13 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
}
} else {
if (IsPCRel) {
- Type = ELF::R_386_PC32;
+ switch (Modifier) {
+ default:
+ llvm_unreachable("Unimplemented");
+ case MCSymbolRefExpr::VK_PLT:
+ Type = ELF::R_386_PLT32;
+ break;
+ }
} else {
switch ((unsigned)Fixup.getKind()) {
default: llvm_unreachable("invalid fixup kind!");
@@ -692,11 +698,11 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case X86::reloc_signed_4byte:
case X86::reloc_pcrel_4byte:
switch (Modifier) {
+ default:
+ llvm_unreachable("Unimplemented");
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;
diff --git a/test/MC/ELF/relocation-386.s b/test/MC/ELF/relocation-386.s
index e65adcc509..18aa9fa3d3 100644
--- a/test/MC/ELF/relocation-386.s
+++ b/test/MC/ELF/relocation-386.s
@@ -1,7 +1,7 @@
// 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.
+// Test that we produce the correct relocation types and that the relocation
+// to .Lfoo uses the symbol and not the section.
// CHECK: # Symbol 1
@@ -11,10 +11,20 @@
// CHECK-NEXT: (('r_offset', 2)
// CHECK-NEXT: ('r_sym', 1)
// CHECK-NEXT: ('r_type', 9)
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Relocation 1
+// CHECK-NEXT: (('r_offset',
+// CHECK-NEXT: ('r_sym',
+// CHECK-NEXT: ('r_type', 4)
.text
bar:
leal .Lfoo@GOTOFF(%ebx), %eax
- .section .rodata.str1.16,"aMS",@progbits,1
+
+ .global bar2
+bar2:
+ calll bar2@PLT
+
+ .section .rodata.str1.16,"aMS",@progbits,1
.Lfoo:
.asciz "bool llvm::llvm_start_multithreaded()"