Xcode 无法正确链接旧 SDK

发布于 2024-12-14 16:05:21 字数 914 浏览 4 评论 0原文

我对在 Mac OS 10.4 中使用 Xcode 2.2.0 构建的旧版 32 位 C 应用程序有疑问。它可以在更高版本(64位)系统(10.5及更高版本)上正确运行,但如果我尝试在10.5及更高版本上的更高版本Xcode(2.2.1 - 3.2.6)中构建它,它的行为会发生变化,即使我设置SDK 10.4 和 GCC 4.0 无处不在(在“项目设置”和“活动目标设置”中)。

有关更改行为的详细信息:通过 CFBundleGetFunctionPointerForName() 获取函数地址然后调用它们时,某些返回指针。然后:

  • 如果应用程序在 Mac OS 10.4 中的 Xcode 2.2.0 中编译,并在 10.5+ 中运行,则指针不能超过 LONG_MAX,因此有符号 long 足以存储调用结果。

  • 如果应用程序在 10.5+ 中的 Xcode 2.2.1+ 中编译并在 10.5+ 中运行,则指针可能在 LONG_MAX..ULONG_MAX 范围内。

将结果解释为有符号长整型至关重要,因为返回有符号长整型(而不是指针)的函数的调用方式完全相同。更改它会造成混乱,所以请不要建议拆分对返回指针的函数和立即返回结果的函数的调用 - 只有当我无法获得正确的构建时才会这样做。

构建行为的这种差异我只能解释为在运行时调用一些其他包,而不是较旧的构建会调用的 - 如果 1) CFBundle 库(调用函数)与实际 10.4 中的不同,或 2) 这是可能的系统正确地确定了旧版本的 SDK,并使用了正确的“向后兼容性”,但较新的程序设置中的某些内容是错误的,因此在运行时调用了其他捆绑包。

所以我想知道,Xcode 或其后端中是否有任何“隐藏”选项,这些选项会在真正的 10.4 构建和后续操作系统中针对 10.4 SDK 构建之间产生差异? 或者我如何寻找这些差异?

I have a problem with legacy 32-bit C application, built in Mac OS 10.4, with Xcode 2.2.0. It runs correctly on later (64-bit) systems (10.5 and later), but if I try to build it in later Xcode versions (2.2.1 - 3.2.6) on 10.5 and later, it's behavior changes, even though I set SDK 10.4 and GCC 4.0 everywhere (in "project settings" and "active target settings").

Details on changed behavior: when getting function addresses through CFBundleGetFunctionPointerForName() and then calling them, some return pointers. Then:

  • If application is compiled in Xcode 2.2.0 in Mac OS 10.4, and running in 10.5+, pointers could not exceed LONG_MAX, so signed long is sufficient for storing call result.

  • If application is compiled in Xcode 2.2.1+ in 10.5+ and running in 10.5+, pointers could be in range LONG_MAX..ULONG_MAX.

And interpreting result as signed long is essential, because functions, returning signed long (not pointers), are called exactly the same way. Changing it would be making a kludge, so please don't suggest splitting calls to functions that return pointers and functions that return result immediately - it would be done only if I cannot get a correct build.

This difference of builds' behavior I could explain only as calling in runtime some other bundles than an older build would call - and that is possible if 1) CFBundle library, which calls functions, is not the same as in real 10.4, or 2) system correctly determines SDK of an older build, and uses the correct "backward compatibility", but something in newer program settings is wrong, and so other bundle is called in runtime.

So I wonder, are there any "hidden" options in Xcode or its backends, that make a difference between real 10.4 build and build against 10.4 SDK in later OS?
Or how I can search for such differences?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文