From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25985 invoked by alias); 4 Jan 2010 09:50:17 -0000 Received: (qmail 25973 invoked by uid 22791); 4 Jan 2010 09:50:15 -0000 X-SWARE-Spam-Status: No, hits=1.9 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,HK_OBFDOMREQ,KAM_STOCKTIP X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Jan 2010 09:50:10 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id EC919290001; Mon, 4 Jan 2010 10:50:07 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lFhxbCSh02+f; Mon, 4 Jan 2010 10:50:07 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id B3F7F290021; Mon, 4 Jan 2010 10:50:02 +0100 (CET) Subject: Re: Regression on prelinked-sepdebug-shlibs Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Tristan Gingold In-Reply-To: <20091225200440.GA3747@host0.dyn.jankratochvil.net> Date: Mon, 04 Jan 2010 09:50:00 -0000 Cc: gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <3346A919-88F5-457A-B6D1-0A35EB2C17F1@adacore.com> References: <20091225200440.GA3747@host0.dyn.jankratochvil.net> To: Jan Kratochvil X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00050.txt.bz2 On Dec 25, 2009, at 9:04 PM, Jan Kratochvil wrote: > Hi, >=20 > Re: [RFA] Make sym_read routines handle separate debug files > http://sourceware.org/ml/gdb-patches/2009-12/msg00117.html > http://sourceware.org/ml/gdb-cvs/2009-12/msg00042.html > ffb64a120e667bad7b2a79c5e617bdea7328f996 > * symfile.h (symbol_file_add_separate): New prototype. > (find_separate_debug_file_by_buildid): Ditto. > (find_separate_debug_file_by_debuglink): Ditto. > * symfile.c (reread_separate_symbols): Remove. > (find_separate_debug_file): Split into ... > (find_separate_debug_file_by_buildid): ... this and ... > (find_separate_debug_file_by_debuglink): ... this. > (symbol_file_add_with_addrs_or_offsets): Do not save orig_addrs. > Remove separate debug file handling. > (symbol_file_add_separate): New function. > (reread_symbols): Do not considere separate debug files, but free > them while handling their parent. Reindent. > * coffread.c (coff_symfile_read): Handle separate object file. > * elfread.c (elf_symfile_read): Ditto. >=20 > has caused a regression: > echo 'void f (void) {}'|gcc -Wall -fPIC -shared -g -o a.so -x c -;objcop= y --only-keep-debug a.so a.so.debug;objcopy --strip-debug --add-gnu-debugli= nk=3Da.so.debug a.so;prelink -NR a.so;echo 'extern void f (void);int main (= void) { f (); return 0; }'|gcc -Wall -g -o a ./a.so -x c -;./gdb -nx -ex st= art -ex 'adv f' ./a > printing now: > Cannot access memory at address 0x52c >=20 > prelink will set in-file addresses to some random value while in the .deb= ug > file they remain zero-based. In such case "section_offsets" below will r= emain > zero because the library will (probably) get loaded at the same address a= s the > file is prelinked at. Still the .debug file must be relocated in such ca= se. >=20 >=20 > symbol_file_add_separate calls there now: > 0, /* No addr table. */ > while it supplies: > objfile->section_offsets, objfile->num_sections, >=20 > This cannot work as the binary file and its separate debug info file are = two > different objfiles having different number and ordering of sections. > objfile-independent displacement format is that "addr table". Hi, my understanding is that separate debug info and its binary file have the s= ame ordering of sections, or to be more precise, the separate debug info only appends new debug sections= to the binary file while making content sections empty. In this example, I have: $ readelf -S a.so There are 26 section headers, starting at offset 0x764: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk I= nf Al [ 0] NULL 00000000 000000 000000 00 0 = 0 0 [ 1] .hash HASH 000000b4 0000b4 000098 04 A 2 = 0 4 [ 2] .dynsym DYNSYM 0000014c 00014c 000130 10 A 3 = 10 4 [ 3] .dynstr STRTAB 0000027c 00027c 00006f 00 A 0 = 0 1 [ 4] .gnu.version VERSYM 000002ec 0002ec 000026 02 A 2 = 0 2 [ 5] .gnu.version_r VERNEED 00000314 000314 000020 00 A 3 = 1 4 [ 6] .rel.dyn REL 00000334 000334 000028 08 A 2 = 0 4 [ 7] .rel.plt REL 0000035c 00035c 000010 08 A 2 = 9 4 [ 8] .init PROGBITS 0000036c 00036c 000017 00 AX 0 = 0 4 [ 9] .plt PROGBITS 00000384 000384 000030 04 AX 0 = 0 4 [10] .text PROGBITS 000003c0 0003c0 000114 00 AX 0 = 0 16 [11] .fini PROGBITS 000004d4 0004d4 00001c 00 AX 0 = 0 4 [12] .eh_frame PROGBITS 000004f0 0004f0 000004 00 A 0 = 0 4 [13] .ctors PROGBITS 000014f4 0004f4 000008 00 WA 0 = 0 4 [14] .dtors PROGBITS 000014fc 0004fc 000008 00 WA 0 = 0 4 [15] .jcr PROGBITS 00001504 000504 000004 00 WA 0 = 0 4 [16] .dynamic DYNAMIC 00001508 000508 0000c0 08 WA 3 = 0 4 [17] .got PROGBITS 000015c8 0005c8 00000c 04 WA 0 = 0 4 [18] .got.plt PROGBITS 000015d4 0005d4 000014 04 WA 0 = 0 4 [19] .data PROGBITS 000015e8 0005e8 000008 00 WA 0 = 0 4 [20] .bss NOBITS 000015f0 0005f0 000004 00 WA 0 = 0 4 [21] .comment PROGBITS 00000000 0005f0 00009b 00 0 = 0 1 [22] .gnu_debuglink PROGBITS 00000000 00068b 000010 00 0 = 0 1 [23] .shstrtab STRTAB 00000000 00069b 0000c8 00 0 = 0 1 [24] .symtab SYMTAB 00000000 000b74 000310 10 25 = 40 4 [25] .strtab STRTAB 00000000 000e84 000164 00 0 = 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) $ readelf -S a.so.debug=20 There are 32 section headers, starting at offset 0xa90: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk I= nf Al [ 0] NULL 00000000 000000 000000 00 0 = 0 0 [ 1] .hash NOBITS 000000b4 0000b4 000098 00 A 0 = 0 4 [ 2] .dynsym NOBITS 0000014c 0000b4 000130 00 A 0 = 0 4 [ 3] .dynstr NOBITS 0000027c 0000b4 00006f 00 A 0 = 0 1 [ 4] .gnu.version NOBITS 000002ec 0000b4 000026 00 A 0 = 0 2 [ 5] .gnu.version_r NOBITS 00000314 0000b4 000020 00 A 0 = 0 4 [ 6] .rel.dyn NOBITS 00000334 0000b4 000028 00 A 0 = 0 4 [ 7] .rel.plt NOBITS 0000035c 0000b4 000010 00 A 0 = 0 4 [ 8] .init NOBITS 0000036c 0000b4 000017 00 AX 0 = 0 4 [ 9] .plt NOBITS 00000384 0000b4 000030 00 AX 0 = 0 4 [10] .text NOBITS 000003c0 0000b4 000114 00 AX 0 = 0 16 [11] .fini NOBITS 000004d4 0000b4 00001c 00 AX 0 = 0 4 [12] .eh_frame NOBITS 000004f0 0000b4 000004 00 A 0 = 0 4 [13] .ctors NOBITS 000014f4 0004f4 000008 00 WA 0 = 0 4 [14] .dtors NOBITS 000014fc 0004f4 000008 00 WA 0 = 0 4 [15] .jcr NOBITS 00001504 0004f4 000004 00 WA 0 = 0 4 [16] .dynamic NOBITS 00001508 0004f4 0000c0 00 WA 0 = 0 4 [17] .got NOBITS 000015c8 0004f4 00000c 00 WA 0 = 0 4 [18] .got.plt NOBITS 000015d4 0004f4 000014 00 WA 0 = 0 4 [19] .data NOBITS 000015e8 0004f4 000008 00 WA 0 = 0 4 [20] .bss NOBITS 000015f0 0004f4 000004 00 WA 0 = 0 4 [21] .comment PROGBITS 00000000 0004f4 00009b 00 0 = 0 1 [22] .debug_aranges PROGBITS 00000000 000590 000078 00 0 = 0 8 [23] .debug_pubnames PROGBITS 00000000 000608 000018 00 0 = 0 1 [24] .debug_info PROGBITS 00000000 000620 000173 00 0 = 0 1 [25] .debug_abbrev PROGBITS 00000000 000793 000047 00 0 = 0 1 [26] .debug_line PROGBITS 00000000 0007da 000146 00 0 = 0 1 [27] .debug_frame PROGBITS 00000000 000920 00002c 00 0 = 0 4 [28] .debug_loc PROGBITS 00000000 00094c 00002c 00 0 = 0 1 [29] .shstrtab STRTAB 00000000 000978 000116 00 0 = 0 1 [30] .symtab SYMTAB 00000000 000f90 000410 10 31 = 56 4 [31] .strtab STRTAB 00000000 0013a0 0001e4 00 0 = 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Also, if you look at symfile.c:reread_separate_symbols (before my patch), t= here was this code: /* If the new objfile has separate debug info, and we haven't loaded it already, do so now. */ if (debug_file && ! objfile->separate_debug_objfile) { /* Use the same section offset table as objfile itself. Preserve the flags from objfile that make sense. */ objfile->separate_debug_objfile =3D (symbol_file_add_with_addrs_or_offsets (symfile_bfd_open (debug_file), info_verbose ? SYMFILE_VERBOSE : 0, 0, /* No addr table. */ objfile->section_offsets, objfile->num_sections, objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW | OBJF_USERLOADED))); objfile->separate_debug_objfile->separate_debug_objfile_backlink =3D objfile; } As you can see, I kept this semantic (which might be wrong but this is not = my understanding). BTW, where can I find prelink ? Looks like it is not available on RHEL S 5= .2 >=20 > There was some description of these data structures in: > [patch 05/15] PIE: Move some symfile code into subroutines > http://sourceware.org/ml/gdb-patches/2009-11/msg00172.html > [patch 06/15] PIE: Fix displacement of separate debug info files > http://sourceware.org/ml/gdb-patches/2009-11/msg00173.html >=20 > (I see a big conflict now there for my unchecked-in PIE patch, oops.) Will read these patches. > One should probably build temporary addr-table from objfile there. That's a possible solution, but we must first be clear on wether the separa= te debug file has the same sections as its binary file. The main drawback of addr-table is that is it much slower. Tristan.