diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1988,10 +1988,16 @@ GlobalVariable::ExternalLinkage, nullptr, "__stack_chk_guard"); - // FreeBSD has "__stack_chk_guard" defined externally on libc.so + // XXX -- needs more investigation + // FreeBSD userland has "__stack_chk_guard" defined externally on libc.so, + // so not dso_local. Kernel modules are compiled in freestanding mode, it + // can be considered dso_local. For unknown reasons set dso_local here + // breaks PPC64 userland binaries (see bug #51590). + // However, FreeBSD amd64 kernel and modules are broken if dso_local + // is not set here, while PCC64 kernel and modules are fine without it. if (TM.getRelocationModel() == Reloc::Static && !TM.getTargetTriple().isWindowsGNUEnvironment() && - !TM.getTargetTriple().isOSFreeBSD()) + !(TM.getTargetTriple().isPPC64() && TM.getTargetTriple().isOSFreeBSD())) GV->setDSOLocal(true); } }