public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "rui314 at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug backtrace/29074] New: gdb fails to find a shared library for a function
Date: Wed, 20 Apr 2022 06:20:19 +0000	[thread overview]
Message-ID: <bug-29074-4717@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-04-20  6:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20  6:20 rui314 at gmail dot com [this message]
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

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=bug-29074-4717@http.sourceware.org/bugzilla/ \
    --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: link
Be 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).