<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Noel, hi Thomas,</div><div><br></div><div>thanks for the great help! I will certainly have a look at the reverse engineered protocol because that's fascinating (also I didn't know wireshark, sounds very interesting to try out!), but binding to the C library will surely be the simpler way then...</div><div><br></div><div>And thank you too for the concrete explanations regarding the 32 v. 64 bit issue!&nbsp;</div><div><br></div><div>Interestingly, file doesn't give such a detailed output on my Mac, and as I'm taking off this week I cannot check on Ubuntu at my workplace (I have been using file there and the output was also quite short, but I think I will mostly have used it for non-executables there, e.g. to find out whether something's a symlink or not, so I don't know).</div><div><br></div><div>On my Mac I have e.g.</div><div><br></div><div><div>$ file '/usr/bin/file'</div><div>/usr/bin/file: Mach-O universal binary with 2 architectures</div><div>/usr/bin/file (for architecture i386):<span class="Apple-tab-span" style="white-space:pre">        </span>Mach-O executable i386</div><div>/usr/bin/file (for architecture ppc7400):<span class="Apple-tab-span" style="white-space:pre">        </span>Mach-O executable ppc</div><div><br></div><div>Regarding objdump, this I do not have in Leopard, but I found out that the Mac equivalent is otool, and from a blog post (<a href="http://paulbeachsblog.blogspot.com/2007/12/32bit-or-64bit-binaries-on-macos.html">http://paulbeachsblog.blogspot.com/2007/12/32bit-or-64bit-binaries-on-macos.html</a>) I found how to use it:</div><div><br></div><div><div>$ otool -h /usr/bin/file</div><div>/usr/bin/file:</div><div>Mach header</div><div>magic cputype cpusubtype &nbsp;caps &nbsp; &nbsp;filetype ncmds sizeofcmds &nbsp; &nbsp; &nbsp;flags</div><div>0xfeedface &nbsp; &nbsp; &nbsp; 7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3 &nbsp;0x00 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp;14 &nbsp; &nbsp; &nbsp; 1296 0x00000085</div><div><br></div><div>And in&nbsp;<span class="Apple-style-span" style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; ">usr/include/mach-o/loader.h I have:</span></div><div><font class="Apple-style-span" face="'Trebuchet MS', Trebuchet, Verdana, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="'Trebuchet MS', Trebuchet, Verdana, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 13px;"><div>/* Constant for the magic field of the mach_header (32-bit architectures) */</div><div>#define MH_MAGIC &nbsp; &nbsp; &nbsp; &nbsp;0xfeedface &nbsp; &nbsp; &nbsp;/* the mach magic number */</div><div><br></div><div><br></div><div>Ciao,</div><div>Sigrid</div></span></font></div></div><div><br></div></div><div><br></div><div><br></div><br><div><div>Am 23.09.2009 um 10:45 schrieb Noel Welsh:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Wed, Sep 23, 2009 at 9:21 AM, Sigrid &lt;<a href="mailto:keydana@gmx.de">keydana@gmx.de</a>&gt; wrote:<br><blockquote type="cite">As for the network vs. FFI approach, I was searching the Oracle<br></blockquote><blockquote type="cite">documentation for it and it seems to me that the network approach is<br></blockquote><blockquote type="cite">impossible, as it uses a proprietary network protocol (called TTC)<br></blockquote><blockquote type="cite">from Oracle.<br></blockquote><br>AFAIK, you're largely correct but some people have reverse engineered<br>the protocol:<br><br><a href="http://www.oracle-internals.com/?p=22">http://www.oracle-internals.com/?p=22</a><br><br>Probably simpler to just bind the C library.<br><br><blockquote type="cite">may I ask a very stupid question: I don't really know how to find out<br></blockquote><blockquote type="cite">whether a library uses 32bit or 64bit (even I don't know, is this a<br></blockquote><blockquote type="cite">feature of a single library, or of the system)?<br></blockquote><br>Both :) The OS generally has to support 64-bit (like Snow Leopard) but<br>then individual libraries may be 64-bit or 32-bit (if the OS supports<br>this kind of "mixed mode" code, which Snow Leopard does).<br><br><blockquote type="cite">Could you tell me how<br></blockquote><blockquote type="cite">to find out such things on a Mac? (For this, as the concept itself is<br></blockquote><blockquote type="cite">not too clear for me I would not even know how to find out on Linux,<br></blockquote><blockquote type="cite">but I must admit that even if I know something on Linux I sometimes<br></blockquote><blockquote type="cite">have problems when things are different on the Mac...)<br></blockquote><br>file, objdump, or readelf (last is probably Linux specific). &nbsp;Examples on Linux:<br><br><br>~&gt; objdump -f /bham/ums/linux/pd/packages/plt-scheme/bin/mzscheme<br><br>/bham/ums/linux/pd/packages/plt-scheme/bin/mzscheme: &nbsp;&nbsp;&nbsp;&nbsp;file format elf32-i386<br>architecture: i386, flags 0x00000112:<br>EXEC_P, HAS_SYMS, D_PAGED<br>start address 0x0805e570<br><br><br>~&gt; readelf -h /bham/ums/linux/pd/packages/plt-scheme/bin/mzscheme<br>ELF Header:<br> &nbsp;Magic: &nbsp;&nbsp;7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00<br> &nbsp;Class: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ELF32<br> &nbsp;Data: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2's complement, little endian<br> &nbsp;Version: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 (current)<br> &nbsp;OS/ABI: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UNIX - System V<br> &nbsp;ABI Version: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<br> &nbsp;Type: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXEC (Executable file)<br> &nbsp;Machine: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Intel 80386<br> &nbsp;Version: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x1<br> &nbsp;Entry point address: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x805e570<br> &nbsp;Start of program headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;52 (bytes into file)<br> &nbsp;Start of section headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4806288 (bytes into file)<br> &nbsp;Flags: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x0<br> &nbsp;Size of this header: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;52 (bytes)<br> &nbsp;Size of program headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;32 (bytes)<br> &nbsp;Number of program headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8<br> &nbsp;Size of section headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;40 (bytes)<br> &nbsp;Number of section headers: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;38<br> &nbsp;Section header string table index: 35<br><br><br><br>~&gt; file /bham/ums/linux/pd/packages/plt-scheme/bin/mzscheme<br>/bham/ums/linux/pd/packages/plt-scheme/bin/mzscheme: ELF 32-bit LSB<br>executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9,<br>dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not<br>stripped<br><br><br><br>HTH,<br>N.<br></div></blockquote></div><br></body></html>