[llvm-commits] [llvm] r117241 - in /llvm/trunk/lib: MC/ELFObjectWriter.cpp Target/X86/X86AsmBackend.cpp Target/X86/X86FixupKinds.h Target/X86/X86MCCodeEmitter.cpp
Rafael Espindola
rafael.espindola at gmail.com
Sun Oct 24 10:35:43 PDT 2010
Author: rafael
Date: Sun Oct 24 12:35:42 2010
New Revision: 117241
URL: http://llvm.org/viewvc/llvm-project?rev=117241&view=rev
Log:
Add X86::reloc_global_offset_table and use it to have a single place where
we check for _GLOBAL_OFFSET_TABLE_.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
llvm/trunk/lib/Target/X86/X86FixupKinds.h
llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=117241&r1=117240&r2=117241&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sun Oct 24 12:35:42 2010
@@ -701,6 +701,10 @@
switch ((unsigned)Fixup.getKind()) {
default: llvm_unreachable("invalid fixup kind!");
+ case X86::reloc_global_offset_table:
+ Type = ELF::R_386_GOTPC;
+ break;
+
// FIXME: Should we avoid selecting reloc_signed_4byte in 32 bit mode
// instead?
case X86::reloc_signed_4byte:
@@ -710,10 +714,7 @@
default:
llvm_unreachable("Unimplemented");
case MCSymbolRefExpr::VK_None:
- if (Symbol->getName() == "_GLOBAL_OFFSET_TABLE_")
- Type = ELF::R_386_GOTPC;
- else
- Type = ELF::R_386_32;
+ Type = ELF::R_386_32;
break;
case MCSymbolRefExpr::VK_GOT:
Type = ELF::R_386_GOT32;
Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=117241&r1=117240&r2=117241&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Sun Oct 24 12:35:42 2010
@@ -39,6 +39,7 @@
case X86::reloc_riprel_4byte:
case X86::reloc_riprel_4byte_movq_load:
case X86::reloc_signed_4byte:
+ case X86::reloc_global_offset_table:
case FK_Data_4: return 2;
case FK_Data_8: return 3;
}
Modified: llvm/trunk/lib/Target/X86/X86FixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FixupKinds.h?rev=117241&r1=117240&r2=117241&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FixupKinds.h (original)
+++ llvm/trunk/lib/Target/X86/X86FixupKinds.h Sun Oct 24 12:35:42 2010
@@ -20,9 +20,12 @@
reloc_pcrel_2byte, // 16-bit pcrel, e.g. callw
reloc_riprel_4byte, // 32-bit rip-relative
reloc_riprel_4byte_movq_load, // 32-bit rip-relative in movq
- reloc_signed_4byte // 32-bit signed. Unlike FK_Data_4
+ reloc_signed_4byte, // 32-bit signed. Unlike FK_Data_4
// this will be sign extended at
// runtime.
+ reloc_global_offset_table // 32-bit, relative to the start
+ // of the instruction. Used only
+ // for _GLOBAL_OFFSET_TABLE_.
};
}
}
Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=117241&r1=117240&r2=117241&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Sun Oct 24 12:35:42 2010
@@ -39,7 +39,7 @@
~X86MCCodeEmitter() {}
unsigned getNumFixupKinds() const {
- return 6;
+ return 7;
}
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
@@ -49,7 +49,8 @@
{ "reloc_pcrel_2byte", 0, 2 * 8, MCFixupKindInfo::FKF_IsPCRel },
{ "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
{ "reloc_riprel_4byte_movq_load", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
- { "reloc_signed_4byte", 0, 4 * 8, 0}
+ { "reloc_signed_4byte", 0, 4 * 8, 0},
+ { "reloc_global_offset_table", 0, 4 * 8, 0}
};
if (Kind < FirstTargetFixupKind)
@@ -229,10 +230,10 @@
// If we have an immoffset, add it to the expression.
const MCExpr *Expr = DispOp.getExpr();
- if (StartsWithGlobalOffsetTable(Expr)) {
- // FIXME: We should probably change the FixupKind to a special one so that
- // other parts of MC don't have to check the symbol name.
+ if (FixupKind == FK_Data_4 && StartsWithGlobalOffsetTable(Expr)) {
assert(ImmOffset == 0);
+
+ FixupKind = MCFixupKind(X86::reloc_global_offset_table);
ImmOffset = CurByte;
}
More information about the llvm-commits
mailing list