MCLinker upstream commit 9628cfb76b5a.
Change-Id: I6d12c63bdae94299558dc1cf42b489bb98748851
diff --git a/lib/Target/Mips/MipsLDBackend.cpp b/lib/Target/Mips/MipsLDBackend.cpp
index 87e43b8..e8b68ea 100644
--- a/lib/Target/Mips/MipsLDBackend.cpp
+++ b/lib/Target/Mips/MipsLDBackend.cpp
@@ -7,9 +7,15 @@
//
//===----------------------------------------------------------------------===//
+#include "Mips.h"
+#include "MipsELFDynamic.h"
+#include "MipsLDBackend.h"
+#include "MipsRelocationFactory.h"
+
#include <llvm/ADT/Triple.h>
#include <llvm/Support/ELF.h>
+#include <mcld/LD/FillFragment.h>
#include <mcld/LD/SectionMap.h>
#include <mcld/MC/MCLDInfo.h>
#include <mcld/MC/MCLinker.h>
@@ -18,11 +24,6 @@
#include <mcld/Support/TargetRegistry.h>
#include <mcld/Target/OutputRelocSection.h>
-#include "Mips.h"
-#include "MipsELFDynamic.h"
-#include "MipsLDBackend.h"
-#include "MipsRelocationFactory.h"
-
enum {
// The original o32 abi.
E_MIPS_ABI_O32 = 0x00001000,
@@ -67,21 +68,6 @@
void MipsGNULDBackend::initTargetSections(MCLinker& pLinker)
{
- // Set up .dynamic
- ELFFileFormat* file_format = NULL;
- switch(pLinker.getLDInfo().output().type()) {
- case Output::DynObj:
- file_format = getDynObjFileFormat();
- break;
- case Output::Exec:
- file_format = getExecFileFormat();
- break;
- case Output::Object:
- default:
- // TODO: not support yet
- return;
- }
- file_format->getDynamic().setFlag(llvm::ELF::SHF_ALLOC);
}
void MipsGNULDBackend::initTargetSymbols(MCLinker& pLinker, const Output& pOutput)
@@ -213,6 +199,14 @@
return 0x80000;
}
+uint64_t MipsGNULDBackend::abiPageSize(const MCLDInfo& pInfo) const
+{
+ if (pInfo.options().maxPageSize() > 0)
+ return pInfo.options().maxPageSize();
+ else
+ return static_cast<uint64_t>(0x10000);
+}
+
void MipsGNULDBackend::doPreLayout(const Output& pOutput,
const MCLDInfo& pInfo,
MCLinker& pLinker)
@@ -498,7 +492,8 @@
/// finalizeSymbol - finalize the symbol value
bool MipsGNULDBackend::finalizeTargetSymbols(MCLinker& pLinker, const Output& pOutput)
{
- m_pGpDispSymbol->setValue(m_pGOT->getSection().addr() + 0x7FF0);
+ if (NULL != m_pGpDispSymbol)
+ m_pGpDispSymbol->setValue(m_pGOT->getSection().addr() + 0x7FF0);
return true;
}
@@ -550,9 +545,9 @@
assert(NULL != bss_sect && NULL != tbss_sect);
- // get or create corresponding BSS MCSectionData
- llvm::MCSectionData& bss_sect_data = pLinker.getOrCreateSectData(*bss_sect);
- llvm::MCSectionData& tbss_sect_data = pLinker.getOrCreateSectData(*tbss_sect);
+ // get or create corresponding BSS SectionData
+ SectionData& bss_sect_data = pLinker.getOrCreateSectData(*bss_sect);
+ SectionData& tbss_sect_data = pLinker.getOrCreateSectData(*tbss_sect);
// remember original BSS size
uint64_t bss_offset = bss_sect->size();
@@ -569,8 +564,8 @@
// when emitting the regular name pools. We must change the symbols'
// description here.
(*com_sym)->resolveInfo()->setDesc(ResolveInfo::Define);
- llvm::MCFragment* frag = new llvm::MCFillFragment(0x0, 1, (*com_sym)->size());
- (*com_sym)->setFragmentRef(new MCFragmentRef(*frag, 0));
+ Fragment* frag = new FillFragment(0x0, 1, (*com_sym)->size());
+ (*com_sym)->setFragmentRef(new FragmentRef(*frag, 0));
if (ResolveInfo::ThreadLocal == (*com_sym)->type()) {
// allocate TLS common symbol in tbss section
@@ -596,8 +591,8 @@
// when emitting the regular name pools. We must change the symbols'
// description here.
(*com_sym)->resolveInfo()->setDesc(ResolveInfo::Define);
- llvm::MCFragment* frag = new llvm::MCFillFragment(0x0, 1, (*com_sym)->size());
- (*com_sym)->setFragmentRef(new MCFragmentRef(*frag, 0));
+ Fragment* frag = new FillFragment(0x0, 1, (*com_sym)->size());
+ (*com_sym)->setFragmentRef(new FragmentRef(*frag, 0));
if (ResolveInfo::ThreadLocal == (*com_sym)->type()) {
// allocate TLS common symbol in tbss section
@@ -879,9 +874,9 @@
{
ELFFileFormat* file_format = getOutputFormat(pOutput);
- // get .rel.dyn LDSection and create MCSectionData
+ // get .rel.dyn LDSection and create SectionData
LDSection& reldyn = file_format->getRelDyn();
- // create MCSectionData and ARMRelDynSection
+ // create SectionData and ARMRelDynSection
m_pRelDyn = new OutputRelocSection(reldyn,
pLinker.getOrCreateSectData(reldyn),
8);