[lld-macho] Find objects in library search path (#78628)

Find object files in library search path just like Apple's linker, this
makes building with some older MacOS SDKs easier since clang runs with
`-lcrt1.10.6.o`

GitOrigin-RevId: 46a9135d61f729da90b88d3d34a3905c91d194d7
diff --git a/MachO/Driver.cpp b/MachO/Driver.cpp
index 401459a..7ac3f51 100644
--- a/MachO/Driver.cpp
+++ b/MachO/Driver.cpp
@@ -90,6 +90,10 @@
     return entry->second;
 
   auto doFind = [&] {
+    // Special case for Csu support files required for Mac OS X 10.7 and older
+    // (crt1.o)
+    if (name.ends_with(".o"))
+      return findPathCombination(name, config->librarySearchPaths, {""});
     if (config->searchDylibsFirst) {
       if (std::optional<StringRef> path =
               findPathCombination("lib" + name, config->librarySearchPaths,
diff --git a/test/MachO/link-csu-object.s b/test/MachO/link-csu-object.s
new file mode 100644
index 0000000..e6f5ff7
--- /dev/null
+++ b/test/MachO/link-csu-object.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s -o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out
+# RUN: llvm-nm %t/a.out | FileCheck %s
+
+# CHECK: _main
+# CHECK: _print_hello
+
+.globl _main
+_main:
+    call _print_hello
+    ret