public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug backtrace/29074] New: gdb fails to find a shared library for a function
@ 2022-04-20  6:20 rui314 at gmail dot com
  2023-07-31 22:18 ` [Bug backtrace/29074] " tromey at sourceware dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rui314 at gmail dot com @ 2022-04-20  6:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29074

            Bug ID: 29074
           Summary: gdb fails to find a shared library for a function
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: backtrace
          Assignee: unassigned at sourceware dot org
          Reporter: rui314 at gmail dot com
  Target Milestone: ---

It looks like gdb sometimes fails to find a shared library name for a function.
My shared library ends with something like this:

ruiu@blue:~/mold$ objdump -d liba.so
<<<omit>>>
0000000000001140 <_ZL5func2i>:
    1140:       55                      push   %rbp
    1141:       48 89 e5                mov    %rsp,%rbp
    1144:       48 83 ec 10             sub    $0x10,%rsp
    1148:       89 7d fc                mov    %edi,-0x4(%rbp)
    114b:       e8 c0 fe ff ff          call   1010 <abort@plt>
ruiu@blue:~/mold$

So, the DSO's text segment ends with a call to `abort`. Since GCC knows `abort`
does not return, it can emit code like this.

When gdb tries to lookup a shared library using a function return address as a
key, the "return address" for the above function is one byte beyond the
executable segment of the DSO. Because of that, gdb fails to find a shared
library for that function. An example output is shown below:

Program received signal SIGABRT, Aborted.
0x00007ffff70b0cdb in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff70b0cdb in raise () from /lib64/libc.so.6
#1 0x00007ffff70b2375 in abort () from /lib64/libc.so.6
#2 0x00007ffff7ff0140 in func2(int) ()
#3 0x00007ffff7ff0123 in func(int) () from ./liba.so
#4 0x0000000000201149 in main () at a1.cpp:2

The third line from the bottom lacks the shared library name.

I believe gdb has to subtract one byte from a return address before using it to
lookup a shared library.

This is originally reported at https://github.com/rui314/mold/issues/444

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-26 16:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20  6:20 [Bug backtrace/29074] New: gdb fails to find a shared library for a function rui314 at gmail dot com
2023-07-31 22:18 ` [Bug backtrace/29074] " tromey at sourceware dot org
2023-07-31 22:47 ` sam at gentoo dot org
2023-08-01 21:12 ` tromey at sourceware dot org
2023-08-03 17:18 ` tromey at sourceware dot org
2023-08-04 17:37 ` tromey at sourceware dot org
2023-08-26 16:34 ` cvs-commit at gcc dot gnu.org
2023-08-26 16:35 ` tromey at sourceware dot org

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).