From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB6533858D35; Mon, 13 Feb 2023 16:17:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB6533858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676305075; bh=KVgHfk58fw2ARq6C1MeCNUB/NsNqlVFttI0GNrMSPBA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jT2jeqLsAN00WReLwQaLnffS3stoo0QwAlvN0Bb58sla8keANww+yqRwFR4kdHMkl DobmPUzrov+ej0coU1mWAwjNL5x2oSjs2P/BhJ+0c4va4s4p5wGe7Z49pL2svYc0r7 Gd6kuKkIgdJVwNy/Kbkxu5lzoN57eimJli6G8844= From: "corinna at vinschen dot de" To: gdb-prs@sourceware.org Subject: [Bug win32/18027] dwarf2 debug info after rebasing DLLs unusable Date: Mon, 13 Feb 2023 16:17:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: win32 X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: corinna at vinschen dot de X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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=3D18027 --- Comment #5 from Corinna Vinschen --- (In reply to Simon Marchi from comment #4) > Can you post a session of this working? I don't understand how the debug > info being separate changes this behavior. I'd be interested in seeing t= he > output of "info breakpoint", to see how GDB placed the same breakpoints as > you placed in other sessions. Ok, so here's the same DLL, stripped at package creation time, installed into /usr/bin, and rebased to 0x300000000: ---------------------------------------------------------------------------= --- $ objdump -h /usr/bin/cygmagic-1.dll /bin/cygmagic-1.dll: file format pei-x86-64 Sections: Idx Name Size VMA LMA File off A= lgn 0 .text 0001d5e8 0000000300001000 0000000300001000 00000400 2= **4 CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA 1 .data 000001c0 000000030001f000 000000030001f000 0001da00 2= **4 CONTENTS, ALLOC, LOAD, DATA 2 .rdata 000065f8 0000000300020000 0000000300020000 0001dc00 2= **4 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .buildid 00000035 0000000300027000 0000000300027000 00024200 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .pdata 000009e4 0000000300028000 0000000300028000 00024400 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 5 .xdata 00000ab4 0000000300029000 0000000300029000 00024e00 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 6 .bss 000004d0 000000030002a000 000000030002a000 00000000 2= **4 ALLOC 7 .edata 00000c75 000000030002b000 000000030002b000 00025a00 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 8 .idata 00001214 000000030002c000 000000030002c000 00026800 2= **2 CONTENTS, ALLOC, LOAD, DATA 9 .reloc 000001f4 000000030002e000 000000030002e000 00027c00 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 10 .gnu_debuglink 00000018 000000030002f000 000000030002f000 00027e00 = 2**2 CONTENTS, READONLY, DEBUGGING ---------------------------------------------------------------------------= --- Debuginfo split off at package creation time with default addresses for this DLL intact: ---------------------------------------------------------------------------= --- $ $ objdump -h /usr/lib/debug/usr/bin/cygmagic-1.dll.dbg /usr/lib/debug/usr/bin/cygmagic-1.dll.dbg: file format pei-x86-64 Sections: Idx Name Size VMA LMA File off A= lgn 0 .text 0001d5e8 00000004d9221000 00000004d9221000 00000000 2= **4 ALLOC, LOAD, READONLY, CODE, DATA 1 .data 000001c0 00000004d923f000 00000004d923f000 00000000 2= **4 ALLOC, LOAD, DATA 2 .rdata 000065f8 00000004d9240000 00000004d9240000 00000000 2= **4 ALLOC, LOAD, READONLY, DATA 3 .buildid 00000035 00000004d9247000 00000004d9247000 00000600 2= **2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .pdata 000009e4 00000004d9248000 00000004d9248000 00000000 2= **2 ALLOC, LOAD, READONLY, DATA 5 .xdata 00000ab4 00000004d9249000 00000004d9249000 00000000 2= **2 ALLOC, LOAD, READONLY, DATA 6 .bss 000004d0 00000004d924a000 00000004d924a000 00000000 2= **4 ALLOC 7 .edata 00000c75 00000004d924b000 00000004d924b000 00000000 2= **2 ALLOC, LOAD, READONLY, DATA 8 .idata 00001214 00000004d924c000 00000004d924c000 00000000 2= **2 ALLOC, LOAD, DATA 9 .reloc 000001f4 00000004d924e000 00000004d924e000 00000000 2= **2 ALLOC, LOAD, READONLY, DATA 10 .debug_aranges 000005d0 00000004d924f000 00000004d924f000 00000800 = 2**0 CONTENTS, READONLY, DEBUGGING 11 .debug_info 0004186a 00000004d9250000 00000004d9250000 00000e00 2= **0 CONTENTS, READONLY, DEBUGGING 12 .debug_abbrev 00005acf 00000004d9292000 00000004d9292000 00042800 2= **0 CONTENTS, READONLY, DEBUGGING 13 .debug_line 000150e4 00000004d9298000 00000004d9298000 00048400 2= **0 CONTENTS, READONLY, DEBUGGING 14 .debug_frame 000056a0 00000004d92ae000 00000004d92ae000 0005d600 2= **0 CONTENTS, READONLY, DEBUGGING 15 .debug_str 0000055b 00000004d92b4000 00000004d92b4000 00062e00 2= **0 CONTENTS, READONLY, DEBUGGING 16 .debug_line_str 00003107 00000004d92b5000 00000004d92b5000 00063400= =20 2**0 CONTENTS, READONLY, DEBUGGING 17 .debug_loclists 000211c5 00000004d92b9000 00000004d92b9000 00066600= =20 2**0 CONTENTS, READONLY, DEBUGGING 18 .debug_rnglists 000025a9 00000004d92db000 00000004d92db000 00087800= =20 2**0 CONTENTS, READONLY, DEBUGGING 19 .gnu_debuglink 0000000c 00000004d92de000 00000004d92de000 00089e00 = 2**2 CONTENTS, READONLY, DEBUGGING ---------------------------------------------------------------------------= --- Now let's debug it: ---------------------------------------------------------------------------= --- $ gdb /usr/bin/file GNU gdb (GDB) (Cygwin 12.1-1) 12.1 [...] Reading symbols from /usr/bin/file... Reading symbols from /usr/lib/debug//usr/bin/file.exe.dbg... (gdb) sta /usr/bin/file.exe Temporary breakpoint 1 at 0x100402400: file /usr/src/debug/file-5.44-1/src/file.c, line 192. Starting program: /usr/bin/file /usr/bin/file.exe [...] Thread 1 "file" hit Temporary breakpoint 1, main (argc=3D2, argv=3D0x7ffffc= c40) at /usr/src/debug/file-5.44-1/src/file.c:192 192 { (gdb) br file_fsmagic Breakpoint 2 at 0x3000173b0: file /usr/src/debug/file-5.44-1/src/fsmagic.c, line 107. (gdb) c Continuing. [New Thread 2960.0x2164] [New Thread 2960.0xbe8] Thread 1 "file" hit Breakpoint 2, file_fsmagic (ms=3Dms@entry=3D0xa00001710, fn=3Dfn@entry=3D0x7ffffcc79 "/usr/bin/file.exe", sb=3Dsb@entry=3D0x7ffffc98= 0) at /usr/src/debug/file-5.44-1/src/fsmagic.c:107 107 { (gdb) info br info br Num Type Disp Enb Address What 2 breakpoint keep y 0x00000003000173b0 in file_fsmagic at /usr/src/debug/file-5.44-1/src/fsmagic.c:107 breakpoint already hit 1 time (gdb) ---------------------------------------------------------------------------= --- As an extra datapoint, if ASLR is active for this DLL, it can be moved to any arbitrary free address by the OS, without GDB choking on that load address. For instance: ---------------------------------------------------------------------------= --- (gdb) br file_fsmagic Breakpoint 2 at 0x7fff658e73b0: file /usr/src/debug/file-5.44-1/src/fsmagic= .c, line 107. (gdb) c Continuing. [New Thread 5988.0xe40] [New Thread 5988.0xe80] Thread 1 "file" hit Breakpoint 2, file_fsmagic (ms=3Dms@entry=3D0xa00001770, fn=3Dfn@entry=3D0x7ffffcc7e "file.exe", sb=3Dsb@entry=3D0x7ffffc950) at /usr/src/debug/file-5.44-1/src/fsmagic.c:107 107 { (gdb) info br Num Type Disp Enb Address What 2 breakpoint keep y 0x00007fff658e73b0 in file_fsmagic at /usr/src/debug/file-5.44-1/src/fsmagic.c:107 breakpoint already hit 1 time ---------------------------------------------------------------------------= --- For the unstripped DLL, this is also true... as long as it hasn't been rebased! If the unstripped DLL got rebased, the same problem occurs for the ASLR'ed address: ---------------------------------------------------------------------------= --- (gdb) br file_fsmagic Breakpoint 2 at 0x7fff658e73c3 (2 locations) (gdb) c Continuing. Warning: Cannot insert breakpoint 2. Cannot access memory at address 0x80013eb073b0 Command aborted. (gdb) ---------------------------------------------------------------------------= --- Does that help? I'm pretty sure the problem is that the dwarf2 debug info contains absolute addresses which don't match the load address of the DLL after rebase. Being loaded to other addresses (ASLR) is taken into account, GDB computes the offset between load address in the file header and actual load address in VM and utilizes it throughout. However, as soon as the DLL gets rebased, the addresses in the debug info and the load address in the DLL header are "off", so the offset computation doesn't work anymore. Just guessing here, of course. Thanks, Corinna --=20 You are receiving this mail because: You are on the CC list for the bug.=