Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get DT_SONAME?

4 views
Skip to first unread message

Johnny C. Lam

unread,
May 25, 1998, 3:00:00 AM5/25/98
to

I'm running the 19980419 snapshot of NetBSD/alpha.

I'm confused about why the following doesn't work. I'm trying to
write something to print out the name stored in DT_SONAME. According
to the ld documentation, if a library is linked with -soname=NAME,
then NAME gets written into the DT_SONAME field of the resulting
object. But I get as output:

% ./soname /usr/lib/libposix.so.0.1
Error: No error
No DT_SONAME found.

% ./soname /usr/lib/libposix.so.0.1 alpha-unknown-netbsd1.3
Error: No error
No DT_SONAME found.

Can someone explain what's going on, or how to do what I'm trying
(unsuccessfully) to do?

Thanks,
--
Johnny C. Lam
Department of Statistics la...@stat.cmu.edu
Carnegie Mellon University http://www.stat.cmu.edu/~lamj/

@>---`---,----


--------- soname.c ---------
#include <stdio.h>
#include <bfd/bfd.h>

int
main( int argc, char * argv[] )
{
bfd * abfd;
const char * soname;
const char * errmsg;
char * target = NULL;

if ( argc > 2 )
target = argv[2];

abfd = bfd_openr( argv[1], target );
errmsg = bfd_errmsg( bfd_get_error() );
printf( "Error: %s\n", errmsg );

soname = bfd_elf_get_dt_soname( abfd );
if ( soname != NULL )
printf( "%s\n", soname );
else
printf( "No DT_SONAME found\n" );
bfd_close( abfd );

return 0;
}

0 new messages