public:
ELFObjectWriter(raw_ostream &OS, bool Is64Bit, Triple::OSType OSType,
- bool IsLittleEndian = true, bool HasRelocationAddend = true);
+ uint16_t EMachine, bool IsLittleEndian = true,
+ bool HasRelocationAddend = true);
virtual ~ELFObjectWriter();
Triple::OSType OSType;
+ uint16_t EMachine;
+
// This holds the symbol table index of the last local symbol.
unsigned LastLocalSymbolIndex;
// This holds the .strtab section index.
public:
ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit,
- bool _HasRelAddend, Triple::OSType _OSType)
+ uint16_t _EMachine, bool _HasRelAddend,
+ Triple::OSType _OSType)
: NeedsGOT(false), Writer(_Writer), OS(Writer->getStream()),
Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend),
- OSType(_OSType) {
+ OSType(_OSType), EMachine(_EMachine) {
}
void Write8(uint8_t Value) { Writer->Write8(Value); }
Write16(ELF::ET_REL); // e_type
- // FIXME: Make this configurable
- Write16(Is64Bit ? ELF::EM_X86_64 : ELF::EM_386); // e_machine = target
+ Write16(EMachine); // e_machine = target
Write32(ELF::EV_CURRENT); // e_version
WriteWord(0); // e_entry, no entry point in .o file
ELFObjectWriter::ELFObjectWriter(raw_ostream &OS,
bool Is64Bit,
Triple::OSType OSType,
+ uint16_t EMachine,
bool IsLittleEndian,
bool HasRelocationAddend)
: MCObjectWriter(OS, IsLittleEndian)
{
- Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend, OSType);
+ Impl = new ELFObjectWriterImpl(this, Is64Bit, EMachine,
+ HasRelocationAddend, OSType);
}
ELFObjectWriter::~ELFObjectWriter() {
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MachObjectWriter.h"
+#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegistry.h"
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
- OSType,
+ OSType, ELF::EM_ARM,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/false);
}
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MachObjectWriter.h"
+#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegistry.h"
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
- OSType,
+ OSType, ELF::EM_MBLAZE,
/*IsLittleEndian=*/false,
/*HasRelocationAddend=*/true);
}
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MachObjectWriter.h"
+#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegistry.h"
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
- OSType,
+ OSType, ELF::EM_386,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/false);
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/true,
- OSType,
+ OSType, ELF::EM_X86_64,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/true);
}