Sponsored Content
Top Forums Programming gdb - loading symbols of shared library Post 302245984 by rimon on Sunday 12th of October 2008 07:01:59 AM
Old 10-12-2008
gdb - loading symbols of shared library

I am debugging in gdb a program that dynamically loads libodbcinst.so. I want to debug the code from libodbcinst - I can break in it, see the source and step through it, but whenever I try printing a variable, I get (e.g. for the variable ret):
Code:
No symbol "ret" in current context.

In my program libodbcinst.so loads my own library (an odbc driver). This library I can debug fully, symbols and all.
Things I've verified:
- libodbcinst.so is compiled with debug information. I compiled it myself from UnixODBC sources, and made sure it was compiled with debug info.
- libodcinst.so is not stripped - I ran 'nm' on it, and got a symbol table.
- From gdb I ran 'info share' and saw that libodbcinst.so was in the list of loaded libraries. I also tried running 'sharedlibrary libodbcinst.so' but this made no difference.
- I tried running add-symbol-file for the library. I must admit I have a problem here. This command is supposed to receive an 'address' parameter. The manual says this should be the address where the library was loaded. How do I know that library? I tried putting different things there - for example the address of the text segment I got from 'maint info sections', but not only could I still not see the symbols, this also screwed up something with the rest of the debugging.

So, in addition to a solution to show the symbols, I would also be very grateful for an explanation of the address parameter for add-symbol-file.

I'm working on HP-UX 11.23 (Itanium). Using HP gdb (wdb) 5.7 .

TIA!

RO
 

10 More Discussions You Might Find Interesting

1. Programming

Loading Gdb And Gcc In Unix System

Can any one help me out???? I need to install GDB and GCC in an UNIX machine. can any one point me to any lucid pointer to it. The gNU help on this is proving to be little tangential for me. (2 Replies)
Discussion started by: rraajjiibb
2 Replies

2. Programming

Shared memory in shared library

I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
Discussion started by: DreamWarrior
12 Replies

3. Programming

Shared memory for shared library

I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability. Obviously, I'll have to worry about mutual exclusion. (0 Replies)
Discussion started by: otheus
0 Replies

4. Red Hat

RHEL5 reboot - error loading shared library

Hi All, I have RHEL 5 installed in my system. Something must has happened because when i reboot the server, it came with many error.. /usr/bin/rhgb-client -- error while loading shared libraries: libpopt.so.0. Can't open shared object files. No such file/directory It finnaly ends with the... (0 Replies)
Discussion started by: c00kie88
0 Replies

5. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

6. Programming

Loading the shared library I want

Hi All I have been given by someone else header file and a shared library to be used by my C++ application. Compilation is fine but when I try to executes the application I receive the following error. ./first: error while loading shared libraries: libMyLib.so.9: cannot open shared object file:... (2 Replies)
Discussion started by: manustone
2 Replies

7. AIX

Loading a shared library in AIX

Hi, I have an application running on AIX. The app is deployed on Webspshere server. Due to some reason, i have to make use of a third party library (Sigar API's) from my application. This library requires an .so file as well. Is there any location where i can put this *.so file and it will... (1 Reply)
Discussion started by: user_guest
1 Replies

8. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies

9. AIX

Add shared members from library to same library in a different directory

I'm trying to install libiconv to AIX 7.1 from an rpm off of the perzl site. The rpm appears to install but I get this error message. add shr4.o shared members from /usr/lib/libiconv.a to /opt/freeware/lib/libiconv.a add shr.o shared members from /usr/lib/libiconv.a to ... (5 Replies)
Discussion started by: kneemoe
5 Replies

10. Programming

Error while loading shared libraries

I am trying to run a C++ program which uses a static library libprun.a. During compilation, I am loading this library file using a environment variable as below. LIBDIR = ${CUSTOM_PATH}/lib LOADLIBS = $(LIBDIR)/libgqlcomm.a \ $(LIBDIR)/libgsml.a \ ... (7 Replies)
Discussion started by: vdivb
7 Replies
STRIP(1)						      General Commands Manual							  STRIP(1)

NAME
strip - remove symbols SYNOPSIS
strip [ option ] name ... DESCRIPTION
strip removes or modifies the symbol table attached to the output of the assembler and link editor. This is useful to save space after a program has been debugged and to limit dynamically bound symbols. strip no longer removes relocation entries under any condition. Instead, it updates the external relocation entries (and indirect symbol table entries) to reflect the resulting symbol table. strip prints an error message for those symbols not in the resulting symbol table that are needed by an external relocation entry or an indirect symbol table. The link editor ld(1) is the only program that can strip relocation entries and know if it is safe to do so. When strip is used with no options on an executable file, it checks that file to see if it uses the dynamic link editor. If it does, the effect of the strip command is the same as using the -u and -r options. If the file does not use the dynamic link editor, the effect of strip without any options is the same as using the -s option of ld(1). The options -S, -x, and -X have the same effect as the ld(1) options. The options to strip(1) can be combined to trim the symbol table to just what is desired. You should trim the symbol table of files used with dynamic linking so that only those symbols intended to be external interfaces are saved. Files used with dynamic linking include executables, objects that are loaded (usually bundles), and dynamic shared libraries. Only global symbols are used by the dynamic linking process. You should strip all non-global symbols. When an executable is built with all its dependent dynamic shared libraries, it is typically stripped with: % strip -u -r executable which saves all undefined symbols (usually defined in the dynamic shared libraries) and all global symbols defined in the executable refer- enced by the dynamic libraries (as marked by the static link editor when the executable was built). This is the maximum level of striping for an executable that will still allow the program to run correctly with its libraries. If the executable loads objects, however, the global symbols that the objects reference from the executable also must not be stripped. In this case, you should list the global symbols that the executable wants to allow the objects to reference in a file, and those global sym- bols are then saved when the executable is stripped. For example: % strip -u -r -s interface_symbols executable where the file interface_symbols would contain only those global symbols from the executable that the executable wants the loaded objects to have access to. For objects that will be loaded into an executable, you should trim the symbol table to limit the global symbols the executable will see. This would be done with: % strip -s interface_symbols -u object which would leave only the undefined symbols and symbols listed in the file interface_symbols in the object file. In this case, strip(1) has updated the relocation entries and indirect symbol table to reflect the new symbol table. For dynamic shared libraries, the maximum level of stripping is usually -x (to remove all non-global symbols). STRIPPING FILES FOR USE WITH RUNTIME LOADED CODE
Trimming the symbol table for programs that load code at runtime allows you to control the interface that the executable wants to provide to the objects that it will load; it will not have to publish symbols that are not part of its interface. For example, an executable that wishes to allow only a subset of its global symbols but all of the statically linked shared library's globals to be used would be stripped with: % strip -s interface_symbols -A executable where the file interface_symbols would contain only those symbols from the executable that it wishes the code loaded at runtime to have access to. Another example is an object that is made up of a number of other objects that will be loaded into an executable would built and then stripped with: % ld -o relocatable.o -r a.o b.o c.o % strip -s interface_symbols -u relocatable.o which would leave only the undefined symbols and symbols listed in the file interface_symbols in the object file. In this case strip(1) has updated the relocation entries to reflect the new symbol table. OPTIONS
The first set of options indicate symbols that are to be save in the resulting output file. -u Save all undefined symbols. This is intended for use with relocatable objects to save symbols referred to by external relocation entries. Note that common symbols are also referred to by external relocation entries and this flag does not save those symbols. -r Save all symbols referenced dynamically. -s filename Save the symbol table entries for the global symbols listed in filename. The symbol names listed in filename must be one per line. Leading and trailing white space are not part of the symbol name. Lines starting with # are ignored, as are lines with only white space. -R filename Remove the symbol table entries for the global symbols listed in filename. This file has the same format as the -s filename option above. This option is usually used in combination with other options that save some symbols, -S, -x, etc. -i Ignore symbols listed in the -s filename or -R filename options that are not in the files to be stripped (this is normally an error). -d filename Save the debugging symbol table entries for each source file name listed in filename. The source file names listed in filename must be one per line with no other white space in the file except the newlines on the end of each line. And they must be just the base name of the source file without any leading directories. -A Save all global absolute symbols except those with a value of zero, and save Objective C class symbols. This is intended for use of programs that load code at runtime and want the loaded code to use symbols from the shared libraries (this is only used with NEXTSTEP 3.3 and earlier releases). -n Save all N_SECT global symbols. This is intended for use with executable programs in combination with -A to remove the symbols needed for correct static link editing which are not needed for use with runtime loading interfaces where using the -s filename would be too much trouble (this is only used with NEXTSTEP 3.3 and earlier releases). These options specify symbols to be removed from the resulting output file. -S Remove the debugging symbol table entries (those created by the -g option to cc(1) and other compilers). -X Remove the local symbols whose names begin with `L'. -x Remove all local symbols (saving only global symbols). -c Remove the section contents of a dynamic library creating a stub library output file. And the last options: - Treat all remaining arguments as file names and not options. -o output Write the result into the file output. SEE ALSO
ld(1), cc(1) LIMITATIONS
Not every layout of a Mach-O file can be stripped by this program. But all layouts produced by the Apple compiler system can be stripped. Apple Computer, Inc. April 21, 2001 STRIP(1)
All times are GMT -4. The time now is 11:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy