FFI: get function address?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FFI: get function address?

Schwab,Wilhelm K
Hello all,

Does Squeak/Pharo FFI offer a way to get the address of a function in a library?  The target of interest is probably more of an exported global containing a pointer, but GetProcAddress() worked on Windows, and I am assuming a similar trick will be required on Linux.

Bill


Reply | Threaded
Open this post in threaded view
|

Re: FFI: get function address?

Andreas.Raab
On 3/25/2010 7:50 PM, Schwab,Wilhelm K wrote:
> Does Squeak/Pharo FFI offer a way to get the address of a function in a library?  The target of interest is probably more of an exported global containing a pointer, but GetProcAddress() worked on Windows, and I am assuming a similar trick will be required on Linux.

You mean generically? No, there isn't. You need to call
LoadLibrary/GetProcAddress or dlopen/dlsym on your platform.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: FFI: get function address?

johnmci
In reply to this post by Schwab,Wilhelm K
There usually is an operating system call that you feed a "symbol" to that gives you a memory address.
This address could be:

(a) the start address of executable code.
(b) the start address of read only, or read/write storage for a data element of some sort.

This is kinda of exposed in the VM api via

        VM->ioLoadModuleOfLength = ioLoadModuleOfLength;
        VM->ioLoadSymbolOfLengthFromModule = ioLoadSymbolOfLengthFromModule;



On 2010-03-25, at 7:50 PM, Schwab,Wilhelm K wrote:

> Hello all,
>
> Does Squeak/Pharo FFI offer a way to get the address of a function in a library?  The target of interest is probably more of an exported global containing a pointer, but GetProcAddress() worked on Windows, and I am assuming a similar trick will be required on Linux.
>
> Bill
>
>

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================







smime.p7s (3K) Download Attachment