Universal Mach-O target for BFD

Ryan Govostes rgovostes@gmail.com
Thu Oct 8 20:59:00 GMT 2009


I noticed that GDB 7, while it supports single-architecture Mach-O  
files, does not like "universal" (fat) binaries.

I haven't done any hacking on gdb / binutils before, so I'm not sure  
of the extent of changes that need to be made. I expect it's something  
like,

1. Add support for universal binaries to BFD.
2. Add flags to GDB to select which architecture to extract.

For the first one, I'm not sure if there is precedent in BFD on how to  
handle fat binaries, but here's the gist of how a multiarchitecture  
file is laid out[1] (all in big-endian byte ordering):


1. The 4-byte magic number 0xCAFEBABE.
2. A 4-byte unsigned integer expressing the number of architectures:
3. A number of structs, one per object file, as follows:
	a. A cpu_type_t specifying the CPU family.
	b. A cpu_subtype_t specifying the CPU family member.
	c. A 4-byte offset from the beginning of the file to the start of the  
Mach-O header for the object file.
	d. A 4-byte size of the object file, in octets.
	e. A 4-byte alignment value for the offset == log(offset) / log(2)


I'd be glad to try my hand at implementing it; does anyone have any  
pointers for where to get started?


Regards,
Ryan Govostes

1: http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/20001298-154889
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2446 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20091008/e134aa5b/attachment.p7s>


More information about the Binutils mailing list