From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BE0D33858C83; Wed, 20 Apr 2022 06:20:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE0D33858C83 From: "rui314 at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: backtrace X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rui314 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2022 06:20:19 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29074 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 funct= ion. My shared library ends with something like this: ruiu@blue:~/mold$ objdump -d liba.so <<>> 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 ruiu@blue:~/mold$ So, the DSO's text segment ends with a call to `abort`. Since GCC knows `ab= ort` does not return, it can emit code like this. When gdb tries to lookup a shared library using a function return address a= s 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 i= t to lookup a shared library. This is originally reported at https://github.com/rui314/mold/issues/444 --=20 You are receiving this mail because: You are on the CC list for the bug.=