[llvm-commits] [llvm] r113508 - in /llvm/trunk: include/llvm/MC/ELFObjectWriter.h lib/MC/ELFObjectWriter.cpp lib/Target/X86/X86AsmBackend.cpp
Roman Divacky
rdivacky at freebsd.org
Thu Sep 9 10:57:50 PDT 2010
Author: rdivacky
Date: Thu Sep 9 12:57:50 2010
New Revision: 113508
URL: http://llvm.org/viewvc/llvm-project?rev=113508&view=rev
Log:
Make ELF OS ABI dependent on the OS from target triple.
Modified:
llvm/trunk/include/llvm/MC/ELFObjectWriter.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
Modified: llvm/trunk/include/llvm/MC/ELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ELFObjectWriter.h?rev=113508&r1=113507&r2=113508&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/ELFObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/ELFObjectWriter.h Thu Sep 9 12:57:50 2010
@@ -10,6 +10,7 @@
#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>
@@ -25,8 +26,8 @@
void *Impl;
public:
- ELFObjectWriter(raw_ostream &OS, bool Is64Bit, bool IsLittleEndian = true,
- bool HasRelocationAddend = true);
+ ELFObjectWriter(raw_ostream &OS, bool Is64Bit, Triple::OSType OSType,
+ bool IsLittleEndian = true, bool HasRelocationAddend = true);
virtual ~ELFObjectWriter();
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=113508&r1=113507&r2=113508&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Sep 9 12:57:50 2010
@@ -107,6 +107,8 @@
bool HasRelocationAddend;
+ Triple::OSType OSType;
+
// This holds the symbol table index of the last local symbol.
unsigned LastLocalSymbolIndex;
// This holds the .strtab section index.
@@ -116,9 +118,10 @@
public:
ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit,
- bool _HasRelAddend)
+ bool _HasRelAddend, Triple::OSType _OSType)
: Writer(_Writer), OS(Writer->getStream()),
- Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend) {
+ Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend),
+ OSType(_OSType) {
}
void Write8(uint8_t Value) { Writer->Write8(Value); }
@@ -270,7 +273,12 @@
Write8(Writer->isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION]
- Write8(ELF::ELFOSABI_LINUX); // e_ident[EI_OSABI]
+ // e_ident[EI_OSABI]
+ switch (OSType) {
+ case Triple::FreeBSD: Write8(ELF::ELFOSABI_FREEBSD); break;
+ case Triple::Linux: Write8(ELF::ELFOSABI_LINUX); break;
+ default: Write8(ELF::ELFOSABI_NONE); break;
+ }
Write8(0); // e_ident[EI_ABIVERSION]
WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD);
@@ -955,11 +963,12 @@
ELFObjectWriter::ELFObjectWriter(raw_ostream &OS,
bool Is64Bit,
+ Triple::OSType OSType,
bool IsLittleEndian,
bool HasRelocationAddend)
: MCObjectWriter(OS, IsLittleEndian)
{
- Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend);
+ Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend, OSType);
}
ELFObjectWriter::~ELFObjectWriter() {
Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=113508&r1=113507&r2=113508&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Thu Sep 9 12:57:50 2010
@@ -186,25 +186,27 @@
namespace {
class ELFX86AsmBackend : public X86AsmBackend {
public:
- ELFX86AsmBackend(const Target &T)
- : X86AsmBackend(T) {
+ Triple::OSType OSType;
+ ELFX86AsmBackend(const Target &T, Triple::OSType _OSType)
+ : X86AsmBackend(T), OSType(_OSType) {
HasAbsolutizedSet = true;
HasScatteredSymbols = true;
}
bool isVirtualSection(const MCSection &Section) const {
const MCSectionELF &SE = static_cast<const MCSectionELF&>(Section);
- return SE.getType() == MCSectionELF::SHT_NOBITS;;
+ return SE.getType() == MCSectionELF::SHT_NOBITS;
}
};
class ELFX86_32AsmBackend : public ELFX86AsmBackend {
public:
- ELFX86_32AsmBackend(const Target &T)
- : ELFX86AsmBackend(T) {}
+ ELFX86_32AsmBackend(const Target &T, Triple::OSType OSType)
+ : ELFX86AsmBackend(T, OSType) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/false,
+ OSType,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/false);
}
@@ -212,11 +214,12 @@
class ELFX86_64AsmBackend : public ELFX86AsmBackend {
public:
- ELFX86_64AsmBackend(const Target &T)
- : ELFX86AsmBackend(T) {}
+ ELFX86_64AsmBackend(const Target &T, Triple::OSType OSType)
+ : ELFX86AsmBackend(T, OSType) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return new ELFObjectWriter(OS, /*Is64Bit=*/true,
+ OSType,
/*IsLittleEndian=*/true,
/*HasRelocationAddend=*/true);
}
@@ -324,7 +327,7 @@
case Triple::Win32:
return new WindowsX86AsmBackend(T, false);
default:
- return new ELFX86_32AsmBackend(T);
+ return new ELFX86_32AsmBackend(T, Triple(TT).getOS());
}
}
@@ -338,6 +341,6 @@
case Triple::Win32:
return new WindowsX86AsmBackend(T, true);
default:
- return new ELFX86_64AsmBackend(T);
+ return new ELFX86_64AsmBackend(T, Triple(TT).getOS());
}
}
More information about the llvm-commits
mailing list