diff options
Diffstat (limited to 'lib/Target/X86')
-rw-r--r-- | lib/Target/X86/X86GOT.cpp | 12 | ||||
-rw-r--r-- | lib/Target/X86/X86GOT.h | 12 | ||||
-rw-r--r-- | lib/Target/X86/X86GOTPLT.cpp | 14 | ||||
-rw-r--r-- | lib/Target/X86/X86GOTPLT.h | 14 | ||||
-rw-r--r-- | lib/Target/X86/X86LDBackend.cpp | 23 | ||||
-rw-r--r-- | lib/Target/X86/X86PLT.cpp | 26 | ||||
-rw-r--r-- | lib/Target/X86/X86PLT.h | 25 | ||||
-rw-r--r-- | lib/Target/X86/X86RelocationFactory.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/X86SectLinker.cpp | 1 |
9 files changed, 81 insertions, 50 deletions
diff --git a/lib/Target/X86/X86GOT.cpp b/lib/Target/X86/X86GOT.cpp index 91c7d65..518cc36 100644 --- a/lib/Target/X86/X86GOT.cpp +++ b/lib/Target/X86/X86GOT.cpp @@ -7,9 +7,14 @@ // //===----------------------------------------------------------------------===// #include "X86GOT.h" + +#include <new> + +#include <llvm/Support/Casting.h> + #include <mcld/LD/LDFileFormat.h> +#include <mcld/LD/SectionData.h> #include <mcld/Support/MsgHandling.h> -#include <new> namespace { const size_t X86GOTEntrySize = 4; @@ -19,7 +24,8 @@ using namespace mcld; //===----------------------------------------------------------------------===// // X86GOT -X86GOT::X86GOT(LDSection& pSection, llvm::MCSectionData& pSectionData) +//===----------------------------------------------------------------------===// +X86GOT::X86GOT(LDSection& pSection, SectionData& pSectionData) : GOT(pSection, pSectionData, X86GOTEntrySize), m_GOTIterator(), m_fIsVisit(false) { @@ -38,7 +44,7 @@ void X86GOT::reserveEntry(size_t pNum) &m_SectionData); if (!Entry) - fatal(diag::fail_allocate_memory) << "GOTEntry"; + fatal(diag::fail_allocate_memory_got); m_Section.setSize(m_Section.size() + X86GOTEntrySize); } diff --git a/lib/Target/X86/X86GOT.h b/lib/Target/X86/X86GOT.h index d758de0..91cc3e8 100644 --- a/lib/Target/X86/X86GOT.h +++ b/lib/Target/X86/X86GOT.h @@ -6,14 +6,16 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#ifndef MCLD_X86_GOT_H -#define MCLD_X86_GOT_H +#ifndef MCLD_TARGET_X86_GOT_H +#define MCLD_TARGET_X86_GOT_H #ifdef ENABLE_UNITTEST #include <gtest.h> #endif #include "X86PLT.h" + #include <mcld/Target/GOT.h> +#include <mcld/LD/SectionData.h> namespace mcld { @@ -28,11 +30,11 @@ class X86GOT : public GOT typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType; public: - typedef llvm::MCSectionData::iterator iterator; - typedef llvm::MCSectionData::const_iterator const_iterator; + typedef SectionData::iterator iterator; + typedef SectionData::const_iterator const_iterator; public: - X86GOT(LDSection& pSection, llvm::MCSectionData& pSectionData); + X86GOT(LDSection& pSection, SectionData& pSectionData); ~X86GOT(); diff --git a/lib/Target/X86/X86GOTPLT.cpp b/lib/Target/X86/X86GOTPLT.cpp index 2ba5669..49f3449 100644 --- a/lib/Target/X86/X86GOTPLT.cpp +++ b/lib/Target/X86/X86GOTPLT.cpp @@ -6,10 +6,15 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #include "X86GOTPLT.h" + +#include <new> + +#include <llvm/Support/Casting.h> + #include <mcld/LD/LDFileFormat.h> #include <mcld/Support/MsgHandling.h> -#include <new> namespace { const uint64_t X86GOTPLTEntrySize = 4; @@ -19,7 +24,8 @@ namespace mcld { //===----------------------------------------------------------------------===// // X86GOTPLT -X86GOTPLT::X86GOTPLT(LDSection& pSection, llvm::MCSectionData& pSectionData) +//===----------------------------------------------------------------------===// +X86GOTPLT::X86GOTPLT(LDSection& pSection, SectionData& pSectionData) : GOT(pSection, pSectionData, X86GOTPLTEntrySize), m_GOTPLTIterator() { GOTEntry* Entry = 0; @@ -30,7 +36,7 @@ X86GOTPLT::X86GOTPLT(LDSection& pSection, llvm::MCSectionData& pSectionData) &m_SectionData); if (!Entry) - fatal(diag::fail_allocate_memory) << "GOT0"; + fatal(diag::fail_allocate_memory_got); m_Section.setSize(m_Section.size() + X86GOTPLTEntrySize); } @@ -84,7 +90,7 @@ void X86GOTPLT::reserveEntry(size_t pNum) for (size_t i = 0; i < pNum; ++i) { got_entry = new GOTEntry(0, getEntrySize(),&(getSectionData())); if (!got_entry) - fatal(diag::fail_allocate_memory) << "GOT"; + fatal(diag::fail_allocate_memory_got); m_Section.setSize(m_Section.size() + getEntrySize()); } diff --git a/lib/Target/X86/X86GOTPLT.h b/lib/Target/X86/X86GOTPLT.h index ae9f0f7..7ca695b 100644 --- a/lib/Target/X86/X86GOTPLT.h +++ b/lib/Target/X86/X86GOTPLT.h @@ -12,28 +12,30 @@ #include <gtest.h> #endif +#include <llvm/ADT/DenseMap.h> + #include <mcld/Target/GOT.h> +#include <mcld/LD/SectionData.h> namespace mcld { class LDSection; +const unsigned int X86GOTPLT0Num = 3; + /** \class X86GOTPLT * \brief X86 .got.plt section. */ - -const unsigned int X86GOTPLT0Num = 3; - class X86GOTPLT : public GOT { typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType; public: - typedef llvm::MCSectionData::iterator iterator; - typedef llvm::MCSectionData::const_iterator const_iterator; + typedef SectionData::iterator iterator; + typedef SectionData::const_iterator const_iterator; public: - X86GOTPLT(LDSection &pSection, llvm::MCSectionData& pSectionData); + X86GOTPLT(LDSection &pSection, SectionData& pSectionData); ~X86GOTPLT(); diff --git a/lib/Target/X86/X86LDBackend.cpp b/lib/Target/X86/X86LDBackend.cpp index 2355afc..d02e621 100644 --- a/lib/Target/X86/X86LDBackend.cpp +++ b/lib/Target/X86/X86LDBackend.cpp @@ -13,11 +13,14 @@ #include "X86RelocationFactory.h" #include <llvm/ADT/Triple.h> +#include <llvm/Support/Casting.h> + #include <mcld/LD/SectionMap.h> +#include <mcld/LD/FillFragment.h> +#include <mcld/LD/RegionFragment.h> #include <mcld/MC/MCLDInfo.h> #include <mcld/MC/MCLDOutput.h> #include <mcld/MC/MCLinker.h> -#include <mcld/MC/MCRegionFragment.h> #include <mcld/Support/MemoryRegion.h> #include <mcld/Support/MsgHandling.h> #include <mcld/Support/TargetRegistry.h> @@ -106,7 +109,7 @@ const X86ELFDynamic& X86GNULDBackend::dynamic() const void X86GNULDBackend::createX86GOT(MCLinker& pLinker, const Output& pOutput) { - // get .got LDSection and create MCSectionData + // get .got LDSection and create SectionData ELFFileFormat* file_format = getOutputFormat(pOutput); LDSection& got = file_format->getGOT(); @@ -115,7 +118,7 @@ void X86GNULDBackend::createX86GOT(MCLinker& pLinker, const Output& pOutput) void X86GNULDBackend::createX86GOTPLT(MCLinker& pLinker, const Output& pOutput) { - // get .got.plt LDSection and create MCSectionData + // get .got.plt LDSection and create SectionData ELFFileFormat* file_format = getOutputFormat(pOutput); LDSection& gotplt = file_format->getGOTPLT(); @@ -158,12 +161,12 @@ void X86GNULDBackend::createX86PLTandRelPLT(MCLinker& pLinker, LDSection& plt = file_format->getPLT(); LDSection& relplt = file_format->getRelPlt(); assert(m_pGOTPLT != NULL); - // create MCSectionData and X86PLT + // create SectionData and X86PLT m_pPLT = new X86PLT(plt, pLinker.getOrCreateSectData(plt), *m_pGOTPLT, pOutput); // set info of .rel.plt to .plt relplt.setLink(&plt); - // create MCSectionData and X86RelDynSection + // create SectionData and X86RelDynSection m_pRelPLT = new OutputRelocSection(relplt, pLinker.getOrCreateSectData(relplt), 8); @@ -172,11 +175,11 @@ void X86GNULDBackend::createX86PLTandRelPLT(MCLinker& pLinker, void X86GNULDBackend::createX86RelDyn(MCLinker& pLinker, const Output& pOutput) { - // get .rel.dyn LDSection and create MCSectionData + // get .rel.dyn LDSection and create SectionData ELFFileFormat* file_format = getOutputFormat(pOutput); LDSection& reldyn = file_format->getRelDyn(); - // create MCSectionData and X86RelDynSection + // create SectionData and X86RelDynSection m_pRelDyn = new OutputRelocSection(reldyn, pLinker.getOrCreateSectData(reldyn), 8); @@ -215,9 +218,9 @@ LDSymbol& X86GNULDBackend::defineSymbolforCopyReloc(MCLinker& pLinker, llvm::ELF::SHF_WRITE | llvm::ELF::SHF_ALLOC); } - // get or create corresponding BSS MCSectionData + // get or create corresponding BSS SectionData assert(NULL != bss_sect_hdr); - llvm::MCSectionData& bss_section = pLinker.getOrCreateSectData( + SectionData& bss_section = pLinker.getOrCreateSectData( *bss_sect_hdr); // Determine the alignment by the symbol value @@ -225,7 +228,7 @@ LDSymbol& X86GNULDBackend::defineSymbolforCopyReloc(MCLinker& pLinker, uint32_t addralign = bitclass() / 8; // allocate space in BSS for the copy symbol - llvm::MCFragment* frag = new llvm::MCFillFragment(0x0, 1, pSym.size()); + Fragment* frag = new FillFragment(0x0, 1, pSym.size()); uint64_t size = pLinker.getLayout().appendFragment(*frag, bss_section, addralign); diff --git a/lib/Target/X86/X86PLT.cpp b/lib/Target/X86/X86PLT.cpp index 2396a21..cbdb568 100644 --- a/lib/Target/X86/X86PLT.cpp +++ b/lib/Target/X86/X86PLT.cpp @@ -1,4 +1,4 @@ -//===- X86PLT.cpp -----------------------------------------------------------===// +//===- X86PLT.cpp ---------------------------------------------------------===// // // The MCLinker Project // @@ -8,12 +8,18 @@ //===----------------------------------------------------------------------===// #include "X86GOTPLT.h" #include "X86PLT.h" -#include <llvm/Support/raw_ostream.h> + +#include <new> + #include <llvm/Support/ELF.h> +#include <llvm/Support/Casting.h> + #include <mcld/MC/MCLDOutput.h> #include <mcld/Support/MsgHandling.h> -#include <new> +//===----------------------------------------------------------------------===// +// PLT entry data +//===----------------------------------------------------------------------===// namespace { const uint8_t x86_dyn_plt0[] = { @@ -44,17 +50,17 @@ const uint8_t x86_exec_plt1[] = { namespace mcld { -X86PLT0::X86PLT0(llvm::MCSectionData* pParent, unsigned int pSize) +X86PLT0::X86PLT0(SectionData* pParent, unsigned int pSize) : PLTEntry(pSize, pParent) { } -X86PLT1::X86PLT1(llvm::MCSectionData* pParent, unsigned int pSize) +X86PLT1::X86PLT1(SectionData* pParent, unsigned int pSize) : PLTEntry(pSize, pParent) { } //===----------------------------------------------------------------------===// // X86PLT - +//===----------------------------------------------------------------------===// X86PLT::X86PLT(LDSection& pSection, - llvm::MCSectionData& pSectionData, + SectionData& pSectionData, X86GOTPLT &pGOTPLT, const Output& pOutput) : PLT(pSection, pSectionData), @@ -94,7 +100,7 @@ void X86PLT::reserveEntry(size_t pNum) plt1_entry = new (std::nothrow) X86PLT1(&m_SectionData, m_PLT1Size); if (!plt1_entry) - fatal(diag::fail_allocate_memory) << "X86PLT1"; + fatal(diag::fail_allocate_memory_plt); m_Section.setSize(m_Section.size() + plt1_entry->getEntrySize()); @@ -152,7 +158,7 @@ void X86PLT::applyPLT0() { data = static_cast<unsigned char*>(malloc(plt0->getEntrySize())); if (!data) - fatal(diag::fail_allocate_memory) << "plt0"; + fatal(diag::fail_allocate_memory_plt); memcpy(data, m_PLT0, plt0->getEntrySize()); @@ -200,7 +206,7 @@ void X86PLT::applyPLT1() { data = static_cast<unsigned char*>(malloc(plt1->getEntrySize())); if (!data) - fatal(diag::fail_allocate_memory) << "plt1"; + fatal(diag::fail_allocate_memory_plt); memcpy(data, m_PLT1, plt1->getEntrySize()); diff --git a/lib/Target/X86/X86PLT.h b/lib/Target/X86/X86PLT.h index 6c7002a..1669a49 100644 --- a/lib/Target/X86/X86PLT.h +++ b/lib/Target/X86/X86PLT.h @@ -1,4 +1,4 @@ -//===- X86PLT.h -----------------------------------------------------===// +//===- X86PLT.h -----------------------------------------------------------===// // // The MCLinker Project // @@ -6,10 +6,13 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#ifndef X86_PLT_H -#define X86_PLT_H +#ifndef MCLD_TARGET_X86_PLT_H +#define MCLD_TARGET_X86_PLT_H + +#include <llvm/ADT/DenseMap.h> #include <mcld/Target/PLT.h> +#include <mcld/LD/SectionData.h> namespace mcld { @@ -17,14 +20,16 @@ class X86GOTPLT; class GOTEntry; class Output; -class X86PLT0 : public PLTEntry { +class X86PLT0 : public PLTEntry +{ public: - X86PLT0(llvm::MCSectionData* pParent, unsigned int pSize); + X86PLT0(SectionData* pParent, unsigned int pSize); }; -class X86PLT1 : public PLTEntry { +class X86PLT1 : public PLTEntry +{ public: - X86PLT1(llvm::MCSectionData* pParent, unsigned int pSize); + X86PLT1(SectionData* pParent, unsigned int pSize); }; /** \class X86PLT @@ -35,12 +40,12 @@ class X86PLT : public PLT typedef llvm::DenseMap<const ResolveInfo*, X86PLT1*> SymbolIndexType; public: - typedef llvm::MCSectionData::iterator iterator; - typedef llvm::MCSectionData::const_iterator const_iterator; + typedef SectionData::iterator iterator; + typedef SectionData::const_iterator const_iterator; public: X86PLT(LDSection& pSection, - llvm::MCSectionData& pSectionData, + SectionData& pSectionData, X86GOTPLT& pGOTPLT, const Output& pOutput); ~X86PLT(); diff --git a/lib/Target/X86/X86RelocationFactory.cpp b/lib/Target/X86/X86RelocationFactory.cpp index 71fa344..f603b6e 100644 --- a/lib/Target/X86/X86RelocationFactory.cpp +++ b/lib/Target/X86/X86RelocationFactory.cpp @@ -132,7 +132,7 @@ GOTEntry& helper_get_GOT_and_init(Relocation& pReloc, rel_entry.targetRef().assign(got_entry); } else { - fatal(diag::reserve_entry_number_mismatch) << "GOT"; + fatal(diag::reserve_entry_number_mismatch_got); } } return got_entry; @@ -182,7 +182,7 @@ PLTEntry& helper_get_PLT_and_init(Relocation& pReloc, rel_entry.setSymInfo(rsym); } else { - fatal(diag::reserve_entry_number_mismatch) << "PLT"; + fatal(diag::reserve_entry_number_mismatch_plt); } } return plt_entry; diff --git a/lib/Target/X86/X86SectLinker.cpp b/lib/Target/X86/X86SectLinker.cpp index a888f47..2954d1f 100644 --- a/lib/Target/X86/X86SectLinker.cpp +++ b/lib/Target/X86/X86SectLinker.cpp @@ -47,3 +47,4 @@ extern "C" void LLVMInitializeX86SectLinker() { // Register the linker frontend mcld::TargetRegistry::RegisterSectLinker(TheX86Target, createX86SectLinker); } + |