[Pythonmac-SIG] python clone of "otool -Lv"

Bob Ippolito bob at redivi.com
Mon Jul 28 05:22:00 EDT 2003


On Monday, July 28, 2003, at 12:50AM, Bob Ippolito wrote:

> 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.

I went ahead and wrote the install_name_tool clone 
(pinstall_name_tool.py), and uploaded a new archive.  I haven't tested 
it extensively, but for the few things I've tried it produced the same 
exact output as install_name_tool did.

It's available at: http://undefined.org/python/potool-0.1.tgz

If anyone wants to backport this to the struct module or something, I 
wouldn't mind :)

-bob




More information about the Pythonmac-SIG mailing list