From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B7E813858C56; Fri, 12 Apr 2024 11:38:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7E813858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712921892; bh=PeBKW+ojWld76S4qBqhgBgE481WltIkqgA3Ky4gGwrs=; h=From:To:Subject:Date:From; b=Phn0Za8Z5+tTtCfXas8BnZJDFjqxngcBFeQkEmDwLe6LxhzhSQYIa2ZnpqIkuhYDk PxBEi6JfMdzF7Xl99ESkA4MsPq6F3vuMYgEaN4v2xJT6/6k9/x89pJ01PYg1F524bV hm+tfHRo8jr2bbH9ntGrsyzn0y08IgOBTTx8s29Y= From: "pablogsal at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug corefiles/31634] New: gdb doesn't correctly fetch the soname of shared libraries Date: Fri, 12 Apr 2024 11:38:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: corefiles X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pablogsal 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31634 Bug ID: 31634 Summary: gdb doesn't correctly fetch the soname of shared libraries Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: corefiles Assignee: unassigned at sourceware dot org Reporter: pablogsal at gmail dot com Target Milestone: --- Looks like gdb_bfd_read_elf_soname fails to correctly fetch the soname of s= ome libraries. For example, consider the following: $ cat main.c extern void foo(int); int main() { foo(13); return 0; } $ cat foo.c #include void foo(int x); void foo1(int x); void foo2(int x); void foo3(int x); void foo(int x) { return foo1(x); } void foo1(int x) { return foo2(x); } void foo2(int x) { return foo3(x); } void foo3(int x) { sleep(1000); } $ gcc foo.c -o libfoo.so --shared -fPIC -g3 -O0 -Wl,-hlibfoo.so $ gcc main.c -g3 -O0 -lfoo -L . $ gdb ./a.out Reading symbols from ./a.out... (gdb) r Starting program: /home/pablogsal/github/binutils-gdb/lel/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". ^C Program received signal SIGINT, Interrupt. 0x00007ffff7e792f7 in clock_nanosleep () from /usr/lib/libc.so.6 (gdb) gcore warning: Memory read failed for corefile section, 4096 bytes at 0xffffffffff600000. Saved corefile core.1263203 $ gdb --args --gdb -c core.1263203 -e ./a.out (gdb) b gdb_bfd_read_elf_soname (gdb) r ... Thread 1 "gdb" hit Breakpoint 1, gdb_bfd_read_elf_soname (filename=3D0x5555563acf50 "/home/pablogsal/github/binutils-gdb/lel/libfoo.= so") at solib.c:1600 1600 { (gdb) finish ... Value returned is $1 =3D std::unique_ptr =3D {get() =3D 0x55555631c340 "gisterTMCloneTable"} As you can see the returned soname is some garbage (gisterTMCloneTable) but= the real soname is correctly set: $ readelf -d libfoo.so Dynamic section at offset 0x2df8 contains 25 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000e (SONAME) Library soname: [libfoo.so] ... --=20 You are receiving this mail because: You are on the CC list for the bug.=