[Pythonmac-SIG] python clone of "otool -Lv"
bob at redivi.com
Mon Jul 28 01:50:44 EDT 2003
I did a quick proof-of-concept utility that clones the functionality of
otool -Lv today. It needs ctypes, because that's how I wrote the
structure parsing stuff... not for any other good reason. The output
of "python potool.py /some/executable_or_dylib" should be identical to
the output of "otool -Lv /some/executable_or_dylib".
The idea behind this is to write a version of install_name_tool in
Python, so that we don't have to depend on the presence of developer
tools for that kind of installation. It's pretty essential for
bundlebuilder kinda stuff if you want to embed frameworks, or
installing frameworks to semi-arbitrary locations on a user's computer
(i.e. admin, network or user). It doesn't do this yet, but all the
parsing/generating code for this kind of modification is there.
There's an ld flag that you should to use to pad these headers
(-headerpad_max_install_names) if you're going to have any luck making
paths longer. By default, they end up with just enough zero padding
cstring termination and 32bit alignment.
It's available at: http://undefined.org/python/potool-0.0.tgz
Anyone, please feel free to take this and write the install_name_tool
code ;) All the information I needed to write this part of the
functionality was in /usr/include/mach-o/loader.h. I took a look at
the install_name_tool source code and man page. The best it does is
modify these dylib structures in-place. It's not capable of expanding
them to accommodate paths beyond the padding size of the mach-o file.
Emulating this tool should be rather easy.
More information about the Pythonmac-SIG