mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
MC: Simplify Mach-O and ELF object writer implementations.
- What was I thinking????? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118992 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
//===-- llvm/MC/ELFObjectWriter.h - ELF File Writer ---------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is distributed under the University of Illinois Open Source
|
|
||||||
// License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef LLVM_MC_ELFOBJECTWRITER_H
|
|
||||||
#define LLVM_MC_ELFOBJECTWRITER_H
|
|
||||||
|
|
||||||
#include "llvm/ADT/Triple.h"
|
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
|
||||||
#include "llvm/Support/raw_ostream.h"
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
class MCAsmFixup;
|
|
||||||
class MCAssembler;
|
|
||||||
class MCFragment;
|
|
||||||
class MCValue;
|
|
||||||
class raw_ostream;
|
|
||||||
|
|
||||||
class ELFObjectWriter : public MCObjectWriter {
|
|
||||||
void *Impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ELFObjectWriter(raw_ostream &OS, bool Is64Bit, Triple::OSType OSType,
|
|
||||||
uint16_t EMachine, bool IsLittleEndian = true,
|
|
||||||
bool HasRelocationAddend = true);
|
|
||||||
|
|
||||||
virtual ~ELFObjectWriter();
|
|
||||||
|
|
||||||
virtual void ExecutePostLayoutBinding(MCAssembler &Asm);
|
|
||||||
|
|
||||||
virtual void RecordRelocation(const MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout,
|
|
||||||
const MCFragment *Fragment,
|
|
||||||
const MCFixup &Fixup, MCValue Target,
|
|
||||||
uint64_t &FixedValue);
|
|
||||||
|
|
||||||
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
|
|
||||||
const MCValue Target,
|
|
||||||
bool IsPCRel,
|
|
||||||
const MCFragment *DF) const;
|
|
||||||
|
|
||||||
virtual void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
|
||||||
#endif
|
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef LLVM_MC_MCOBJECTWRITER_H
|
#ifndef LLVM_MC_MCOBJECTWRITER_H
|
||||||
#define LLVM_MC_MCOBJECTWRITER_H
|
#define LLVM_MC_MCOBJECTWRITER_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/DataTypes.h"
|
#include "llvm/System/DataTypes.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -177,6 +178,13 @@ public:
|
|||||||
static void EncodeULEB128(uint64_t Value, raw_ostream &OS);
|
static void EncodeULEB128(uint64_t Value, raw_ostream &OS);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MCObjectWriter *createMachObjectWriter(raw_ostream &OS, bool is64Bit,
|
||||||
|
uint32_t CPUType, uint32_t CPUSubtype,
|
||||||
|
bool IsLittleEndian);
|
||||||
|
MCObjectWriter *createELFObjectWriter(raw_ostream &OS, bool is64Bit,
|
||||||
|
Triple::OSType OSType, uint16_t EMachine,
|
||||||
|
bool IsLittleEndian,
|
||||||
|
bool HasRelocationAddend);
|
||||||
MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS, bool is64Bit);
|
MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS, bool is64Bit);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
//===-- llvm/MC/MachObjectWriter.h - Mach-O File Writer ---------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is distributed under the University of Illinois Open Source
|
|
||||||
// License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef LLVM_MC_MACHOBJECTWRITER_H
|
|
||||||
#define LLVM_MC_MACHOBJECTWRITER_H
|
|
||||||
|
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
|
||||||
#include "llvm/Support/raw_ostream.h"
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
class MCAssembler;
|
|
||||||
class MCFragment;
|
|
||||||
class MCFixup;
|
|
||||||
class MCValue;
|
|
||||||
class raw_ostream;
|
|
||||||
|
|
||||||
class MachObjectWriter : public MCObjectWriter {
|
|
||||||
void *Impl;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MachObjectWriter(raw_ostream &OS, bool Is64Bit, uint32_t CPUType,
|
|
||||||
uint32_t CPUSubtype, bool IsLittleEndian = true);
|
|
||||||
virtual ~MachObjectWriter();
|
|
||||||
|
|
||||||
virtual void ExecutePostLayoutBinding(MCAssembler &Asm);
|
|
||||||
|
|
||||||
virtual void RecordRelocation(const MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout,
|
|
||||||
const MCFragment *Fragment,
|
|
||||||
const MCFixup &Fixup, MCValue Target,
|
|
||||||
uint64_t &FixedValue);
|
|
||||||
|
|
||||||
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
|
|
||||||
const MCValue Target,
|
|
||||||
bool IsPCRel,
|
|
||||||
const MCFragment *DF) const;
|
|
||||||
|
|
||||||
virtual void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
|
||||||
#endif
|
|
@@ -11,7 +11,6 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/ELFObjectWriter.h"
|
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
@@ -99,8 +98,7 @@ static bool RelocNeedsGOT(MCSymbolRefExpr::VariantKind Variant) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
class ELFObjectWriter : public MCObjectWriter {
|
||||||
class ELFObjectWriterImpl {
|
|
||||||
/*static bool isFixupKindX86RIPRel(unsigned Kind) {
|
/*static bool isFixupKindX86RIPRel(unsigned Kind) {
|
||||||
return Kind == X86::reloc_riprel_4byte ||
|
return Kind == X86::reloc_riprel_4byte ||
|
||||||
Kind == X86::reloc_riprel_4byte_movq_load;
|
Kind == X86::reloc_riprel_4byte_movq_load;
|
||||||
@@ -167,10 +165,6 @@ namespace {
|
|||||||
|
|
||||||
bool NeedsSymtabShndx;
|
bool NeedsSymtabShndx;
|
||||||
|
|
||||||
ELFObjectWriter *Writer;
|
|
||||||
|
|
||||||
raw_ostream &OS;
|
|
||||||
|
|
||||||
unsigned Is64Bit : 1;
|
unsigned Is64Bit : 1;
|
||||||
|
|
||||||
bool HasRelocationAddend;
|
bool HasRelocationAddend;
|
||||||
@@ -189,29 +183,20 @@ namespace {
|
|||||||
unsigned ShstrtabIndex;
|
unsigned ShstrtabIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit,
|
ELFObjectWriter(raw_ostream &_OS, bool _Is64Bit, bool IsLittleEndian,
|
||||||
uint16_t _EMachine, bool _HasRelAddend,
|
uint16_t _EMachine, bool _HasRelAddend,
|
||||||
Triple::OSType _OSType)
|
Triple::OSType _OSType)
|
||||||
: NeedsGOT(false), NeedsSymtabShndx(false), Writer(_Writer),
|
: MCObjectWriter(_OS, IsLittleEndian),
|
||||||
OS(Writer->getStream()),
|
NeedsGOT(false), NeedsSymtabShndx(false),
|
||||||
Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend),
|
Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend),
|
||||||
OSType(_OSType), EMachine(_EMachine) {
|
OSType(_OSType), EMachine(_EMachine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write8(uint8_t Value) { Writer->Write8(Value); }
|
|
||||||
void Write16(uint16_t Value) { Writer->Write16(Value); }
|
|
||||||
void Write32(uint32_t Value) { Writer->Write32(Value); }
|
|
||||||
//void Write64(uint64_t Value) { Writer->Write64(Value); }
|
|
||||||
void WriteZeros(unsigned N) { Writer->WriteZeros(N); }
|
|
||||||
//void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) {
|
|
||||||
// Writer->WriteBytes(Str, ZeroFillSize);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void WriteWord(uint64_t W) {
|
void WriteWord(uint64_t W) {
|
||||||
if (Is64Bit)
|
if (Is64Bit)
|
||||||
Writer->Write64(W);
|
Write64(W);
|
||||||
else
|
else
|
||||||
Writer->Write32(W);
|
Write32(W);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringLE16(char *buf, uint16_t Value) {
|
void StringLE16(char *buf, uint16_t Value) {
|
||||||
@@ -252,7 +237,7 @@ namespace {
|
|||||||
|
|
||||||
void String16(MCDataFragment &F, uint16_t Value) {
|
void String16(MCDataFragment &F, uint16_t Value) {
|
||||||
char buf[2];
|
char buf[2];
|
||||||
if (Writer->isLittleEndian())
|
if (isLittleEndian())
|
||||||
StringLE16(buf, Value);
|
StringLE16(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE16(buf, Value);
|
StringBE16(buf, Value);
|
||||||
@@ -261,7 +246,7 @@ namespace {
|
|||||||
|
|
||||||
void String32(MCDataFragment &F, uint32_t Value) {
|
void String32(MCDataFragment &F, uint32_t Value) {
|
||||||
char buf[4];
|
char buf[4];
|
||||||
if (Writer->isLittleEndian())
|
if (isLittleEndian())
|
||||||
StringLE32(buf, Value);
|
StringLE32(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE32(buf, Value);
|
StringBE32(buf, Value);
|
||||||
@@ -270,7 +255,7 @@ namespace {
|
|||||||
|
|
||||||
void String64(MCDataFragment &F, uint64_t Value) {
|
void String64(MCDataFragment &F, uint64_t Value) {
|
||||||
char buf[8];
|
char buf[8];
|
||||||
if (Writer->isLittleEndian())
|
if (isLittleEndian())
|
||||||
StringLE64(buf, Value);
|
StringLE64(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE64(buf, Value);
|
StringBE64(buf, Value);
|
||||||
@@ -357,8 +342,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit the ELF header.
|
// Emit the ELF header.
|
||||||
void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize,
|
void ELFObjectWriter::WriteHeader(uint64_t SectionDataSize,
|
||||||
unsigned NumberOfSections) {
|
unsigned NumberOfSections) {
|
||||||
// ELF Header
|
// ELF Header
|
||||||
// ----------
|
// ----------
|
||||||
//
|
//
|
||||||
@@ -375,7 +360,7 @@ void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize,
|
|||||||
Write8(Is64Bit ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]
|
Write8(Is64Bit ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]
|
||||||
|
|
||||||
// e_ident[EI_DATA]
|
// e_ident[EI_DATA]
|
||||||
Write8(Writer->isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
|
Write8(isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
|
||||||
|
|
||||||
Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION]
|
Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION]
|
||||||
// e_ident[EI_OSABI]
|
// e_ident[EI_OSABI]
|
||||||
@@ -423,13 +408,13 @@ void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize,
|
|||||||
Write16(ShstrtabIndex);
|
Write16(ShstrtabIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteSymbolEntry(MCDataFragment *SymtabF,
|
void ELFObjectWriter::WriteSymbolEntry(MCDataFragment *SymtabF,
|
||||||
MCDataFragment *ShndxF,
|
MCDataFragment *ShndxF,
|
||||||
uint64_t name,
|
uint64_t name,
|
||||||
uint8_t info, uint64_t value,
|
uint8_t info, uint64_t value,
|
||||||
uint64_t size, uint8_t other,
|
uint64_t size, uint8_t other,
|
||||||
uint32_t shndx,
|
uint32_t shndx,
|
||||||
bool Reserved) {
|
bool Reserved) {
|
||||||
if (ShndxF) {
|
if (ShndxF) {
|
||||||
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
||||||
String32(*ShndxF, shndx);
|
String32(*ShndxF, shndx);
|
||||||
@@ -497,7 +482,7 @@ static const MCSymbol &AliasedSymbol(const MCSymbol &Symbol) {
|
|||||||
return *S;
|
return *S;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::ExecutePostLayoutBinding(MCAssembler &Asm) {
|
void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) {
|
||||||
// The presence of symbol versions causes undefined symbols and
|
// The presence of symbol versions causes undefined symbols and
|
||||||
// versions declared with @@@ to be renamed.
|
// versions declared with @@@ to be renamed.
|
||||||
|
|
||||||
@@ -543,10 +528,10 @@ void ELFObjectWriterImpl::ExecutePostLayoutBinding(MCAssembler &Asm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *SymtabF,
|
void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF,
|
||||||
MCDataFragment *ShndxF,
|
MCDataFragment *ShndxF,
|
||||||
ELFSymbolData &MSD,
|
ELFSymbolData &MSD,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
MCSymbolData &OrigData = *MSD.SymbolData;
|
MCSymbolData &OrigData = *MSD.SymbolData;
|
||||||
MCSymbolData &Data =
|
MCSymbolData &Data =
|
||||||
Layout.getAssembler().getSymbolData(AliasedSymbol(OrigData.getSymbol()));
|
Layout.getAssembler().getSymbolData(AliasedSymbol(OrigData.getSymbol()));
|
||||||
@@ -590,10 +575,10 @@ void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *SymtabF,
|
|||||||
Size, Other, MSD.SectionIndex, IsReserved);
|
Size, Other, MSD.SectionIndex, IsReserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *SymtabF,
|
void ELFObjectWriter::WriteSymbolTable(MCDataFragment *SymtabF,
|
||||||
MCDataFragment *ShndxF,
|
MCDataFragment *ShndxF,
|
||||||
const MCAssembler &Asm,
|
const MCAssembler &Asm,
|
||||||
const MCAsmLayout &Layout,
|
const MCAsmLayout &Layout,
|
||||||
const SectionIndexMapTy &SectionIndexMap) {
|
const SectionIndexMapTy &SectionIndexMap) {
|
||||||
// The string table must be emitted first because we need the index
|
// The string table must be emitted first because we need the index
|
||||||
// into the string table for all the symbol names.
|
// into the string table for all the symbol names.
|
||||||
@@ -679,12 +664,12 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this is currently X86/X86_64 only
|
// FIXME: this is currently X86/X86_64 only
|
||||||
void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
||||||
const MCAsmLayout &Layout,
|
const MCAsmLayout &Layout,
|
||||||
const MCFragment *Fragment,
|
const MCFragment *Fragment,
|
||||||
const MCFixup &Fixup,
|
const MCFixup &Fixup,
|
||||||
MCValue Target,
|
MCValue Target,
|
||||||
uint64_t &FixedValue) {
|
uint64_t &FixedValue) {
|
||||||
int64_t Addend = 0;
|
int64_t Addend = 0;
|
||||||
int Index = 0;
|
int Index = 0;
|
||||||
int64_t Value = Target.getConstant();
|
int64_t Value = Target.getConstant();
|
||||||
@@ -886,8 +871,8 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
ELFObjectWriterImpl::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
||||||
const MCSymbol *S) {
|
const MCSymbol *S) {
|
||||||
MCSymbolData &SD = Asm.getSymbolData(*S);
|
MCSymbolData &SD = Asm.getSymbolData(*S);
|
||||||
|
|
||||||
// Local symbol.
|
// Local symbol.
|
||||||
@@ -938,8 +923,8 @@ static bool isLocal(const MCSymbolData &Data) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::ComputeIndexMap(MCAssembler &Asm,
|
void ELFObjectWriter::ComputeIndexMap(MCAssembler &Asm,
|
||||||
SectionIndexMapTy &SectionIndexMap) {
|
SectionIndexMapTy &SectionIndexMap) {
|
||||||
unsigned Index = 1;
|
unsigned Index = 1;
|
||||||
for (MCAssembler::iterator it = Asm.begin(),
|
for (MCAssembler::iterator it = Asm.begin(),
|
||||||
ie = Asm.end(); it != ie; ++it) {
|
ie = Asm.end(); it != ie; ++it) {
|
||||||
@@ -960,7 +945,7 @@ void ELFObjectWriterImpl::ComputeIndexMap(MCAssembler &Asm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm,
|
void ELFObjectWriter::ComputeSymbolTable(MCAssembler &Asm,
|
||||||
const SectionIndexMapTy &SectionIndexMap) {
|
const SectionIndexMapTy &SectionIndexMap) {
|
||||||
// FIXME: Is this the correct place to do this?
|
// FIXME: Is this the correct place to do this?
|
||||||
if (NeedsGOT) {
|
if (NeedsGOT) {
|
||||||
@@ -1057,8 +1042,8 @@ void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm,
|
|||||||
UndefinedSymbolData[i].SymbolData->setIndex(Index++);
|
UndefinedSymbolData[i].SymbolData->setIndex(Index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
|
void ELFObjectWriter::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
|
||||||
const MCSectionData &SD) {
|
const MCSectionData &SD) {
|
||||||
if (!Relocations[&SD].empty()) {
|
if (!Relocations[&SD].empty()) {
|
||||||
MCContext &Ctx = Asm.getContext();
|
MCContext &Ctx = Asm.getContext();
|
||||||
const MCSectionELF *RelaSection;
|
const MCSectionELF *RelaSection;
|
||||||
@@ -1087,16 +1072,16 @@ void ELFObjectWriterImpl::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
|
|||||||
|
|
||||||
WriteRelocationsFragment(Asm, F, &SD);
|
WriteRelocationsFragment(Asm, F, &SD);
|
||||||
|
|
||||||
Asm.AddSectionToTheEnd(*Writer, RelaSD, Layout);
|
Asm.AddSectionToTheEnd(*this, RelaSD, Layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteSecHdrEntry(uint32_t Name, uint32_t Type,
|
void ELFObjectWriter::WriteSecHdrEntry(uint32_t Name, uint32_t Type,
|
||||||
uint64_t Flags, uint64_t Address,
|
uint64_t Flags, uint64_t Address,
|
||||||
uint64_t Offset, uint64_t Size,
|
uint64_t Offset, uint64_t Size,
|
||||||
uint32_t Link, uint32_t Info,
|
uint32_t Link, uint32_t Info,
|
||||||
uint64_t Alignment,
|
uint64_t Alignment,
|
||||||
uint64_t EntrySize) {
|
uint64_t EntrySize) {
|
||||||
Write32(Name); // sh_name: index into string table
|
Write32(Name); // sh_name: index into string table
|
||||||
Write32(Type); // sh_type
|
Write32(Type); // sh_type
|
||||||
WriteWord(Flags); // sh_flags
|
WriteWord(Flags); // sh_flags
|
||||||
@@ -1109,9 +1094,9 @@ void ELFObjectWriterImpl::WriteSecHdrEntry(uint32_t Name, uint32_t Type,
|
|||||||
WriteWord(EntrySize); // sh_entsize
|
WriteWord(EntrySize); // sh_entsize
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteRelocationsFragment(const MCAssembler &Asm,
|
void ELFObjectWriter::WriteRelocationsFragment(const MCAssembler &Asm,
|
||||||
MCDataFragment *F,
|
MCDataFragment *F,
|
||||||
const MCSectionData *SD) {
|
const MCSectionData *SD) {
|
||||||
std::vector<ELFRelocationEntry> &Relocs = Relocations[SD];
|
std::vector<ELFRelocationEntry> &Relocs = Relocations[SD];
|
||||||
// sort by the r_offset just like gnu as does
|
// sort by the r_offset just like gnu as does
|
||||||
array_pod_sort(Relocs.begin(), Relocs.end());
|
array_pod_sort(Relocs.begin(), Relocs.end());
|
||||||
@@ -1145,8 +1130,8 @@ void ELFObjectWriterImpl::WriteRelocationsFragment(const MCAssembler &Asm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::CreateMetadataSections(MCAssembler &Asm,
|
void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
|
||||||
MCAsmLayout &Layout,
|
MCAsmLayout &Layout,
|
||||||
const SectionIndexMapTy &SectionIndexMap) {
|
const SectionIndexMapTy &SectionIndexMap) {
|
||||||
MCContext &Ctx = Asm.getContext();
|
MCContext &Ctx = Asm.getContext();
|
||||||
MCDataFragment *F;
|
MCDataFragment *F;
|
||||||
@@ -1193,14 +1178,14 @@ void ELFObjectWriterImpl::CreateMetadataSections(MCAssembler &Asm,
|
|||||||
MCDataFragment *ShndxF = NULL;
|
MCDataFragment *ShndxF = NULL;
|
||||||
if (NeedsSymtabShndx) {
|
if (NeedsSymtabShndx) {
|
||||||
ShndxF = new MCDataFragment(SymtabShndxSD);
|
ShndxF = new MCDataFragment(SymtabShndxSD);
|
||||||
Asm.AddSectionToTheEnd(*Writer, *SymtabShndxSD, Layout);
|
Asm.AddSectionToTheEnd(*this, *SymtabShndxSD, Layout);
|
||||||
}
|
}
|
||||||
WriteSymbolTable(F, ShndxF, Asm, Layout, SectionIndexMap);
|
WriteSymbolTable(F, ShndxF, Asm, Layout, SectionIndexMap);
|
||||||
Asm.AddSectionToTheEnd(*Writer, SymtabSD, Layout);
|
Asm.AddSectionToTheEnd(*this, SymtabSD, Layout);
|
||||||
|
|
||||||
F = new MCDataFragment(&StrtabSD);
|
F = new MCDataFragment(&StrtabSD);
|
||||||
F->getContents().append(StringTable.begin(), StringTable.end());
|
F->getContents().append(StringTable.begin(), StringTable.end());
|
||||||
Asm.AddSectionToTheEnd(*Writer, StrtabSD, Layout);
|
Asm.AddSectionToTheEnd(*this, StrtabSD, Layout);
|
||||||
|
|
||||||
F = new MCDataFragment(&ShstrtabSD);
|
F = new MCDataFragment(&ShstrtabSD);
|
||||||
|
|
||||||
@@ -1233,13 +1218,13 @@ void ELFObjectWriterImpl::CreateMetadataSections(MCAssembler &Asm,
|
|||||||
F->getContents() += '\x00';
|
F->getContents() += '\x00';
|
||||||
}
|
}
|
||||||
|
|
||||||
Asm.AddSectionToTheEnd(*Writer, ShstrtabSD, Layout);
|
Asm.AddSectionToTheEnd(*this, ShstrtabSD, Layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ELFObjectWriterImpl::IsFixupFullyResolved(const MCAssembler &Asm,
|
bool ELFObjectWriter::IsFixupFullyResolved(const MCAssembler &Asm,
|
||||||
const MCValue Target,
|
const MCValue Target,
|
||||||
bool IsPCRel,
|
bool IsPCRel,
|
||||||
const MCFragment *DF) const {
|
const MCFragment *DF) const {
|
||||||
// If this is a PCrel relocation, find the section this fixup value is
|
// If this is a PCrel relocation, find the section this fixup value is
|
||||||
// relative to.
|
// relative to.
|
||||||
const MCSection *BaseSection = 0;
|
const MCSection *BaseSection = 0;
|
||||||
@@ -1270,9 +1255,9 @@ bool ELFObjectWriterImpl::IsFixupFullyResolved(const MCAssembler &Asm,
|
|||||||
return !SectionB && BaseSection == SectionA;
|
return !SectionB && BaseSection == SectionA;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::CreateGroupSections(MCAssembler &Asm,
|
void ELFObjectWriter::CreateGroupSections(MCAssembler &Asm,
|
||||||
MCAsmLayout &Layout,
|
MCAsmLayout &Layout,
|
||||||
GroupMapTy &GroupMap) {
|
GroupMapTy &GroupMap) {
|
||||||
typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
|
typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
|
||||||
// Build the groups
|
// Build the groups
|
||||||
RevGroupMapTy Groups;
|
RevGroupMapTy Groups;
|
||||||
@@ -1316,16 +1301,16 @@ void ELFObjectWriterImpl::CreateGroupSections(MCAssembler &Asm,
|
|||||||
i != e; ++i) {
|
i != e; ++i) {
|
||||||
const MCSectionELF *Group = i->second;
|
const MCSectionELF *Group = i->second;
|
||||||
MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
|
MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
|
||||||
Asm.AddSectionToTheEnd(*Writer, Data, Layout);
|
Asm.AddSectionToTheEnd(*this, Data, Layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteSection(MCAssembler &Asm,
|
void ELFObjectWriter::WriteSection(MCAssembler &Asm,
|
||||||
const SectionIndexMapTy &SectionIndexMap,
|
const SectionIndexMapTy &SectionIndexMap,
|
||||||
uint32_t GroupSymbolIndex,
|
uint32_t GroupSymbolIndex,
|
||||||
uint64_t Offset, uint64_t Size,
|
uint64_t Offset, uint64_t Size,
|
||||||
uint64_t Alignment,
|
uint64_t Alignment,
|
||||||
const MCSectionELF &Section) {
|
const MCSectionELF &Section) {
|
||||||
uint64_t sh_link = 0;
|
uint64_t sh_link = 0;
|
||||||
uint64_t sh_info = 0;
|
uint64_t sh_info = 0;
|
||||||
|
|
||||||
@@ -1390,9 +1375,8 @@ void ELFObjectWriterImpl::WriteSection(MCAssembler &Asm,
|
|||||||
Alignment, Section.getEntrySize());
|
Alignment, Section.getEntrySize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
|
void ELFObjectWriter::WriteObject(MCAssembler &Asm,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
|
|
||||||
GroupMapTy GroupMap;
|
GroupMapTy GroupMap;
|
||||||
CreateGroupSections(Asm, const_cast<MCAsmLayout&>(Layout), GroupMap);
|
CreateGroupSections(Asm, const_cast<MCAsmLayout&>(Layout), GroupMap);
|
||||||
|
|
||||||
@@ -1460,7 +1444,7 @@ void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
|
|||||||
|
|
||||||
FileOff += Layout.getSectionFileSize(&SD);
|
FileOff += Layout.getSectionFileSize(&SD);
|
||||||
|
|
||||||
Asm.WriteSectionData(&SD, Layout, Writer);
|
Asm.WriteSectionData(&SD, Layout, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Padding = OffsetToAlignment(FileOff, NaturalAlignment);
|
uint64_t Padding = OffsetToAlignment(FileOff, NaturalAlignment);
|
||||||
@@ -1492,44 +1476,12 @@ void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ELFObjectWriter::ELFObjectWriter(raw_ostream &OS,
|
MCObjectWriter *llvm::createELFObjectWriter(raw_ostream &OS,
|
||||||
bool Is64Bit,
|
bool Is64Bit,
|
||||||
Triple::OSType OSType,
|
Triple::OSType OSType,
|
||||||
uint16_t EMachine,
|
uint16_t EMachine,
|
||||||
bool IsLittleEndian,
|
bool IsLittleEndian,
|
||||||
bool HasRelocationAddend)
|
bool HasRelocationAddend) {
|
||||||
: MCObjectWriter(OS, IsLittleEndian)
|
return new ELFObjectWriter(OS, Is64Bit, IsLittleEndian, EMachine,
|
||||||
{
|
HasRelocationAddend, OSType);
|
||||||
Impl = new ELFObjectWriterImpl(this, Is64Bit, EMachine,
|
|
||||||
HasRelocationAddend, OSType);
|
|
||||||
}
|
|
||||||
|
|
||||||
ELFObjectWriter::~ELFObjectWriter() {
|
|
||||||
delete (ELFObjectWriterImpl*) Impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) {
|
|
||||||
((ELFObjectWriterImpl*) Impl)->ExecutePostLayoutBinding(Asm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout,
|
|
||||||
const MCFragment *Fragment,
|
|
||||||
const MCFixup &Fixup, MCValue Target,
|
|
||||||
uint64_t &FixedValue) {
|
|
||||||
((ELFObjectWriterImpl*) Impl)->RecordRelocation(Asm, Layout, Fragment, Fixup,
|
|
||||||
Target, FixedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ELFObjectWriter::IsFixupFullyResolved(const MCAssembler &Asm,
|
|
||||||
const MCValue Target,
|
|
||||||
bool IsPCRel,
|
|
||||||
const MCFragment *DF) const {
|
|
||||||
return ((ELFObjectWriterImpl*) Impl)->IsFixupFullyResolved(Asm, Target,
|
|
||||||
IsPCRel, DF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ELFObjectWriter::WriteObject(MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout) {
|
|
||||||
((ELFObjectWriterImpl*) Impl)->WriteObject(Asm, Layout);
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/MachObjectWriter.h"
|
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
@@ -159,7 +158,7 @@ static bool isScatteredFixupFullyResolvedSimple(const MCAssembler &Asm,
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MachObjectWriterImpl {
|
class MachObjectWriter : public MCObjectWriter {
|
||||||
// See <mach-o/loader.h>.
|
// See <mach-o/loader.h>.
|
||||||
enum {
|
enum {
|
||||||
Header_Magic32 = 0xFEEDFACE,
|
Header_Magic32 = 0xFEEDFACE,
|
||||||
@@ -284,29 +283,17 @@ class MachObjectWriterImpl {
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
MachObjectWriter *Writer;
|
|
||||||
|
|
||||||
raw_ostream &OS;
|
|
||||||
|
|
||||||
unsigned Is64Bit : 1;
|
unsigned Is64Bit : 1;
|
||||||
|
|
||||||
uint32_t CPUType;
|
uint32_t CPUType;
|
||||||
uint32_t CPUSubtype;
|
uint32_t CPUSubtype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MachObjectWriterImpl(MachObjectWriter *_Writer, bool _Is64Bit,
|
MachObjectWriter(raw_ostream &_OS,
|
||||||
uint32_t _CPUType, uint32_t _CPUSubtype)
|
bool _Is64Bit, uint32_t _CPUType, uint32_t _CPUSubtype,
|
||||||
: Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit),
|
bool _IsLittleEndian)
|
||||||
CPUType(_CPUType), CPUSubtype(_CPUSubtype) {
|
: MCObjectWriter(_OS, _IsLittleEndian),
|
||||||
}
|
Is64Bit(_Is64Bit), CPUType(_CPUType), CPUSubtype(_CPUSubtype) {
|
||||||
|
|
||||||
void Write8(uint8_t Value) { Writer->Write8(Value); }
|
|
||||||
void Write16(uint16_t Value) { Writer->Write16(Value); }
|
|
||||||
void Write32(uint32_t Value) { Writer->Write32(Value); }
|
|
||||||
void Write64(uint64_t Value) { Writer->Write64(Value); }
|
|
||||||
void WriteZeros(unsigned N) { Writer->WriteZeros(N); }
|
|
||||||
void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) {
|
|
||||||
Writer->WriteBytes(Str, ZeroFillSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteHeader(unsigned NumLoadCommands, unsigned LoadCommandsSize,
|
void WriteHeader(unsigned NumLoadCommands, unsigned LoadCommandsSize,
|
||||||
@@ -1170,7 +1157,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout) {
|
void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
|
||||||
unsigned NumSections = Asm.size();
|
unsigned NumSections = Asm.size();
|
||||||
|
|
||||||
// The section data starts after the header, the segment load command (and
|
// The section data starts after the header, the segment load command (and
|
||||||
@@ -1271,7 +1258,7 @@ public:
|
|||||||
// Write the actual section data.
|
// Write the actual section data.
|
||||||
for (MCAssembler::const_iterator it = Asm.begin(),
|
for (MCAssembler::const_iterator it = Asm.begin(),
|
||||||
ie = Asm.end(); it != ie; ++it)
|
ie = Asm.end(); it != ie; ++it)
|
||||||
Asm.WriteSectionData(it, Layout, Writer);
|
Asm.WriteSectionData(it, Layout, this);
|
||||||
|
|
||||||
// Write the extra padding.
|
// Write the extra padding.
|
||||||
WriteZeros(SectionDataPadding);
|
WriteZeros(SectionDataPadding);
|
||||||
@@ -1331,42 +1318,9 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MachObjectWriter::MachObjectWriter(raw_ostream &OS,
|
MCObjectWriter *llvm::createMachObjectWriter(raw_ostream &OS, bool is64Bit,
|
||||||
bool Is64Bit,
|
uint32_t CPUType,
|
||||||
uint32_t CPUType,
|
uint32_t CPUSubtype,
|
||||||
uint32_t CPUSubtype,
|
bool IsLittleEndian) {
|
||||||
bool IsLittleEndian)
|
return new MachObjectWriter(OS, is64Bit, CPUType, CPUSubtype, IsLittleEndian);
|
||||||
: MCObjectWriter(OS, IsLittleEndian)
|
|
||||||
{
|
|
||||||
Impl = new MachObjectWriterImpl(this, Is64Bit, CPUType, CPUSubtype);
|
|
||||||
}
|
|
||||||
|
|
||||||
MachObjectWriter::~MachObjectWriter() {
|
|
||||||
delete (MachObjectWriterImpl*) Impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MachObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) {
|
|
||||||
((MachObjectWriterImpl*) Impl)->ExecutePostLayoutBinding(Asm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MachObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout,
|
|
||||||
const MCFragment *Fragment,
|
|
||||||
const MCFixup &Fixup, MCValue Target,
|
|
||||||
uint64_t &FixedValue) {
|
|
||||||
((MachObjectWriterImpl*) Impl)->RecordRelocation(Asm, Layout, Fragment, Fixup,
|
|
||||||
Target, FixedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MachObjectWriter::IsFixupFullyResolved(const MCAssembler &Asm,
|
|
||||||
const MCValue Target,
|
|
||||||
bool IsPCRel,
|
|
||||||
const MCFragment *DF) const {
|
|
||||||
return ((MachObjectWriterImpl*) Impl)->IsFixupFullyResolved(Asm, Target,
|
|
||||||
IsPCRel, DF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
|
||||||
const MCAsmLayout &Layout) {
|
|
||||||
((MachObjectWriterImpl*) Impl)->WriteObject(Asm, Layout);
|
|
||||||
}
|
}
|
||||||
|
@@ -11,14 +11,12 @@
|
|||||||
#include "ARM.h"
|
#include "ARM.h"
|
||||||
#include "ARMFixupKinds.h"
|
#include "ARMFixupKinds.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/ELFObjectWriter.h"
|
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCObjectFormat.h"
|
#include "llvm/MC/MCObjectFormat.h"
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MachObjectWriter.h"
|
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/MachO.h"
|
#include "llvm/Support/MachO.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
@@ -94,10 +92,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
|
return createELFObjectWriter(OS, /*Is64Bit=*/false,
|
||||||
OSType, ELF::EM_ARM,
|
OSType, ELF::EM_ARM,
|
||||||
/*IsLittleEndian=*/true,
|
/*IsLittleEndian=*/true,
|
||||||
/*HasRelocationAddend=*/false);
|
/*HasRelocationAddend=*/false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,8 +131,9 @@ public:
|
|||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
// FIXME: Subtarget info should be derived. Force v7 for now.
|
// FIXME: Subtarget info should be derived. Force v7 for now.
|
||||||
return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeARM,
|
return createMachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeARM,
|
||||||
MachO::CPUSubType_ARM_V7);
|
MachO::CPUSubType_ARM_V7,
|
||||||
|
/*IsLittleEndian=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
||||||
|
@@ -11,14 +11,12 @@
|
|||||||
#include "MBlaze.h"
|
#include "MBlaze.h"
|
||||||
#include "MBlazeFixupKinds.h"
|
#include "MBlazeFixupKinds.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/ELFObjectWriter.h"
|
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCObjectFormat.h"
|
#include "llvm/MC/MCObjectFormat.h"
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MachObjectWriter.h"
|
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@@ -104,10 +102,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
|
return createELFObjectWriter(OS, /*Is64Bit=*/false,
|
||||||
OSType, ELF::EM_MBLAZE,
|
OSType, ELF::EM_MBLAZE,
|
||||||
/*IsLittleEndian=*/false,
|
/*IsLittleEndian=*/false,
|
||||||
/*HasRelocationAddend=*/true);
|
/*HasRelocationAddend=*/true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "X86.h"
|
#include "X86.h"
|
||||||
#include "X86FixupKinds.h"
|
#include "X86FixupKinds.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/ELFObjectWriter.h"
|
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCObjectFormat.h"
|
#include "llvm/MC/MCObjectFormat.h"
|
||||||
@@ -19,7 +18,6 @@
|
|||||||
#include "llvm/MC/MCSectionCOFF.h"
|
#include "llvm/MC/MCSectionCOFF.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MachObjectWriter.h"
|
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/MachO.h"
|
#include "llvm/Support/MachO.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
@@ -310,10 +308,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
|
return createELFObjectWriter(OS, /*Is64Bit=*/false,
|
||||||
OSType, ELF::EM_386,
|
OSType, ELF::EM_386,
|
||||||
/*IsLittleEndian=*/true,
|
/*IsLittleEndian=*/true,
|
||||||
/*HasRelocationAddend=*/false);
|
/*HasRelocationAddend=*/false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -327,10 +325,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new ELFObjectWriter(OS, /*Is64Bit=*/true,
|
return createELFObjectWriter(OS, /*Is64Bit=*/true,
|
||||||
OSType, ELF::EM_X86_64,
|
OSType, ELF::EM_X86_64,
|
||||||
/*IsLittleEndian=*/true,
|
/*IsLittleEndian=*/true,
|
||||||
/*HasRelocationAddend=*/true);
|
/*HasRelocationAddend=*/true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -397,8 +395,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeI386,
|
return createMachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeI386,
|
||||||
MachO::CPUSubType_I386_ALL);
|
MachO::CPUSubType_I386_ALL,
|
||||||
|
/*IsLittleEndian=*/true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -414,8 +413,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||||
return new MachObjectWriter(OS, /*Is64Bit=*/true, MachO::CPUTypeX86_64,
|
return createMachObjectWriter(OS, /*Is64Bit=*/true, MachO::CPUTypeX86_64,
|
||||||
MachO::CPUSubType_I386_ALL);
|
MachO::CPUSubType_I386_ALL,
|
||||||
|
/*IsLittleEndian=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
||||||
|
Reference in New Issue
Block a user