]> git.saurik.com Git - apple/ld64.git/blobdiff - src/ld/parsers/textstub_dylib_file.cpp
ld64-278.4.tar.gz
[apple/ld64.git] / src / ld / parsers / textstub_dylib_file.cpp
index 585446254e6bc3b33b4646e1f3d11a976c730900..0b83d410959e4e7a0b56c5a3e045f717438c8ec0 100644 (file)
@@ -108,14 +108,39 @@ template <typename A>
        : Base(strdup(path), mTime, ord, platform, linkMinOSVersion, allowWeakImports, linkingFlatNamespace,
                   hoistImplicitPublicDylibs, allowSimToMacOSX, addVers)
 {
+       std::unique_ptr<tapi::LinkerInterfaceFile> file;
+       std::string errorMessage;
+
+// <rdar://problem/29038544> Support $ld$weak symbols in .tbd files
+#if ((TAPI_API_VERSION_MAJOR == 1 &&  TAPI_API_VERSION_MINOR >= 1) || (TAPI_API_VERSION_MAJOR > 1))
+       // Check if the library supports the new create API.
+       if (tapi::APIVersion::isAtLeast(1, 1)) {
+               tapi::ParsingFlags flags = tapi::ParsingFlags::None;
+               if (enforceDylibSubtypesMatch)
+                       flags |= tapi::ParsingFlags::ExactCpuSubType;
+
+               if (!allowWeakImports)
+                       flags |= tapi::ParsingFlags::DisallowWeakImports;
+
+               file.reset(tapi::LinkerInterfaceFile::create(
+                       path, fileContent, fileLength, cpuType, cpuSubType, flags,
+                       tapi::PackedVersion32(linkMinOSVersion), errorMessage));
+       } else {
+               auto matchingType = enforceDylibSubtypesMatch ?
+                               tapi::CpuSubTypeMatching::Exact : tapi::CpuSubTypeMatching::ABI_Compatible;
+
+               file.reset(tapi::LinkerInterfaceFile::create(
+                       path, fileContent, fileLength, cpuType, cpuSubType, matchingType,
+                       tapi::PackedVersion32(linkMinOSVersion), errorMessage));
+       }
+#else
        auto matchingType = enforceDylibSubtypesMatch ?
-                       tapi::CpuSubTypeMatching::Exact : tapi::CpuSubTypeMatching::ABI_Compatible;
+               tapi::CpuSubTypeMatching::Exact : tapi::CpuSubTypeMatching::ABI_Compatible;
 
-       std::string errorMessage;
-       auto file = std::unique_ptr<tapi::LinkerInterfaceFile>(
-               tapi::LinkerInterfaceFile::create(path, fileContent, fileLength, cpuType,
-                                                                                 cpuSubType, matchingType,
-                                                                                 tapi::PackedVersion32(linkMinOSVersion), errorMessage));
+       file.reset(tapi::LinkerInterfaceFile::create(
+               path, fileContent, fileLength, cpuType, cpuSubType, matchingType,
+               tapi::PackedVersion32(linkMinOSVersion), errorMessage));
+#endif
 
        if (file == nullptr)
                throw strdup(errorMessage.c_str());