CmdArgs.push_back("-ldl");
}
-static StringRef getLinuxDynamicLinker(const ArgList &Args,
- const toolchains::Linux &ToolChain) {
+static std::string getLinuxDynamicLinker(const ArgList &Args,
+ const toolchains::Linux &ToolChain) {
if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
if (ToolChain.getTriple().isArch64Bit())
return "/system/bin/linker64";
else
return "/lib/ld-linux.so.3"; /* TODO: check which dynamic linker name. */
} else if (ToolChain.getArch() == llvm::Triple::mips ||
- ToolChain.getArch() == llvm::Triple::mipsel) {
- if (mips::isNaN2008(Args, ToolChain.getTriple()))
- return "/lib/ld-linux-mipsn8.so.1";
- return "/lib/ld.so.1";
- } else if (ToolChain.getArch() == llvm::Triple::mips64 ||
+ ToolChain.getArch() == llvm::Triple::mipsel ||
+ ToolChain.getArch() == llvm::Triple::mips64 ||
ToolChain.getArch() == llvm::Triple::mips64el) {
- if (mips::hasMipsAbiArg(Args, "n32"))
- return mips::isNaN2008(Args, ToolChain.getTriple())
- ? "/lib32/ld-linux-mipsn8.so.1" : "/lib32/ld.so.1";
- return mips::isNaN2008(Args, ToolChain.getTriple())
- ? "/lib64/ld-linux-mipsn8.so.1" : "/lib64/ld.so.1";
+ StringRef CPUName;
+ StringRef ABIName;
+ mips::getMipsCPUAndABI(Args, ToolChain.getTriple(), CPUName, ABIName);
+ bool IsNaN2008 = mips::isNaN2008(Args, ToolChain.getTriple());
+
+ StringRef LibDir = llvm::StringSwitch<llvm::StringRef>(ABIName)
+ .Case("o32", "/lib")
+ .Case("n32", "/lib32")
+ .Case("n64", "/lib64")
+ .Default("/lib");
+ StringRef LibName = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
+
+ return (LibDir + "/" + LibName).str();
} else if (ToolChain.getArch() == llvm::Triple::ppc)
return "/lib/ld.so.1";
else if (ToolChain.getArch() == llvm::Triple::ppc64) {