public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "lance604 at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug symtab/11717] New: common/.bss variables from shared libraries not displayed correctly Date: Fri, 18 Jun 2010 13:25:00 -0000 [thread overview] Message-ID: <20100618132513.11717.lance604@gmail.com> (raw) Observed with version 7.0-ubuntu under Kubuntu 9.10 with gcc version 4.4.1. Also occurs for gdb 6.8 and gcc version 4.4.3 in x86_64 hosted MIPS cross-compilation toolchain. Apparently, when linking a shared library which contains a variable in .bss with an executable referencing that variable, ld allocates space for that variable in the executable's .bss section and creates a duplicate symbol for this variable. The executable's copy of the variable will be used due to the dynamic linker's search order (executable first). However, gdb always used data from the shared library .bss section (always zero) instead of the executable's .bss section. Here's a minimal example: Contents of shared.c: int var; Build shared.c into libshared.so: gcc -g -o libshared.so -fPIC -shared shared.c Contents of executable.c: #include <stdlib.h> extern int var; int main(int argc, char **argv) { var = 42; abort(); return 0; } Build executable: gcc -g -L. -Wl,-rpath,. -o executable -lshared executable.c Display symbols (note that "var" is defined in both files): nm -aA libshared.so executable | grep var libshared.so:0000000000201020 B var executable:0000000000601020 B var GDB session demonstrating problem: gdb executable GNU gdb (GDB) 7.0-ubuntu Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/lrichardson/test/executable...done. (gdb) run Starting program: /home/lrichardson/test/executable Program received signal SIGABRT, Aborted. 0x00007ffff78a04b5 in raise () from /lib/libc.so.6 (gdb) p &var $1 = (int *) 0x7ffff7dde020 (gdb) p var $2 = 0 (gdb) p *(int *)0x601020 $3 = 42 (gdb) info shared From To Syms Read Shared Object Library 0x00007ffff7ddfaf0 0x00007ffff7df7354 Yes (*) /lib64/ld-linux-x86-64.so.2 0x00007ffff7bdd4a0 0x00007ffff7bdd5a8 Yes ./libshared.so 0x00007ffff788b730 0x00007ffff798b7fc Yes (*) /lib/libc.so.6 (*): Shared library is missing debugging information. Note that &var and the value of var (zero) come from the shared library's version of the variable. Using the address of var from the executable shows the expected value (42) as modified by the program. -- Summary: common/.bss variables from shared libraries not displayed correctly Product: gdb Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: symtab AssignedTo: unassigned at sourceware dot org ReportedBy: lance604 at gmail dot com CC: gdb-prs at sourceware dot org GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://sourceware.org/bugzilla/show_bug.cgi?id=11717 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next reply other threads:[~2010-06-18 13:25 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-06-18 13:25 lance604 at gmail dot com [this message] 2010-07-12 20:01 ` [Bug symtab/11717] " nbowler at draconx dot ca 2010-07-21 8:43 ` jan dot kratochvil at redhat dot com 2010-07-21 8:55 ` jan dot kratochvil at redhat dot com 2010-08-22 7:41 ` jan dot kratochvil at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100618132513.11717.lance604@gmail.com \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).