-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Proper fat Mach-O creation #100
Conversation
Introduces `MachOFile#segment_alignment`, `SegmentCommand#guess_align`, and `Sections::MAX_SECT_ALIGN`. Closes #99.
Slightly better than having "\x00"s scattered throughout the code.
Could you give the changes in this branch a try, @sashkab? (I'll be in front of Mac in a few days to test them with |
Umm... the only exposure to ruby I have is due to Homebrew. I tried and couldn't figure out how to install updated version into hombrew to test it using my formula. If you can, point me to steps to upgrade the gem?Thanks! |
The simplest way to test it is probably just to clone the repo: $ git clone https://github.com/Homebrew/ruby-macho
$ cd ruby-macho ...and then load it into $ irb -Ilib -rmacho From there, you should be able to call methods like |
Thanks. Looks good to me now: irb(main):002:0> libs = ["/tmp/uopenssl-20180702-16887-vjpn5r/openssl-1.0.2o/build-i386/libcrypto.1.0.0.dylib","/tmp/uopenssl-20180702-16887-vjpn5r/openssl-1.0.2o/build-x86_64/libcrypto.1.0.0.dylib"]
=> ["/tmp/uopenssl-20180702-16887-vjpn5r/openssl-1.0.2o/build-i386/libcrypto.1.0.0.dylib", "/tmp/uopenssl-20180702-16887-vjpn5r/openssl-1.0.2o/build-x86_64/libcrypto.1.0.0.dylib"]
irb(main):003:0> MachO::Tools.merge_machos("/tmp/fix1.dylib", *libs)
=> 3649920
$ lipo -info /tmp/fix1.dylib
Architectures in the fat file: /tmp/fix1.dylib are: i386 x86_64
$ file /tmp/fix1.dylib
/tmp/fix1.dylib: Mach-O universal binary with 2 architectures: [i386:Mach-O dynamically linked shared library i386] [x86_64]
/tmp/fix1.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/tmp/fix1.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 |
Awesome! I'll do some cleanup on the changes, and hopefully we'll have a fixed version vendored in Homebrew in a day or two 😄 |
Great, thank you @woodruffw! |
This now calculates alignments correctly, and pads the resulting Fat Mach-O so that individual Mach-O slices are page-aligned.
Closes #99.