aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/MCTargetDesc
diff options
context:
space:
mode:
authorCharles Davis <cdavis5x@gmail.com>2013-08-27 05:38:30 +0000
committerCharles Davis <cdavis5x@gmail.com>2013-08-27 05:38:30 +0000
commitf69a29b23a116a3520f185054290c445abf9aa62 (patch)
treec98b02ef136f3b0b7378b2e883faae39c6177679 /lib/Target/X86/MCTargetDesc
parent45fbe98c21d06448d1977e8abc95972f4ad86b26 (diff)
downloadexternal_llvm-f69a29b23a116a3520f185054290c445abf9aa62.zip
external_llvm-f69a29b23a116a3520f185054290c445abf9aa62.tar.gz
external_llvm-f69a29b23a116a3520f185054290c445abf9aa62.tar.bz2
Revert "Fix the build broken by r189315." and "Move everything depending on Object/MachOFormat.h over to Support/MachO.h."
This reverts commits r189319 and r189315. r189315 broke some tests on what I believe are big-endian platforms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/MCTargetDesc')
-rw-r--r--lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp10
-rw-r--r--lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp24
-rw-r--r--lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp132
3 files changed, 84 insertions, 82 deletions
diff --git a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index fc3bae3..598ddee 100644
--- a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -19,10 +19,10 @@
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
+#include "llvm/Object/MachOFormat.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -395,8 +395,8 @@ public:
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createX86MachObjectWriter(OS, /*Is64Bit=*/false,
- MachO::CPU_TYPE_I386,
- MachO::CPU_SUBTYPE_I386_ALL);
+ object::mach::CTM_i386,
+ object::mach::CSX86_ALL);
}
};
@@ -409,8 +409,8 @@ public:
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createX86MachObjectWriter(OS, /*Is64Bit=*/true,
- MachO::CPU_TYPE_X86_64,
- MachO::CPU_SUBTYPE_X86_64_ALL);
+ object::mach::CTM_x86_64,
+ object::mach::CSX86_ALL);
}
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
diff --git a/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp b/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp
index 209b1d0..75b5acf 100644
--- a/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp
@@ -17,7 +17,7 @@
using namespace llvm;
using namespace object;
-using namespace MachO;
+using namespace macho;
namespace {
class X86_64MachORelocationInfo : public MCRelocationInfo {
@@ -33,7 +33,7 @@ public:
StringRef SymName; SymI->getName(SymName);
uint64_t SymAddr; SymI->getAddress(SymAddr);
- any_relocation_info RE = Obj->getRelocation(Rel.getRawDataRefImpl());
+ RelocationEntry RE = Obj->getRelocation(Rel.getRawDataRefImpl());
bool isPCRel = Obj->getAnyRelocationPCRel(RE);
MCSymbol *Sym = Ctx.GetOrCreateSymbol(SymName);
@@ -43,44 +43,44 @@ public:
const MCExpr *Expr = 0;
switch(RelType) {
- case X86_64_RELOC_TLV:
+ case RIT_X86_64_TLV:
Expr = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_TLVP, Ctx);
break;
- case X86_64_RELOC_SIGNED_4:
+ case RIT_X86_64_Signed4:
Expr = MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Sym, Ctx),
MCConstantExpr::Create(4, Ctx),
Ctx);
break;
- case X86_64_RELOC_SIGNED_2:
+ case RIT_X86_64_Signed2:
Expr = MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Sym, Ctx),
MCConstantExpr::Create(2, Ctx),
Ctx);
break;
- case X86_64_RELOC_SIGNED_1:
+ case RIT_X86_64_Signed1:
Expr = MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Sym, Ctx),
MCConstantExpr::Create(1, Ctx),
Ctx);
break;
- case X86_64_RELOC_GOT_LOAD:
+ case RIT_X86_64_GOTLoad:
Expr = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Ctx);
break;
- case X86_64_RELOC_GOT:
+ case RIT_X86_64_GOT:
Expr = MCSymbolRefExpr::Create(Sym, isPCRel ?
MCSymbolRefExpr::VK_GOTPCREL :
MCSymbolRefExpr::VK_GOT,
Ctx);
break;
- case X86_64_RELOC_SUBTRACTOR:
+ case RIT_X86_64_Subtractor:
{
RelocationRef RelNext;
Obj->getRelocationNext(Rel.getRawDataRefImpl(), RelNext);
- any_relocation_info RENext = Obj->getRelocation(RelNext.getRawDataRefImpl());
+ RelocationEntry RENext = Obj->getRelocation(RelNext.getRawDataRefImpl());
// X86_64_SUBTRACTOR must be followed by a relocation of type
- // X86_64_RELOC_UNSIGNED.
+ // X86_64_RELOC_UNSIGNED .
// NOTE: Scattered relocations don't exist on x86_64.
unsigned RType = Obj->getAnyRelocationType(RENext);
- if (RType != X86_64_RELOC_UNSIGNED)
+ if (RType != RIT_X86_64_Unsigned)
report_fatal_error("Expected X86_64_RELOC_UNSIGNED after "
"X86_64_RELOC_SUBTRACTOR.");
diff --git a/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
index 45437e0..6eff224 100644
--- a/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
@@ -16,11 +16,12 @@
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCValue.h"
+#include "llvm/Object/MachOFormat.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/MachO.h"
using namespace llvm;
+using namespace llvm::object;
namespace {
class X86MachObjectWriter : public MCMachObjectTargetWriter {
@@ -131,7 +132,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
if (Target.isAbsolute()) { // constant
// SymbolNum of 0 indicates the absolute section.
- Type = MachO::X86_64_RELOC_UNSIGNED;
+ Type = macho::RIT_X86_64_Unsigned;
Index = 0;
// FIXME: I believe this is broken, I don't think the linker can understand
@@ -140,7 +141,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
// is to use an absolute symbol (which we don't support yet).
if (IsPCRel) {
IsExtern = 1;
- Type = MachO::X86_64_RELOC_BRANCH;
+ Type = macho::RIT_X86_64_Branch;
}
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
@@ -192,15 +193,15 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
IsExtern = 0;
}
- Type = MachO::X86_64_RELOC_UNSIGNED;
-
- MachO::relocation_info MRE;
- MRE.r_address = FixupOffset;
- MRE.r_symbolnum = Index;
- MRE.r_pcrel = IsPCRel;
- MRE.r_length = Log2Size;
- MRE.r_extern = IsExtern;
- MRE.r_type = Type;
+ Type = macho::RIT_X86_64_Unsigned;
+
+ macho::RelocationEntry MRE;
+ MRE.Word0 = FixupOffset;
+ MRE.Word1 = ((Index << 0) |
+ (IsPCRel << 24) |
+ (Log2Size << 25) |
+ (IsExtern << 27) |
+ (Type << 28));
Writer->addRelocation(Fragment->getParent(), MRE);
if (B_Base) {
@@ -211,7 +212,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
IsExtern = 0;
}
- Type = MachO::X86_64_RELOC_SUBTRACTOR;
+ Type = macho::RIT_X86_64_Subtractor;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
MCSymbolData &SD = Asm.getSymbolData(*Symbol);
@@ -271,15 +272,15 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
// rewrite the movq to an leaq at link time if the symbol ends up in
// the same linkage unit.
if (unsigned(Fixup.getKind()) == X86::reloc_riprel_4byte_movq_load)
- Type = MachO::X86_64_RELOC_GOT_LOAD;
+ Type = macho::RIT_X86_64_GOTLoad;
else
- Type = MachO::X86_64_RELOC_GOT;
+ Type = macho::RIT_X86_64_GOT;
} else if (Modifier == MCSymbolRefExpr::VK_TLVP) {
- Type = MachO::X86_64_RELOC_TLV;
+ Type = macho::RIT_X86_64_TLV;
} else if (Modifier != MCSymbolRefExpr::VK_None) {
report_fatal_error("unsupported symbol modifier in relocation");
} else {
- Type = MachO::X86_64_RELOC_SIGNED;
+ Type = macho::RIT_X86_64_Signed;
// The Darwin x86_64 relocation format has a problem where it cannot
// encode an address (L<foo> + <constant>) which is outside the atom
@@ -296,9 +297,9 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
// (the additional bias), but instead appear to just look at the final
// offset.
switch (-(Target.getConstant() + (1LL << Log2Size))) {
- case 1: Type = MachO::X86_64_RELOC_SIGNED_1; break;
- case 2: Type = MachO::X86_64_RELOC_SIGNED_2; break;
- case 4: Type = MachO::X86_64_RELOC_SIGNED_4; break;
+ case 1: Type = macho::RIT_X86_64_Signed1; break;
+ case 2: Type = macho::RIT_X86_64_Signed2; break;
+ case 4: Type = macho::RIT_X86_64_Signed4; break;
}
}
} else {
@@ -306,24 +307,24 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
report_fatal_error("unsupported symbol modifier in branch "
"relocation");
- Type = MachO::X86_64_RELOC_BRANCH;
+ Type = macho::RIT_X86_64_Branch;
}
} else {
if (Modifier == MCSymbolRefExpr::VK_GOT) {
- Type = MachO::X86_64_RELOC_GOT;
+ Type = macho::RIT_X86_64_GOT;
} else if (Modifier == MCSymbolRefExpr::VK_GOTPCREL) {
// GOTPCREL is allowed as a modifier on non-PCrel instructions, in which
// case all we do is set the PCrel bit in the relocation entry; this is
// used with exception handling, for example. The source is required to
// include any necessary offset directly.
- Type = MachO::X86_64_RELOC_GOT;
+ Type = macho::RIT_X86_64_GOT;
IsPCRel = 1;
} else if (Modifier == MCSymbolRefExpr::VK_TLVP) {
report_fatal_error("TLVP symbol modifier should have been rip-rel");
} else if (Modifier != MCSymbolRefExpr::VK_None)
report_fatal_error("unsupported symbol modifier in relocation");
else
- Type = MachO::X86_64_RELOC_UNSIGNED;
+ Type = macho::RIT_X86_64_Unsigned;
}
}
@@ -331,13 +332,13 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
FixedValue = Value;
// struct relocation_info (8 bytes)
- MachO::relocation_info MRE;
- MRE.r_address = FixupOffset;
- MRE.r_symbolnum = Index;
- MRE.r_pcrel = IsPCRel;
- MRE.r_length = Log2Size;
- MRE.r_extern = IsExtern;
- MRE.r_type = Type;
+ macho::RelocationEntry MRE;
+ MRE.Word0 = FixupOffset;
+ MRE.Word1 = ((Index << 0) |
+ (IsPCRel << 24) |
+ (Log2Size << 25) |
+ (IsExtern << 27) |
+ (Type << 28));
Writer->addRelocation(Fragment->getParent(), MRE);
}
@@ -351,7 +352,7 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
uint64_t &FixedValue) {
uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
- unsigned Type = MachO::GENERIC_RELOC_VANILLA;
+ unsigned Type = macho::RIT_Vanilla;
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
@@ -378,16 +379,15 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
// Note that there is no longer any semantic difference between these two
// relocation types from the linkers point of view, this is done solely for
// pedantic compatibility with 'as'.
- Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
- (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
+ Type = A_SD->isExternal() ? (unsigned)macho::RIT_Difference :
+ (unsigned)macho::RIT_Generic_LocalDifference;
Value2 = Writer->getSymbolAddress(B_SD, Layout);
FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
}
- MachO::scattered_relocation_info MRE;
// Relocations are written out in reverse order, so the PAIR comes first.
- if (Type == MachO::GENERIC_RELOC_SECTDIFF ||
- Type == MachO::GENERIC_RELOC_LOCAL_SECTDIFF) {
+ if (Type == macho::RIT_Difference ||
+ Type == macho::RIT_Generic_LocalDifference) {
// If the offset is too large to fit in a scattered relocation,
// we're hosed. It's an unfortunate limitation of the MachO format.
if (FixupOffset > 0xffffff) {
@@ -401,12 +401,13 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
llvm_unreachable("fatal error returned?!");
}
- MRE.r_address = 0;
- MRE.r_type = MachO::GENERIC_RELOC_PAIR;
- MRE.r_length = Log2Size;
- MRE.r_pcrel = IsPCRel;
- MRE.r_scattered = 1;
- MRE.r_value = Value2;
+ macho::RelocationEntry MRE;
+ MRE.Word0 = ((0 << 0) |
+ (macho::RIT_Pair << 24) |
+ (Log2Size << 28) |
+ (IsPCRel << 30) |
+ macho::RF_Scattered);
+ MRE.Word1 = Value2;
Writer->addRelocation(Fragment->getParent(), MRE);
} else {
// If the offset is more than 24-bits, it won't fit in a scattered
@@ -420,12 +421,13 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
return false;
}
- MRE.r_address = FixupOffset;
- MRE.r_type = Type;
- MRE.r_length = Log2Size;
- MRE.r_pcrel = IsPCRel;
- MRE.r_scattered = 1;
- MRE.r_value = Value;
+ macho::RelocationEntry MRE;
+ MRE.Word0 = ((FixupOffset << 0) |
+ (Type << 24) |
+ (Log2Size << 28) |
+ (IsPCRel << 30) |
+ macho::RF_Scattered);
+ MRE.Word1 = Value;
Writer->addRelocation(Fragment->getParent(), MRE);
return true;
}
@@ -467,13 +469,13 @@ void X86MachObjectWriter::RecordTLVPRelocation(MachObjectWriter *Writer,
}
// struct relocation_info (8 bytes)
- MachO::relocation_info MRE;
- MRE.r_address = Value;
- MRE.r_symbolnum = Index;
- MRE.r_pcrel = IsPCRel;
- MRE.r_length = Log2Size;
- MRE.r_extern = 1;
- MRE.r_type = MachO::GENERIC_RELOC_TLV;
+ macho::RelocationEntry MRE;
+ MRE.Word0 = Value;
+ MRE.Word1 = ((Index << 0) |
+ (IsPCRel << 24) |
+ (Log2Size << 25) |
+ (1 << 27) | // Extern
+ (macho::RIT_Generic_TLV << 28)); // Type
Writer->addRelocation(Fragment->getParent(), MRE);
}
@@ -533,7 +535,7 @@ void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
//
// FIXME: Currently, these are never generated (see code below). I cannot
// find a case where they are actually emitted.
- Type = MachO::GENERIC_RELOC_VANILLA;
+ Type = macho::RIT_Vanilla;
} else {
// Resolve constant variables.
if (SD->getSymbol().isVariable()) {
@@ -564,17 +566,17 @@ void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
if (IsPCRel)
FixedValue -= Writer->getSectionAddress(Fragment->getParent());
- Type = MachO::GENERIC_RELOC_VANILLA;
+ Type = macho::RIT_Vanilla;
}
// struct relocation_info (8 bytes)
- MachO::relocation_info MRE;
- MRE.r_address = FixupOffset;
- MRE.r_symbolnum = Index;
- MRE.r_pcrel = IsPCRel;
- MRE.r_length = Log2Size;
- MRE.r_extern = IsExtern;
- MRE.r_type = Type;
+ macho::RelocationEntry MRE;
+ MRE.Word0 = FixupOffset;
+ MRE.Word1 = ((Index << 0) |
+ (IsPCRel << 24) |
+ (Log2Size << 25) |
+ (IsExtern << 27) |
+ (Type << 28));
Writer->addRelocation(Fragment->getParent(), MRE);
}