-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class-dump XCFramework only creates library for ios-arm64_x86_64-simulator #409
Comments
I see two alternatives here:
As a general note, I would add that when dealing with Private Frameworks, there is no guarantee that an XCFW will be portable between architectures, platforms, or different OS versions. You are only guaranteed to have 100% reliability when generating an XCFW in the same system you intend to use it, while being aware that OS updates may break it. |
I think we can provide both solutions by adding an extra flag to WDYT, @blacktop? |
ya I always like to lean on the side of less flags (as I've found that people don't really read the docs/help 😏 but for this weird edge case a flag might make the most sense for those that accept the possible errors of a generic tbd but as I mentioned in your PR, that we could chose the correct platform subset based on the ARCH/platform of the DSC for the non-generic case, but not 💯 about old DSCs |
I'll take a look at this in the weekend |
@Meowcat285 @t0rr3sp3dr0 do you know what the structure of an XCFramework would be that supports macOS as well? Is it a separate folder or can I just append macos to the from of |
So I just pushed out a release that I "believe" creates much more accurate XCFrameworks, however, this also means that it will only make them for the We can work on adding 'generic' XCFrameworks too, I just think there's an edge case where the class-dump headers and the .tbd symbols wouldn't match. You can see in the This is a pretty complex issue 😩 I STILL think I need more examples of good XCFrameworks to use to make sure I'm filling out all the required Info.plist fields etc. |
I think to make a BIG generic XCFramework we'd need to supply it with the DSCes from an macOS IPSW which would have |
Please at least try and use the output and let me know if it actually compiles and is useful and has code-completions when calling into the private ObjC funcs etc @NSAntoine if you have any time I'd love your input as well 🙏 |
The entire DSC? or just the binary of the specified lib/framework? can't you extract just one specific lib from a DSC? |
Ya, 'extracting' from the DSC is sooooooooo 2019 😏 now we just analyze the DSC as a whole. But my comment was that is the output product that XCFramework consumer REALLY want is a generic one that supports all teh things, then the input to |
Lying about that sounds like a bad idea in theory, I think an option to specify the targets would be best here |
@NSAntoine have you tried the |
The next |
Haven't, been really really busy w studying, I could after ~may 16 |
package.swift generation?? |
Ya I understand and there's no real rush. tx ❤️ |
ya I supposed there's REALLY nothing to it other than filling out a few fields, with the XCFramework being the My idea is that I would create a NEW github org and it's output would be SPMs for the popular FWs so people could just import then and use them like any other Swift pkg? |
I don't know if this is the recommended way, but take a look at mdk.xcframework
├── Info.plist
├── _CodeSignature
│ └── ...
├── ios-arm64
│ └── mdk.framework
│ └── ...
├── ios-arm64_x86_64-maccatalyst
│ └── mdk.framework
│ └── ...
├── ios-arm64_x86_64-simulator
│ └── mdk.framework
│ └── ...
├── macos-arm64_x86_64
│ └── mdk.framework
│ └── ...
├── tvos-arm64
│ └── mdk.framework
│ └── ...
├── tvos-arm64_x86_64-simulator
│ └── mdk.framework
│ └── ...
├── xros-arm64
│ └── mdk.framework
│ └── ...
└── xros-arm64_x86_64-simulator
└── mdk.framework
└── ... |
I'll try the new version during this week and let you know |
That would be amazing. I'm personally using these XCFWs with SwiftPM and would love not have to generate them manually and store them together with the source code. |
About the generic XCFW, I now believe that's not a good idea unless you provide the DSC for all architectures and systems. I was debugging the Objective-C type encoding in go-macho and found out that I also learned that Similar to So if we have this class: @implementation C : NSObject
- (void)b:(BOOL)b {
}
- (void)l:(long)l {
}
- (void)ld:(long double)ld {
}
@end We may decompile it to this: @interface C : NSObject
- (void)b:(signed char)b; // v20@0:8c16
- (void)l:(long)l; // v20@0:8l16
- (void)ld:(long double)ld; // v32@0:8D16
@end Or this: @implementation C : NSObject
- (void)b:(_Bool)b; // v20@0:8B16
- (void)l:(long)l; // v24@0:8q16
- (void)ld:(long double)ld; // v24@0:8D16
@end |
@blacktop, I just tried the new version, the TBD generation based on the specific system and architecture of the DSC is working perfectly. But there are still some problems with the XCFW generation. Using CoreFoundation as an example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>CoreFoundation.framework/CoreFoundation.tbd</string>
<key>LibraryIdentifier</key>
<string>macos_x86_64maccatalyst_x86_64</string>
<key>LibraryPath</key>
<string>CoreFoundation.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>maccatalyst</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist> Fixing everything, we should have this: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>CoreFoundation.framework/CoreFoundation.tbd</string>
<key>LibraryIdentifier</key>
<string>ios-x86_64-maccatalyst</string>
<key>LibraryPath</key>
<string>CoreFoundation.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>CoreFoundation.framework/CoreFoundation.tbd</string>
<key>LibraryIdentifier</key>
<string>macos-x86_64</string>
<key>LibraryPath</key>
<string>CoreFoundation.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist> And if we had a universal Mach-O, it would this: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>CoreFoundation.framework/CoreFoundation.tbd</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-maccatalyst</string>
<key>LibraryPath</key>
<string>CoreFoundation.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>CoreFoundation.framework/CoreFoundation.tbd</string>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>CoreFoundation.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
I expected this instead:
Note that we can only assume the module to be a system module if we get it from a DSC (at least I think, not sure if there is some info about this in the Mach-O). Modules for regular binaries should be like this:
% ipsw cd -x /System/Library/PrivateFrameworks/CoreFP.framework/Versions/A/CoreFP
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x104709692]
goroutine 1 [running]:
github.com/blacktop/ipsw/pkg/dyld.(*File).GetDylibIndex(0x0, {0x7ff7bc4a9b4d, 0x6})
/Users/pedro/Documents/blacktop/ipsw/pkg/dyld/closure.go:1020 +0x32
github.com/blacktop/ipsw/pkg/dyld.(*File).Image(0x0, {0x7ff7bc4a9b4d, 0x6})
/Users/pedro/Documents/blacktop/ipsw/pkg/dyld/file.go:1717 +0x37
github.com/blacktop/ipsw/internal/commands/macho.(*ObjC).XCFramework(0xc000040180)
/Users/pedro/Documents/blacktop/ipsw/internal/commands/macho/objc.go:726 +0x173
github.com/blacktop/ipsw/cmd/ipsw/cmd.init.func22(0xc0007a9a00?, {0xc0000fa280, 0x1, 0x104b4c63f?})
/Users/pedro/Documents/blacktop/ipsw/cmd/ipsw/cmd/class_dump.go:245 +0xe71
github.com/spf13/cobra.(*Command).execute(0x105ddc6c0, {0xc0000fa260, 0x2, 0x2})
/Users/pedro/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x105ddc9a0)
/Users/pedro/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/Users/pedro/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/blacktop/ipsw/cmd/ipsw/cmd.Execute()
/Users/pedro/Documents/blacktop/ipsw/cmd/ipsw/cmd/root.go:67 +0x1a
main.main()
/Users/pedro/Documents/blacktop/ipsw/cmd/ipsw/main.go:27 +0xf |
@t0rr3sp3dr0 thank you for this great analysis. Just fyi I'm traveling a lot recently so I'll be slow to respond for a while. |
Quick note, if you do something like this: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>FridaGum.framework/FridaGum</string>
<key>LibraryIdentifier</key>
<string>macos-arm64</string>
<key>LibraryPath</key>
<string>FridaGum.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>FridaGum.framework/FridaGum</string>
<key>LibraryIdentifier</key>
<string>macos-x86_64</string>
<key>LibraryPath</key>
<string>FridaGum.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist> Xcode will fail: error: Failed to load XCFramework at 'FridaGum.xcframework': Both 'macos-arm64' and 'macos-x86_64' represent two equivalent library definitions. So |
Congrats on your CVE @t0rr3sp3dr0 🎉 |
Thanks! 😁 You gave me the news even before Apple did, lol. Their communication has been spotty at best. |
What happened?
class-dump's XCFramework feature only creates the library for
ios-arm64_x86_64-simulator
and not for other platforms like macOSHow can we reproduce this?
Use class-dump's XCFramework on a dylib from macOS and see that it doesn't output a library for other platforms
ipsw version
Search
Code of Conduct
Additional context
No response
The text was updated successfully, but these errors were encountered: