Skip to content

Commit

Permalink
Compile against llvm-3.3
Browse files Browse the repository at this point in the history
instead of against LLVM trunk@187732

Change-Id: Ibe45c9100421a2b937219fa7c9d69be59014379f

Note: this patch was found in the android ndk
  • Loading branch information
Andrew Hsieh authored and rib committed Nov 12, 2013
1 parent 5d24fe1 commit c8d3dd2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
3 changes: 2 additions & 1 deletion include/mcld/Support/raw_ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#endif
#include <string>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/FileSystem.h>

namespace mcld {

Expand All @@ -31,7 +32,7 @@ class raw_fd_ostream : public llvm::raw_fd_ostream
/// output errors).
raw_fd_ostream(const char *pFilename,
std::string &pErrorInfo,
llvm::sys::fs::OpenFlags pFlags = llvm::sys::fs::F_None);
unsigned pFlags = 0);

/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
/// ShouldClose is true, this closes the file when the stream is destroyed.
Expand Down
6 changes: 3 additions & 3 deletions lib/CodeGen/MCLDTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ static void addPassesToHandleExceptions(llvm::TargetMachine *TM,
// removed from the parent invoke(s). This could happen when a landing
// pad is shared by multiple invokes and is also a target of a normal
// edge from elsewhere.
PM.add(createSjLjEHPreparePass(TM));
PM.add(createSjLjEHPreparePass(TM->getTargetLowering()));
// FALLTHROUGH
case llvm::ExceptionHandling::DwarfCFI:
case llvm::ExceptionHandling::ARM:
case llvm::ExceptionHandling::Win64:
PM.add(createDwarfEHPass(TM));
break;
case llvm::ExceptionHandling::None:
PM.add(createLowerInvokePass(TM));
PM.add(createLowerInvokePass(TM->getTargetLowering()));

// The lower invoke pass may create unreachable code. Remove it.
PM.add(createUnreachableBlockEliminationPass());
Expand Down Expand Up @@ -288,7 +288,7 @@ bool mcld::MCLDTargetMachine::addCompilerPasses(PassManagerBase &pPM,
MCInstPrinter *InstPrinter =
m_pLLVMTarget->createMCInstPrinter(MAI.getAssemblerDialect(), MAI,
MII,
*Context->getRegisterInfo(), STI);
Context->getRegisterInfo(), STI);

MCCodeEmitter* MCE = 0;
MCAsmBackend *MAB = 0;
Expand Down
5 changes: 3 additions & 2 deletions lib/Support/ToolOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <llvm/Support/Signals.h>
#include <llvm/Support/Path.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/FormattedStream.h>

using namespace mcld;
Expand All @@ -29,7 +30,7 @@ ToolOutputFile::CleanupInstaller::CleanupInstaller(const sys::fs::Path& pPath)
: Keep(false), m_Path(pPath) {
// Arrange for the file to be deleted if the process is killed.
if ("-" != m_Path.native())
llvm::sys::RemoveFileOnSignal(m_Path.native());
llvm::sys::RemoveFileOnSignal(llvm::sys::Path(m_Path.native()));
}

ToolOutputFile::CleanupInstaller::~CleanupInstaller()
Expand All @@ -45,7 +46,7 @@ ToolOutputFile::CleanupInstaller::~CleanupInstaller()
// Ok, the file is successfully written and closed, or deleted. There's no
// further need to clean it up on signals.
if ("_" != m_Path.native())
llvm::sys::DontRemoveFileOnSignal(m_Path.native());
llvm::sys::DontRemoveFileOnSignal(llvm::sys::Path(m_Path.native()));
}

//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions lib/Support/Windows/PathV3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
#include <mcld/Support/Path.h>
#include <llvm/Support/ErrorHandling.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stack>
Expand Down
2 changes: 1 addition & 1 deletion lib/Support/raw_ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace mcld;
//===----------------------------------------------------------------------===//
mcld::raw_fd_ostream::raw_fd_ostream(const char *pFilename,
std::string &pErrorInfo,
llvm::sys::fs::OpenFlags pFlags)
unsigned pFlags)
: llvm::raw_fd_ostream(pFilename, pErrorInfo, pFlags),
m_bConfigColor(false),
m_bSetColor(false) {
Expand Down
48 changes: 34 additions & 14 deletions lib/Target/Mips/MipsELFDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@

using namespace mcld;


// MIPS mandatory dynamic section entries
enum {
DT_MIPS_RLD_VERSION = 0x70000001,
DT_MIPS_FLAGS = 0x70000005,
DT_MIPS_BASE_ADDRESS = 0x70000006,
DT_MIPS_LOCAL_GOTNO = 0x7000000a,
DT_MIPS_SYMTABNO = 0x70000011,
DT_MIPS_GOTSYM = 0x70000013,
DT_MIPS_PLTGOT = 0x70000032,
};

// Dynamic section MIPS flags
enum {
RHF_NONE = 0x00000000, // None
RHF_QUICKSTART = 0x00000001, // Use shortcut pointers
RHF_NOTPOT = 0x00000002, // Hash size not power of two
RHF_NO_LIBRARY_REPLACEMENT = 0x00000004 // Ignore LD_LIBRARY_PATH
};

MipsELFDynamic::MipsELFDynamic(const MipsGNULDBackend& pParent,
const LinkerConfig& pConfig)
: ELFDynamic(pParent, pConfig),
Expand All @@ -30,31 +50,31 @@ void MipsELFDynamic::reserveTargetEntries(const ELFFileFormat& pFormat)
if (pFormat.hasGOT())
reserveOne(llvm::ELF::DT_PLTGOT);

reserveOne(llvm::ELF::DT_MIPS_RLD_VERSION);
reserveOne(llvm::ELF::DT_MIPS_FLAGS);
reserveOne(llvm::ELF::DT_MIPS_BASE_ADDRESS);
reserveOne(llvm::ELF::DT_MIPS_LOCAL_GOTNO);
reserveOne(llvm::ELF::DT_MIPS_SYMTABNO);
reserveOne(llvm::ELF::DT_MIPS_GOTSYM);
reserveOne(DT_MIPS_RLD_VERSION);
reserveOne(DT_MIPS_FLAGS);
reserveOne(DT_MIPS_BASE_ADDRESS);
reserveOne(DT_MIPS_LOCAL_GOTNO);
reserveOne(DT_MIPS_SYMTABNO);
reserveOne(DT_MIPS_GOTSYM);

if (pFormat.hasGOTPLT())
reserveOne(llvm::ELF::DT_MIPS_PLTGOT);
reserveOne(DT_MIPS_PLTGOT);
}

void MipsELFDynamic::applyTargetEntries(const ELFFileFormat& pFormat)
{
if (pFormat.hasGOT())
applyOne(llvm::ELF::DT_PLTGOT, pFormat.getGOT().addr());

applyOne(llvm::ELF::DT_MIPS_RLD_VERSION, 1);
applyOne(llvm::ELF::DT_MIPS_FLAGS, llvm::ELF::RHF_NOTPOT);
applyOne(llvm::ELF::DT_MIPS_BASE_ADDRESS, getBaseAddress());
applyOne(llvm::ELF::DT_MIPS_LOCAL_GOTNO, getLocalGotNum(pFormat));
applyOne(llvm::ELF::DT_MIPS_SYMTABNO, getSymTabNum(pFormat));
applyOne(llvm::ELF::DT_MIPS_GOTSYM, getGotSym(pFormat));
applyOne(DT_MIPS_RLD_VERSION, 1);
applyOne(DT_MIPS_FLAGS, RHF_NOTPOT);
applyOne(DT_MIPS_BASE_ADDRESS, getBaseAddress());
applyOne(DT_MIPS_LOCAL_GOTNO, getLocalGotNum(pFormat));
applyOne(DT_MIPS_SYMTABNO, getSymTabNum(pFormat));
applyOne(DT_MIPS_GOTSYM, getGotSym(pFormat));

if (pFormat.hasGOTPLT())
applyOne(llvm::ELF::DT_MIPS_PLTGOT, pFormat.getGOTPLT().addr());
applyOne(DT_MIPS_PLTGOT, pFormat.getGOTPLT().addr());
}

size_t MipsELFDynamic::getSymTabNum(const ELFFileFormat& pFormat) const
Expand Down

0 comments on commit c8d3dd2

Please sign in to comment.