Skip to content

Commit

Permalink
Section relative fixups are a coff concept, not a x86 one. Replace the
Browse files Browse the repository at this point in the history
x86 specific reloc_coff_secrel32 with a generic FK_SecRel_4.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147252 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Dec 24, 2011
1 parent 7782102 commit ce618af
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions include/llvm/MC/MCFixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ enum MCFixupKind {
FK_GPRel_2, ///< A two-byte gp relative fixup.
FK_GPRel_4, ///< A four-byte gp relative fixup.
FK_GPRel_8, ///< A eight-byte gp relative fixup.
FK_SecRel_1, ///< A one-byte section relative fixup.
FK_SecRel_2, ///< A two-byte section relative fixup.
FK_SecRel_4, ///< A four-byte section relative fixup.
FK_SecRel_8, ///< A eight-byte section relative fixup.

FirstTargetFixupKind = 128,

Expand Down
6 changes: 5 additions & 1 deletion lib/MC/MCAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
{ "FK_GPRel_1", 0, 8, 0 },
{ "FK_GPRel_2", 0, 16, 0 },
{ "FK_GPRel_4", 0, 32, 0 },
{ "FK_GPRel_8", 0, 64, 0 }
{ "FK_GPRel_8", 0, 64, 0 },
{ "FK_SecRel_1", 0, 8, 0 },
{ "FK_SecRel_2", 0, 16, 0 },
{ "FK_SecRel_4", 0, 32, 0 },
{ "FK_SecRel_8", 0, 64, 0 }
};

assert((size_t)Kind <= sizeof(Builtins) / sizeof(Builtins[0]) &&
Expand Down
4 changes: 1 addition & 3 deletions lib/MC/WinCOFFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"

#include "../Target/X86/MCTargetDesc/X86FixupKinds.h"

using namespace llvm;

namespace {
Expand Down Expand Up @@ -303,7 +301,7 @@ void WinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol)

DF->addFixup(MCFixup::Create(DF->getContents().size(),
MCSymbolRefExpr::Create (Symbol, getContext ()),
(MCFixupKind)X86::reloc_coff_secrel32));
FK_SecRel_4));
DF->getContents().resize(DF->getContents().size() + 4, 0);
}

Expand Down
8 changes: 5 additions & 3 deletions lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ static unsigned getFixupKindLog2Size(unsigned Kind) {
switch (Kind) {
default: assert(0 && "invalid fixup kind!");
case FK_PCRel_1:
case FK_SecRel_1:
case FK_Data_1: return 0;
case FK_PCRel_2:
case FK_SecRel_2:
case FK_Data_2: return 1;
case FK_PCRel_4:
case X86::reloc_riprel_4byte:
case X86::reloc_riprel_4byte_movq_load:
case X86::reloc_signed_4byte:
case X86::reloc_global_offset_table:
case X86::reloc_coff_secrel32:
case FK_SecRel_4:
case FK_Data_4: return 2;
case FK_PCRel_8:
case FK_SecRel_8:
case FK_Data_8: return 3;
}
}
Expand Down Expand Up @@ -77,8 +80,7 @@ class X86AsmBackend : public MCAsmBackend {
{ "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_global_offset_table", 0, 4 * 8, 0},
{ "reloc_coff_secrel32", 0, 4 * 8, 0}
{ "reloc_global_offset_table", 0, 4 * 8, 0}
};

if (Kind < FirstTargetFixupKind)
Expand Down
2 changes: 0 additions & 2 deletions lib/Target/X86/MCTargetDesc/X86FixupKinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ enum Fixups {
reloc_global_offset_table, // 32-bit, relative to the start
// of the instruction. Used only
// for _GLOBAL_OFFSET_TABLE_.
reloc_coff_secrel32, // PE-COFF section relative 32
// (only valid for win32 COFF)
// Marker
LastTargetFixupKind,
NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
Expand Down
2 changes: 1 addition & 1 deletion lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ unsigned X86WinCOFFObjectWriter::getRelocType(unsigned FixupKind) const {
else
llvm_unreachable("unsupported relocation type");
break;
case X86::reloc_coff_secrel32:
case FK_SecRel_4:
return Is64Bit ? COFF::IMAGE_REL_AMD64_SREL32 : COFF::IMAGE_REL_I386_SECREL;
break;
default:
Expand Down

0 comments on commit ce618af

Please sign in to comment.