[llvm-commits] [llvm] r116728 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp lib/Target/X86/X86AsmBackend.cpp test/MC/ELF/relocation-386.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 18 11:36:12 PDT 2010
Author: rafael
Date: Mon Oct 18 13:36:12 2010
New Revision: 116728
URL: http://llvm.org/viewvc/llvm-project?rev=116728&view=rev
Log:
Produce ELF::R_386_GOTPC relocations.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
llvm/trunk/test/MC/ELF/relocation-386.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=116728&r1=116727&r2=116728&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Oct 18 13:36:12 2010
@@ -707,7 +707,12 @@
break;
}
break;
- case FK_Data_4: Type = ELF::R_386_32; break;
+ case FK_Data_4:
+ if (Symbol->getName() == "_GLOBAL_OFFSET_TABLE_")
+ Type = ELF::R_386_GOTPC;
+ else
+ Type = ELF::R_386_32;
+ break;
case FK_Data_2: Type = ELF::R_386_16; break;
case X86::reloc_pcrel_1byte:
case FK_Data_1: Type = ELF::R_386_8; break;
Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=116728&r1=116727&r2=116728&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Mon Oct 18 13:36:12 2010
@@ -72,6 +72,11 @@
default:
return Op;
+ // This is used on i386 with things like addl $foo, %ebx
+ // FIXME: Should the other *i8 instructions be here too? If not, it might
+ // be better to just select X86::ADD32ri instead of X86::ADD32ri8.
+ case X86::ADD32ri8: return X86::ADD32ri;
+
case X86::JAE_1: return X86::JAE_4;
case X86::JA_1: return X86::JA_4;
case X86::JBE_1: return X86::JBE_4;
Modified: llvm/trunk/test/MC/ELF/relocation-386.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation-386.s?rev=116728&r1=116727&r2=116728&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation-386.s (original)
+++ llvm/trunk/test/MC/ELF/relocation-386.s Mon Oct 18 13:36:12 2010
@@ -16,6 +16,12 @@
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 4)
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Relocation 2
+// CHECK-NEXT: (('r_offset',
+// CHECK-NEXT: ('r_sym',
+// CHECK-NEXT: ('r_type', 10)
+// CHECK-NEXT: ),
.text
bar:
@@ -24,6 +30,7 @@
.global bar2
bar2:
calll bar2 at PLT
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
.section .rodata.str1.16,"aMS", at progbits,1
.Lfoo:
More information about the llvm-commits
mailing list