Subject: How to get DT_SONAME?
To: None <current-users@NetBSD.ORG>
From: Johnny C. Lam <>
List: port-alpha
Date: 05/23/1998 20:46:38
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/
Error: No error
No DT_SONAME found.

% ./soname /usr/lib/ 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?

   Johnny C. Lam
   Department of Statistics   
   Carnegie Mellon University 


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

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 );
    printf( "No DT_SONAME found\n" );
  bfd_close( abfd );

  return 0;