Skip to content
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

add v6 patched qemu binaries #32

Closed
wants to merge 3 commits into from
Closed

add v6 patched qemu binaries #32

wants to merge 3 commits into from

Conversation

joske
Copy link

@joske joske commented Feb 11, 2021

here are the binaries with v6 patches, works perfectly here.

@ubenmackin
Copy link
Owner

Thanks for submitting this.

However, the binaries reference your locally installed libraries which others might not have installed (/opt/homebrew). You can check this by using the otool tool (I placed **** by the libraries in question):

macbookair:~ $ otool -L Downloads/qemu-system-aarch64 
Downloads/qemu-system-aarch64:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Hypervisor.framework/Versions/A/Hypervisor (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	****/opt/homebrew/opt/pixman/lib/libpixman-1.0.dylib (compatibility version 41.0.0, current version 41.0.0)
	****/opt/homebrew/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 6601.0.0, current version 6601.6.0)
	****/opt/homebrew/opt/glib/lib/libgobject-2.0.0.dylib (compatibility version 6601.0.0, current version 6601.6.0)
	****/opt/homebrew/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 6601.0.0, current version 6601.6.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	****/opt/homebrew/opt/jpeg/lib/libjpeg.9.dylib (compatibility version 14.0.0, current version 14.0.0)
	****/opt/homebrew/opt/libpng/lib/libpng16.16.dylib (compatibility version 54.0.0, current version 54.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
	/usr/lib/libpam.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.20.117)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 54.0.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1463.2.1)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.255.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Basically what you need to do is tell the binary to reference the libraries that will be bundled with ACVM. For myself, I run these on the binaries in the build folder for qemu like so:

install_name_tool -change /opt/homebrew/opt/glib/lib/libglib-2.0.0.dylib @executable_path/../Frameworks/libglib-2.0.0.dylib build/qemu-img
install_name_tool -add_rpath @executable_path/../Frameworks build/qemu-img

Note that for the qemu-system-aarch64 we need to run on the unsigned binary, and then resign, otehrwise OS X will complain the binary signature was changed:

install_name_tool -change /opt/homebrew/opt/pixman/lib/libpixman-1.0.dylib @executable_path/../Frameworks/libpixman-1.0.dylib build/qemu-system-aarch64-unsigned
install_name_tool -change /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib build/qemu-system-aarch64-unsigned
install_name_tool -change /opt/homebrew/opt/glib/lib/libglib-2.0.0.dylib @executable_path/../Frameworks/libglib-2.0.0.dylib build/qemu-system-aarch64-unsigned
install_name_tool -change /opt/homebrew/opt/glib/lib/libgmodule-2.0.0.dylib @executable_path/../Frameworks/libgmodule-2.0.0.dylib build/qemu-system-aarch64-unsigned
install_name_tool -add_rpath @executable_path/../Frameworks build/qemu-system-aarch64-unsigned

scripts/entitlement.sh build/qemu-system-aarch64-unsigned build/qemu-system-aarch64 accel/hvf/entitlements.plist

The binaries you get won't run standalone, the'll only run when in the folder structure of ACVM because of the library references. But they will work for anyone, as they won't have to have homebrew and the libraries installed outside of ACVM.

I am new to Swift/OS X programming, so a lot of this I have picked up over on the macrumors forums from other users. Hopefully this make sense.

@joske
Copy link
Author

joske commented Feb 12, 2021

You seem to know a lot more than me though ;-) (linux guy). Did not expect this, in normal unix systems, the loader will resolve shared libs from its search path. I expected the mac loader to be smart to look inside its app bundle thingy. Apparently not.

@joske
Copy link
Author

joske commented Feb 12, 2021

Relocated the libs, and added a few that were missing. I added those to the project, but they are not automatically signed, trying to figure out how, but I don't want to commit my project files, as they have my signing keys etc, and I don't know enough about it to safely do that.

@joske
Copy link
Author

joske commented Feb 12, 2021

now I can no longer get it to run :(. I get SIGABRT. Complaining about the signature on libjpeg and libpng.

@joske
Copy link
Author

joske commented Feb 12, 2021

To confuse matters even more, the qemu binaries you ship point to libs in /usr/local/opt which does not exist on my system, but still it seems it finds them in the Frameworks folder?

@joske
Copy link
Author

joske commented Feb 12, 2021

Ok figured it out, I had to add them to the project and in the build step also in several places ;). Learning.

So I guess with the updated libs you can fix the project file yourself, as I dare not commit it.

@joske
Copy link
Author

joske commented Feb 12, 2021

I updated the project file in a safe way I think (not commited the team change). The pod project file was also (massively) changed, did not commit that one, not sure about that.

@mooseword
Copy link

@joske, I just opened #38 but wasn't able to @ you there, so hopefully it is ok to do so here.

Is it possible you could help with that issue, since you have been gone through the process?

@joske joske closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants