From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4700 invoked by alias); 7 Jul 2010 18:49:57 -0000 Received: (qmail 4678 invoked by uid 22791); 7 Jul 2010 18:49:55 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail1-relais-roc.national.inria.fr (HELO mail1-relais-roc.national.inria.fr) (192.134.164.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 18:49:49 +0000 Received: from 98.225.194-77.rev.gaoland.net (HELO [192.168.1.2]) ([77.194.225.98]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 07 Jul 2010 20:49:45 +0200 Subject: impossible to resolve symbols in same binary loaded twice with dlmopen From: Mathieu Lacage To: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary="=-NewI4ZzG79zzuvkrOhg3" Date: Wed, 07 Jul 2010 18:49:00 -0000 Message-ID: <1278528582.10151.23.camel@localhost.localdomain> Mime-Version: 1.0 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-07/txt/msg00121.txt.bz2 --=-NewI4ZzG79zzuvkrOhg3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 1586 hi, A couple of months ago, I reported on the gdb mailing-list this issue: http://sourceware.org/ml/gdb/2010-02/msg00027.html (the original report mentionned a crash which happened with a different program loader but the root cause of the problem is the same as the one mentionned here) and tom tromey gave hints on how it could be fixed. It took me a while to eventually put together a patch and a reduced testcase for this issue but here it is in the bugzilla database: http://sourceware.org/bugzilla/show_bug.cgi?id=11766 For convenience, this email contains the reduced testcase and patch attached. Here is the associated ChangeLog entry: 2010-XX-XX Mathieu Lacage Fix PR/gdb 11766: gdb does not resolve correctly symbols in binaries loaded twice with dlmopen Because the name of an inferior binary present in the linkmap is not sufficient for the test of uniqueness, of an entry in the list of objfiles, we ensure uniqueness with an extra equality condition, the addr_low member of the binary. * gdb/objfiles.h: add addr_low member variable * gdb/solib.c (solib_read_symbols): check for addr_low in equality test for objfile, initialize addr_low if needed. I really care about fixing this issue because it hits me and a lot of my users and asking them to recompile gdb with a patch is not fun in the long run. I am looking forward to fix this upstream so, please, let me know what I can do to help with the resolution of this issue. Mathieu -- Mathieu Lacage Tel: +33 4 9238 5056 --=-NewI4ZzG79zzuvkrOhg3 Content-Type: application/x-compressed-tar; name="test.tar.gz" Content-Disposition: attachment; filename="test.tar.gz" Content-Transfer-Encoding: base64 Content-length: 915 H4sIAAHcKUwAA+2WbU/bMBDH+xZ/ilPpi6RrSx6aRiorGioMTWqZBEPTNrEq Dw6N5sQoSZEmxD77zklaCoOxTSrTtPu9iBP77uzcxX+n4Hmx09gsBuK6TtUO +nfamoZp9k3Ldhx34DYM03TtfgOcDa+rZJEXXgbQSLxiHvPFo3ZPjf+jFKr+ IvZV2ws2M4cq8OBe3dfrb1rusv59w7Cx/rZjYf2NzSznLv95/eO0gEhK0K5k HOrsmgFkvFhkKRi77IapYR/zszYczPG5fQkjZQFrd+t+f/u1iF+k3P+b3PyN J/e/afXt1f4fWEr/bcMxaf8/B9shj+KUw+zo+Gx2+vbsZHwIJtuO00AsQg4v QxEFaW++t9aVF6EvpVCdDJNXxAEodYDAE6ISCmjPOxDINC9qtUi9hFfqoQRF a0epXkuKEo4oRQnRqhG96tZDkX9NQMM4pW9tpulKXEpVSrw4rZy87CLo1BPh /dWn82oqtUgI5T4GL7IFVyHiCLS8yILkErTS1DzvQNNr6jBCEdPRAuC6vMI9 T4AbvHKR80eC+D8JEnnodxulSpGHA6FI5CXH95hMZ28OZseH7ydTjNVbnci5 bHbg5N3kYDbZ//ihTEPl7f+Rd50CXNXdZVal89AZz4KmvvtDN54By+5lHh4I 4D8cwL8fAJtQBEJiMjWv7F09+tUq6Sx5Jkr9n3pfUAUE39AcT/3/WX1r9f9v DMr/P9txSf+fg/Hryf7R6ah7YTOGm3UI6oOAWwFhTN0MYXJQGr4YdUUoGLs1 GK6MJdtqaeOxDi2tttahm6Ms8xC6ElqvoPWZsUBwLx2yrSyBbgTtnlybrJq8 /Q2svZ2QX+2kCyFo+xMEQRAEQRAEQRAEQRAEQRAEQfwW3wFua4JRACgAAA== --=-NewI4ZzG79zzuvkrOhg3 Content-Disposition: attachment; filename="patch" Content-Type: text/plain; name="patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 1774 ? objdir ? patch Index: gdb/objfiles.h =================================================================== RCS file: /cvs/src/src/gdb/objfiles.h,v retrieving revision 1.72 diff -c -p -r1.72 objfiles.h *** gdb/objfiles.h 14 Apr 2010 17:26:11 -0000 1.72 --- gdb/objfiles.h 7 Jul 2010 18:35:38 -0000 *************** struct objfile *** 193,198 **** --- 193,200 ---- char *name; + CORE_ADDR addr_low; + /* Some flag bits for this objfile. */ unsigned short flags; Index: gdb/solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.140 diff -c -p -r1.140 solib.c *** gdb/solib.c 16 May 2010 23:49:58 -0000 1.140 --- gdb/solib.c 7 Jul 2010 18:35:39 -0000 *************** solib_read_symbols (struct so_list *so, *** 634,644 **** TRY_CATCH (e, RETURN_MASK_ERROR) { struct section_addr_info *sap; - /* Have we already loaded this shared object? */ ALL_OBJFILES (so->objfile) { ! if (strcmp (so->objfile->name, so->so_name) == 0) break; } if (so->objfile != NULL) --- 634,644 ---- TRY_CATCH (e, RETURN_MASK_ERROR) { struct section_addr_info *sap; /* Have we already loaded this shared object? */ ALL_OBJFILES (so->objfile) { ! if (strcmp (so->objfile->name, so->so_name) == 0 ! && so->objfile->addr_low == so->addr_low) break; } if (so->objfile != NULL) *************** solib_read_symbols (struct so_list *so, *** 648,653 **** --- 648,654 ---- so->sections_end); so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); + so->objfile->addr_low = so->addr_low; free_section_addr_info (sap); } --=-NewI4ZzG79zzuvkrOhg3--