XCode 4.5 builds invalid 32-bit kext binaries

Originator:phil
Number:rdar://12353507 Date Originated:22-Sep-2012 09:56 PM
Status:Open Resolved:
Product:Developer Tools Product Version:4.5
Classification:Serious Bug Reproducible:Always
 
Summary:
i386 kernel extension binaries built by XCode 4.5 contain the loader commands LC_DATA_IN_CODE and LC_FUNCTION_STARTS. Neither of these is supported by kxld in kernels older than OSX 10.8. The kexts built this way are therefore rejected by OSX Lion, Snow Leopard, etc.

Steps to Reproduce:
- Open XCode
- File -> New -> Project…
- Choose "I/O Kit Driver"
- Complete the assistant
- Set the target's deployment target to 10.7 or earlier
- Set architectures to Intel 32/64-bit.
- Build the 32-bit version (or a fat 32+64-bit binary)
- Run the terminal command:
otool -lV -arch i386 /path/to/kext/Contents/MacOS/binary_name

Expected Results:
No unsupported commands should be listed.

Actual Results:
Near the end, LC_DATA_IN_CODE and LC_FUNCTION_STARTS commands are present.

Regression:
If you open and build the same project using XCode 4.4.1 or earlier, the produced kexts are fine.

Notes:
- It does not matter whether XCode 4.5 is running on OS X 10.7 or 10.8, the produced kexts are always bad.
- The 64-bit versions are not affected and do not contain the relevant commands.
- An affected "fat" kext can be loaded on a 64-bit system, but it seems to interfere with kernel prelinking.
- Relevant thread in the darwin-kernel mailing list: http://lists.apple.com/archives/darwin-kernel/2012/Sep/msg00025.html

Comments

Fixed as for me with 4.6 (4H127).

Update from Apple

29-Nov-2012 06:37 PM Apple Developer Bug Reporting Team :

We believe this issue has been addressed in the latest Xcode 4.6 Developer Preview.

This is a pre-release version of the Xcode developer toolset for Mac, iPhone, and iPad. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building OS X and iOS apps.  Please verify with this release, and update your bug report with the results.  

Xcode 4.6 Build 4H95e

Posted Date: November 12, 2012

Mac Developers: Log in to the Developer site at https://developer.apple.com/devcenter/mac/index.action

iOS Developers: Log in to the Developer site at https://developer.apple.com/devcenter/ios/index.action# (and click on 'iOS 6.1 SDK beta' tab)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!