Index: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -91,8 +91,12 @@ MCCodeGenInfo *X = new MCCodeGenInfo(); if (CM == CodeModel::JITDefault) RM = Reloc::Static; - else if (RM == Reloc::Default) - RM = Reloc::PIC_; + else if (RM == Reloc::Default) { + if (Triple(TT).isOSNaCl()) + RM = Reloc::Static; + else + RM = Reloc::PIC_; + } X->InitMCCodeGenInfo(RM, CM, OL); return X; } Index: test/CodeGen/Mips/longbranch.ll =================================================================== --- test/CodeGen/Mips/longbranch.ll +++ test/CodeGen/Mips/longbranch.ll @@ -7,8 +7,8 @@ ; RUN: < %s | FileCheck %s -check-prefix=N64 ; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=micromips \ ; RUN: -force-mips-long-branch -O3 < %s | FileCheck %s -check-prefix=MICROMIPS -; RUN: llc -mtriple=mipsel-none-nacl -force-mips-long-branch -O3 < %s \ -; RUN: | FileCheck %s -check-prefix=NACL +; RUN: llc -mtriple=mipsel-none-nacl -relocation-model=pic \ +; RUN: -force-mips-long-branch -O3 < %s | FileCheck %s -check-prefix=NACL @x = external global i32 Index: test/CodeGen/Mips/relocation-model.ll =================================================================== --- /dev/null +++ test/CodeGen/Mips/relocation-model.ll @@ -0,0 +1,7 @@ +; RUN: llc -filetype=obj -mtriple=mipsel-none-linux < %s -o - | llvm-readobj -h | FileCheck -check-prefix=PIC %s +; RUN: llc -filetype=obj -mtriple=mipsel-none-nacl < %s -o - | llvm-readobj -h | FileCheck -check-prefix=STATIC %s + +; Check MIPS llc default relocation model. +; For NaCl target it is static, otherwise it is pic. +; PIC: EF_MIPS_PIC +; STATIC-NOT: EF_MIPS_PIC