<div dir="ltr">Hi Esteban,<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 7:57 AM, Esteban Lorenzano <span dir="ltr"><<a href="mailto:estebanlm@gmail.com" target="_blank">estebanlm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
I’m trying to access symbols through FFI (like, for instance, to access char **environ variable from libc).<br>
I know the vm has implemented<br>
<br>
<br>
ioLoadModule: moduleNameIndex OfLength: moduleNameLength<br>
ioLoadSymbol: functionNameIndex OfLength: functionNameLength FromModule: moduleHandle<br>
<br>
… but well, since this functions are implemented inside the executable and not in an external module, I cannot access them through a regular FFI call.<br></blockquote><div><br></div><div>Well you can/ They are just interfaces to dlsym et al on Unix and GetProcAddress on WIndows. They have the advantage that they're portable. Why would you want to access them through an FFI call? Don't you just want a primitive interface? See e.g. the ALien (IA32ABI) primitive interface:</div><div><br></div><div><div>/* Attempt to find the address of a symbol in a loaded library.</div><div> The primitive can have a signature either of the form:</div><div> <Anywhere> primInLibrary: libraryHandle <Alien> findSymbol: symbolName</div><div> <String> ^<Integer></div><div> <primitive: 'primInLibraryFindSymbol' error: errorCode module: 'IA32ABI'></div><div> or:</div><div> libraryHandle <Alien> primFindSymbol: symbolName <String> ^<Integer></div><div> <primitive: 'primInLibraryFindSymbol' error: errorCode module: 'IA32ABI'> */</div><div><br></div><div> /* IA32ABIPlugin>>#primInLibraryFindSymbol */</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I suppose this can be like that because of security reasons, but I really need them (this is part of my effort to provide a replacement to NativeBoost on Pharo)… I really want to go back to use the FFI Plugin.<br></blockquote><div><br></div><div>Right. So either use the Alien interface or copy the Alien primitives into the FFI plugin.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Is there a way to do this?<br>
If not, would you agree if I add a primitive “loadSymbol:fromModule:” to ThreadedFFIPlugin? (I know, I could fork it, but I’m really trying to get aligned with the current implementation of the VM and I do not want to start again with the problem :P)<br></blockquote><div><br></div><div>Yes. Of course.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
thanks!<br>
<span class="HOEnZb"><font color="#888888">Esteban</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>