digitalmars.D - Accessing the symbol table of a mach-o file
- Jacob Carlborg (29/29) Mar 03 2010 I posted this message in the learn newsgroup without any response, I'm
- KennyTM~ (4/33) Mar 03 2010 If the Mach-O file is from Mac OS X 10.6 or iPhone OS 3.1, your method
- Jacob Carlborg (2/45) Mar 03 2010 No, it's compiled and run on Mac OS X 10.5.7.
I posted this message in the learn newsgroup without any response, I'm now hoping to have better response here. I'm trying to access the symbol table of a mach-o file. I've managed to access the symbol table but I have two problems: 1. It seems I can't access the whole symbol table if I compare my output to the output of nm. For example, I have a global struct in the file I'm examining which doesn't show up in my output. I have a global class that does show up but not the methods in the class. 2. When I'm printing the string representation (accessed from the string table) of some of the symbols they don't seem to be complete. For example "inte" instead of "internal". Then the next symbol I print is the rest of the previous symbol. This is the code I have so far, in some kind of pseudo code format: header = the header of the mach-o file cmd = cast(load_command*) (cast(byte*) header + size of header) loop (number of load commands) { cmd = cast(type of command) (cast(byte*) cmd + size of command) if (cmd == symbol table command) break } symbolTable = cast(nlist*) (cast(byte*) header + symbol table offset) stringTable = cast(char*) (cast(byte*) header + string table offset) foreach (entry in symbolTable) { symbol = stringTable + string table index print symbol } Does anyone have any idea what I can do about the above two problems?
Mar 03 2010
On Mar 4, 10 00:02, Jacob Carlborg wrote:I posted this message in the learn newsgroup without any response, I'm now hoping to have better response here. I'm trying to access the symbol table of a mach-o file. I've managed to access the symbol table but I have two problems: 1. It seems I can't access the whole symbol table if I compare my output to the output of nm. For example, I have a global struct in the file I'm examining which doesn't show up in my output. I have a global class that does show up but not the methods in the class. 2. When I'm printing the string representation (accessed from the string table) of some of the symbols they don't seem to be complete. For example "inte" instead of "internal". Then the next symbol I print is the rest of the previous symbol. This is the code I have so far, in some kind of pseudo code format: header = the header of the mach-o file cmd = cast(load_command*) (cast(byte*) header + size of header) loop (number of load commands) { cmd = cast(type of command) (cast(byte*) cmd + size of command) if (cmd == symbol table command) break } symbolTable = cast(nlist*) (cast(byte*) header + symbol table offset) stringTable = cast(char*) (cast(byte*) header + string table offset) foreach (entry in symbolTable) { symbol = stringTable + string table index print symbol } Does anyone have any idea what I can do about the above two problems?If the Mach-O file is from Mac OS X 10.6 or iPhone OS 3.1, your method won't work because the symbol table format is changed. See http://developer.apple.com/mac/library/releasenotes/DeveloperTools/RN-dyld/index.html.
Mar 03 2010
On 3/3/10 18:54, KennyTM~ wrote:On Mar 4, 10 00:02, Jacob Carlborg wrote:No, it's compiled and run on Mac OS X 10.5.7.I posted this message in the learn newsgroup without any response, I'm now hoping to have better response here. I'm trying to access the symbol table of a mach-o file. I've managed to access the symbol table but I have two problems: 1. It seems I can't access the whole symbol table if I compare my output to the output of nm. For example, I have a global struct in the file I'm examining which doesn't show up in my output. I have a global class that does show up but not the methods in the class. 2. When I'm printing the string representation (accessed from the string table) of some of the symbols they don't seem to be complete. For example "inte" instead of "internal". Then the next symbol I print is the rest of the previous symbol. This is the code I have so far, in some kind of pseudo code format: header = the header of the mach-o file cmd = cast(load_command*) (cast(byte*) header + size of header) loop (number of load commands) { cmd = cast(type of command) (cast(byte*) cmd + size of command) if (cmd == symbol table command) break } symbolTable = cast(nlist*) (cast(byte*) header + symbol table offset) stringTable = cast(char*) (cast(byte*) header + string table offset) foreach (entry in symbolTable) { symbol = stringTable + string table index print symbol } Does anyone have any idea what I can do about the above two problems?If the Mach-O file is from Mac OS X 10.6 or iPhone OS 3.1, your method won't work because the symbol table format is changed. See http://developer.apple.com/mac/library/releasenotes/DeveloperTools/RN-dyld/index.html.
Mar 03 2010