diff --git a/llvm/test/tools/llvm-objcopy/tool-name.test b/llvm/test/tools/llvm-objcopy/tool-name.test
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/tool-name.test
@@ -0,0 +1,32 @@
+## Don't make symlinks on Windows.
+# UNSUPPORTED: system-windows
+
+# RUN: rm -rf %t
+# RUN: mkdir %t
+# RUN: ln -s llvm-strip %t/llvm-strip-11
+# RUN: ln -s llvm-strip %t/strip.exe
+
+# RUN: llvm-strip --help | FileCheck --check-prefix=STRIP %s
+# RUN: %t/llvm-strip-11 --help | FileCheck --check-prefix=STRIP %s
+# RUN: %t/strip.exe --help | FileCheck --check-prefix=STRIP %s
+
+# STRIP: OVERVIEW: llvm-strip tool
+
+# RUN: ln -s llvm-objcopy %t/llvm-objcopy-11
+# RUN: ln -s llvm-objcopy %t/objcopy.exe
+
+# RUN: llvm-objcopy --help | FileCheck --check-prefix=OBJCOPY %s
+# RUN: %t/llvm-objcopy-11 --help | FileCheck --check-prefix=OBJCOPY %s
+# RUN: %t/objcopy.exe --help | FileCheck --check-prefix=OBJCOPY %s
+
+# OBJCOPY: OVERVIEW: llvm-objcopy tool
+
+## This driver emulates install_name_tool on macOS.
+# RUN: ln -s llvm-install-name-tool %t/llvm-install-name-tool-11
+# RUN: ln -s llvm-install-name-tool %t/install_name_tool
+
+# RUN: llvm-install-name-tool --help | FileCheck --check-prefix=INSTALL %s
+# RUN: %t/llvm-install-name-tool-11 --help | FileCheck --check-prefix=INSTALL %s
+# RUN: %t/install_name_tool --help | FileCheck --check-prefix=INSTALL %s
+
+# INSTALL: OVERVIEW: llvm-install-name-tool tool
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -327,11 +327,19 @@
 int main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
-  ToolType Tool = StringSwitch<ToolType>(sys::path::stem(ToolName))
-                      .EndsWith("strip", ToolType::Strip)
-                      .EndsWith("install-name-tool", ToolType::InstallNameTool)
-                      .EndsWith("install_name_tool", ToolType::InstallNameTool)
-                      .Default(ToolType::Objcopy);
+
+  StringRef Stem = sys::path::stem(ToolName);
+  auto Is = [&](StringRef Tool) {
+    auto I = Stem.rfind_lower(Tool);
+    return I != StringRef::npos &&
+           (I + Tool.size() == Stem.size() || !isAlnum(Stem[I + Tool.size()]));
+  };
+  ToolType Tool = ToolType::Objcopy;
+  if (Is("strip"))
+    Tool = ToolType::Strip;
+  else if (Is("install-name-tool") || Is("install_name_tool"))
+    Tool = ToolType::InstallNameTool;
+
   // Expand response files.
   // TODO: Move these lines, which are copied from lib/Support/CommandLine.cpp,
   // into a separate function in the CommandLine library and call that function