Using Shared Object Libraries

1. Using gdb with Linux Elf shared object libraries

Hello,

    I recently began debugging a product which distributes itself as a
set of shared object libraries. Try as I may, I have been unable to get
gdb (4.16 or 4.17) to load the shared object libraries, despite having
LD_LIBRARY_PATH set correctly. The programs will run stand-alone, but
fail to find my shared object libraries under gdb. I have tried using
the "share" command in gdb and still no luck.

    I tried the simplest example of making and using a program built of
of user shared object libraries, from Linux Application Development by
Michael K. Johnson and Eric W. Troan (ISBN 0-201-30821-5) p. 74-75.  My
file listings are given below, as well as the gdb output. Is this a
known defect in gdb on Linux? I saw some mention of this in
gnu.gdb.bugs, but the messages of interest seemed to have expired. Yet
some claim to be able to debug local (not in /etc/ld.so.cache) shared
object libraries under Linux.

    My system is running Red Hat 5.0/Intel with all updates applied. I
am using gcc 2.7.2.3. I compiled gdb 4.17 locally and got exactly the
same results. I tried preloading, and all ELF documented tricks, but
have made no reproducible progress.

Thanks,
Robert D. Kennedy
Fermi National Accelerator Laboratory

===========================================

/* libhello.h */
void print_hello(void)

/* libhello.c */
#include <stdio.h>
void print_hello(void)
{ printf("Hello, from a shared library.\n") ;

/* usehello.c */
#include "libhello.h"
int main(void)
{print_hello() ;
  return 0 ;

% gcc -fPIC -Wall -g -c libhello.c
% gcc -g -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.c
-lc
% #<make symlinks for libhello.so, libhello.so.0>
% gcc -g -Wall usehello.c -L. -lhello -o usehello
% setenv LD_LIBRARY_PATH $cwd
% ./usehello        # Works fine

gdb ./usehello # fails to load libhello.so...

b0pc07:Test> gdb ./usehello

GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for
details.
GDB 4.16 (i386-redhat-linux), Copyright 1996 Free Software Foundation,
Inc...
(gdb) run
Starting program: /usr/scratch/kennedy/Test/./usehello
/usr/scratch/kennedy/Test/./usehello: error in loading shared libraries
libhello.so.0: cannot open shared object file: No such file or directory

Program exited with code 0177.

2. Linux T-shirts?

3. error in loading shared libraries: libXmu.so.6: cannot open shared object

4. zsh on RS6000

5. creating new shared object from existing shared objects ??

6. Will there ever be a decent CMDTOOL?

7. Using static libraries and shared libraries in same program?

8. Kernel Name

9. Using libtool to build shared libraries that depend on static libraries

10. Unresolved symbols in shared-object libraries, how?

11. Circular dependencies between shared-object libraries

12. static objects inside shared library causes crash

13. Problem with new and delete in shared object (dynamic link library) files.