<br><br><div class="gmail_quote">On Sat, Sep 25, 2010 at 7:30 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
On 25 September 2010 10:32, K. K. Subramaniam &lt;<a href="http://kksubbu.ml" target="_blank">kksubbu.ml</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt; wrote:<br>
&gt; On Saturday 25 Sep 2010 6:44:19 am Igor Stasenko wrote:<br>
&gt;&gt; But on Linux, mmap() is a part of GLIBC library.<br>
&gt;&gt; Any idea, what module name i could use to get a pointer to<br>
&gt;&gt; mmap/dlopen/dlsym using interpreterProxy functions?<br>
&gt; libc.so.6 (for sixth generation C library). see man page for libc<br>
&gt;<br>
</div></div>how i can be sure that squeak vm always using this &#39; sixth generation<br>
C library&#39;,<br>
and i&#39;m not trying load a different version of it?<br>
Where the guarantees that all unix boxes using libc.so.6?<br></blockquote><div><br></div><div>Nothing.  And on Mac OS X it will likely be libSystem.B.dylib and on Solaris will be something else again etc.  You&#39;ll need to use the tool that displays the dynamic libraries against which the VM is linked.  e.g.</div>
<div><br></div><div><div>ldd cogunix/bin/lib/squeak/3.9-7/squeak </div><div>        linux-gate.so.1 =&gt;  (0x00765000)</div><div>        libutil.so.1 =&gt; /lib/libutil.so.1 (0x06b55000)</div><div>        libdl.so.2 =&gt; /lib/libdl.so.2 (0x00afd000)</div>
<div>        libpthread.so.0 =&gt; /lib/libpthread.so.0 (0x00b04000)</div><div>        libm.so.6 =&gt; /lib/libm.so.6 (0x00ad2000)</div><div>        libnsl.so.1 =&gt; /lib/libnsl.so.1 (0x064b5000)</div><div>        <b>libc.so.6 =&gt; /lib/libc.so.6 (0x00b53000</b>)</div>
<div>        /lib/ld-linux.so.2 (0x00ab3000)</div></div><div> </div><div><div> otool -L Cog/oscogvm/macbuild/Fast.app/Contents/MacOS/Croquet </div><div>Cog/oscogvm/macbuild/Fast.app/Contents/MacOS/Croquet:</div><div>        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 476.19.0)</div>
<div>        /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)</div><div>        /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)</div>
<div>        /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)</div><div>        /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1327.73.0)</div>
<div>        /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)</div><div>        /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)</div>
<div>        /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)</div><div>        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 677.26.0)</div>
<div>        /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 212.2.0)</div><div>        /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)</div>
<div>        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)</div><div>        <b>/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)</b></div><div>        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)</div>
<div>        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 32.0.0)</div><div>        /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 34.0.0)</div>
</div><div><br></div><div>It would be convenient if the VM could answer the basename of the C library against which it was linked, e.g. through a systemAttributeAt:, but I expect that would be implemented by using a manifest string constant in the VM.  Clearly this info belongs in the VM, not a table in the image.  But VM builders would still need to test it as it could easily get stale if its supplied from the build system.  We&#39;d need a test and e.g. one of my Alien tests is an invocation of qsort which is in the C library.</div>
<div><br></div><div>Igor, for now I would hard code this in the image.  But we should add it to the VM soon.</div><div><br></div><div>But this raises an important issue.  I think the architecture of dynamic linking of both named primitives and FFI calls in Squeak is wrong.  The VM does all the work of binding names to functions, taking a function name, library/plugin pair and resolving it to an address, which means for example that one can&#39;t substitute a symbolic name such as TheCLibrary in an FFI call since this name will be interpreted literally by the VM (and will fail).</div>
<div><br></div><div>If instead there were two primitives, openLibrary and lookupInLibrary (as there are in Alien) then the linking machinery could be moved up into the image where we could concretize symbolic names.  This would be done either explicitly, e.g.</div>
<div><br></div><div>    myPluginPrimitive</div><div>        &lt;primitive: &#39;myPluginPrimitive&#39; module: &#39;ThePlugin&#39; error: errorCode&gt;</div><div>        errorCode == #unlinked ifTrue:</div><div>            [^thisContext linkAndRetryExternalPluginInvocation]</div>
<div>        ...</div><div><br></div><div>    qsort: base elements: nel width: width comparator: compar</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;apicall: void &#39;qsort&#39; (void* ulong ulong void*)</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>module: &#39;WhateverTheCLibraryIsOnThisPlatform&#39;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>error: err&gt;</div><div>        errorCode == #unlinked ifTrue:</div>
<div>            [^thisContext linkAndRetryExternalPluginInvocation]</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^self externalCallFailedWith: err</div><div><br></div><div>or, as it is in VisualWorks, with a hidden callback (selector in the specialObjectsArray) that sends a message to the unlinked method whose arguments are the calls receiver and arguments.  Personally I think the explicit method is better since its more flexible.</div>
<div><br></div><div>best</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
&gt; Subbu<br>
<div><div></div><div class="h5">&gt;<br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>