That could be written in Perl, and you'd learn a lot doing it. It would take a while to work out all the wrinkles.
Why not use the right tool for the job? The nm utility does just that for any object file, including libraries and executables. For a perl without debugging symbols,
$ nm /usr/bin/perl
08049a10 T boot_DynaLoader
0804b24c A __bss_start
08049074 t call_gmon_start
0804b24c b completed.1
0804b164 d __CTOR_END__
0804b160 d __CTOR_LIST__
0804b050 D __data_start
0804b050 W data_start
w __deregister_frame_info_bases@@GCC_3.0
U dlclose@@GLIBC_2.0
U dlerror@@GLIBC_2.0
08049290 t dl_generic_private_init
U dlopen@@GLIBC_2.1
08049390 t dl_private_init
U dlsym@@GLIBC_2.0
08049d30 t __do_global_ctors_aux
080490a0 t __do_global_dtors_aux
0804b054 D __dso_handle
0804b16c d __DTOR_END__
0804b168 d __DTOR_LIST__
0804b060 A _DYNAMIC
0804b24c A _edata
0804b05c d __EH_FRAME_BEGIN__
0804b274 A _end
U exit@@GLIBC_2.0
08049d60 T _fini
08049d80 R _fp_hw
08049100 t frame_dummy
0804b05c d __FRAME_END__
U getenv@@GLIBC_2.0
0804b174 A _GLOBAL_OFFSET_TABLE_
w __gmon_start__
08048e0c T _init
08049d84 R _IO_stdin_used
0804b170 d __JCR_END__
0804b170 d __JCR_LIST__
w _Jv_RegisterClasses
U __libc_start_main@@GLIBC_2.0
08049160 T main
0804b26c b my_cxt
0804b268 b my_perl
0804b250 b object.2
0804b058 d p.0
U perl_alloc
U perl_construct
U Perl_croak
U perl_destruct
U Perl_form
U perl_free
U Perl_get_sv
U Perl_mg_set
U Perl_newRV
U Perl_newSVpvn
U Perl_newXS
U perl_parse
U perl_run
U Perl_sv_2iv
U Perl_sv_2mortal
U Perl_sv_2pv_flags
U Perl_sv_2pv_nolen
U Perl_sv_newmortal
U Perl_sv_setiv
U Perl_sv_setpv
U Perl_sv_setpvn
U Perl_vmess
U PL_curpad
U PL_do_undump
U PL_exit_flags
U PL_markstack_ptr
U PL_op
U PL_perl_destruct_level
U PL_sigfpe_saved
U PL_stack_base
U PL_stack_sp
U PL_sv_yes
w __register_frame_info_bases@@GCC_3.0
08049310 t SaveError
U signal@@GLIBC_2.0
08049050 T _start
U __strtol_internal@@GLIBC_2.0
08049920 T XS_DynaLoader_dl_error
08049640 T XS_DynaLoader_dl_find_symbol
080497f0 T XS_DynaLoader_dl_install_xsub
080493a0 T XS_DynaLoader_dl_load_file
08049770 T XS_DynaLoader_dl_undef_symbols
080494f0 T XS_DynaLoader_dl_unload_file
08049240 t xs_init
$
That perl is compiled to build and use libperl.so, hence all the unresolved symbols from perlguts
There are lots of options recognised by nm. See the man page.
|