FFI::ExtractSymbols - Extract symbol names from a shared object or DLL
version 0.04
use FFI::ExtractSymbols; use FFI::CheckLib; my $libpath = find_lib( lib => 'foo' ); extract_symbols($libpath, code => sub { print "found a function called $_[0]\n"; }, );
This module extracts the symbol names from a DLL or shared object. The method used depends on the platform.
extract_symbols($lib, export => sub { ... }, code => sub { ... }, data => sub { ... }, );
Extracts symbols from the dynamic library (DLL on Windows, shared library most other places) from the library and calls the given callbacks. Each callback is called once for each symbol that matches that type. Each callback gets two arguments. The first is the symbol name in a form that can be passed into FFI::Platypus#find_symbol, FFI::Platypus#function or FFI::Platypus#attach. The second is the exact symbol name as it was extracted from the DLL or shared library. On some platforms this will be prefixed by an underscore. Some tools, such as c++filt will require this version as input. Example:
c++filt
extract_symbols( 'libfoo.so', export => sub { my($symbol1, $symbol2) = @_; my $address = $ffi->find_symbol($symbol1); my $demangled = `c++filt $symbol2`; }, );
All exported symbols, both code and data.
All symbols in the "text" section of the DLL or shared object. These are usually functions.
All symbols in the data section of the DLL or shared object.
This module may work on static libraries and object files for some platforms, but that usage is unsupported and may not be portable.
On windows, depending on the implementation available, this module may not differentiate between code and data symbols. In that case the export and code callbacks will be called for both.
On many platforms extra symbols get lumped into DLLs and shared object files so you should account for and ignore getting unexpected symbols that you probably don't care about.
Write Perl bindings to non-Perl libraries without C or XS
Module for checking for the availability of dynamic libraries.
This module can parse the symbol names out of shared object files on platforms where nm works on those types of files.
nm
It does not work for Windows DLL files. It also depends on Regexp::Assemble which appears to be unmaintained.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2015 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install FFI::ExtractSymbols, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FFI::ExtractSymbols
CPAN shell
perl -MCPAN -e shell install FFI::ExtractSymbols
For more information on module installation, please visit the detailed CPAN module installation guide.