Bug 15079 - GDB loads local symbol file if it cannot find a matching file in sysroot/solib-search-path (both set).
Summary: GDB loads local symbol file if it cannot find a matching file in sysroot/soli...
Status: RESOLVED WORKSFORME
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: archer
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-29 14:22 UTC by sagovic
Modified: 2013-02-19 10:23 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sagovic 2013-01-29 14:22:32 UTC
Setting sysroot[1] allows one to use an alternative system root for the program being debugged. Using it in combination with solib-search-path unfortunately leak in the local / system root if no matching library was found in the search path. In a cross debugging scenario this yield the following warning as GDB load the host libraries instead of the target ones:

warning: `/usr/lib/libfoobar.so': Shared library architecture FOO is not compatible with target architecture BAR.

[1] http://sourceware.org/gdb/current/onlinedocs/gdb/Files.html#index-set-sysroot-1077

Set sysroot
-----------
$ gdb -q -ex "set sysroot /foo/bar" -ex "file /bin/true" -ex run
Reading symbols from /bin/true...(no debugging symbols found)...done.
Starting program: /bin/true
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

GDB could not find any matching solibs in the set sysroot, which is expected at least to me.


Set sysroot and solib-search-path
---------------------------------
$ gdb -q -ex "set sysroot /foo/bar" -ex "set solib-search-path /foo/bar" -ex "file /bin/true" -ex run
Reading symbols from /bin/true...(no debugging symbols found)...done.
Starting program: /bin/true

In this case GDB resolved the solibs via the / system root and thus break the sysroot jail.
Comment 1 Pedro Alves 2013-02-05 13:22:00 UTC
Hmm, sounds about the same as:

http://sourceware.org/ml/gdb-patches/2012-09/msg00665.html

Do you have that patch? What's your GDB version?
Comment 2 sagovic 2013-02-19 10:23:08 UTC
I`m using archer-fc18. After applying the patch or moving to fsf-head it works.

Thanks.