aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/Mips/MipsTargetObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/Mips/MipsTargetObjectFile.cpp')
-rw-r--r--lib/Target/Mips/MipsTargetObjectFile.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsTargetObjectFile.cpp b/lib/Target/Mips/MipsTargetObjectFile.cpp
index 04dc60aa6b..e91b2d811f 100644
--- a/lib/Target/Mips/MipsTargetObjectFile.cpp
+++ b/lib/Target/Mips/MipsTargetObjectFile.cpp
@@ -37,6 +37,23 @@ void MipsTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
ELF::SHF_WRITE |ELF::SHF_ALLOC,
SectionKind::getBSS());
+ // @LOCALMOD-BEGIN
+ // Without this the linker defined symbols __fini_array_start and
+ // __fini_array_end do not have useful values. c.f.:
+ // http://code.google.com/p/nativeclient/issues/detail?id=805
+ if (TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) {
+ StaticCtorSection =
+ getContext().getELFSection(".init_array", ELF::SHT_INIT_ARRAY,
+ ELF::SHF_WRITE |
+ ELF::SHF_ALLOC,
+ SectionKind::getDataRel());
+ StaticDtorSection =
+ getContext().getELFSection(".fini_array", ELF::SHT_FINI_ARRAY,
+ ELF::SHF_WRITE |
+ ELF::SHF_ALLOC,
+ SectionKind::getDataRel());
+ }
+ // @LOCALMOD-END
}
// A address must be loaded from a small section if its size is less than the
@@ -65,6 +82,12 @@ IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
if (Subtarget.isLinux())
return false;
+ // @LOCALMOD-BEGIN
+ // Do not use small section for NaCl.
+ if (Subtarget.isTargetNaCl())
+ return false;
+ // @LOCALMOD-BEGIN
+
// Only global variables, not functions.
const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
if (!GVA)