From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18534 invoked by alias); 11 Feb 2010 22:21:23 -0000 Received: (qmail 18523 invoked by uid 22791); 11 Feb 2010 22:21:22 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Feb 2010 22:21:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1BMLGDo012322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Feb 2010 17:21:16 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1BMLDfN007110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Feb 2010 17:21:15 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o1BMLDbv004645; Thu, 11 Feb 2010 23:21:13 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1BMLDgw004644; Thu, 11 Feb 2010 23:21:13 +0100 Date: Thu, 11 Feb 2010 22:21:00 -0000 From: Jan Kratochvil To: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [patch] Sanity check PIE displacement (like the PIC one) Message-ID: <20100211222113.GA31323@host0.dyn.jankratochvil.net> References: <20100201012004.GA6015@host0.dyn.jankratochvil.net> <20100211200506.GA24110@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100211200506.GA24110@caradoc.them.org> User-Agent: Mutt/1.5.20 (2009-08-17) 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-02/txt/msg00305.txt.bz2 On Thu, 11 Feb 2010 21:05:11 +0100, Daniel Jacobowitz wrote: > On Thu, Feb 11, 2010 at 12:43:00PM -0700, Tom Tromey wrote: > > Jan> The current PIC message being printed "all the time" is: > > Jan> warning: .dynamic section for "/lib64/librt-2.11.1.so" is not at the expected address > > Jan> warning: difference appears to be caused by prelink, adjusting expectations > > [...] > > Jan> I do not find the current PIC message too useful (moreover without > > Jan> any offset printed). Therefore I am open to removing both the PIC > > Jan> (and new PIE) messages when the offset is successfuly considered as > > Jan> valid. > > > > I don't find that PIC message particularly useful, either. > > Is there some situation where that information is helpful? > > If not, then IMO we should remove it. > > Under what circumstances would you remove it? I'd favor removing the > former warning when the second one would be printed, but not otherwise. > > The first message is a real life-saver. It triggers when you have the > wrong C library when loading a core file or using a sysroot. solib-svr4.c LM_ADDR_CHECK if ((l_addr & align) == ((l_dynaddr - dynaddr) & align)) { A1: warning (_(".dynamic section for \"%s\" " "is not at the expected address"), so->so_name); A2: warning (_("difference appears to be caused by prelink, " "adjusting expectations")); } else B: warning (_(".dynamic section for \"%s\" " "is not at the expected address " "(wrong library or version mismatch?)"), so->so_name); I got lost in what specific messages got referenced by these mails. The life-saver message is IMO "B" but the message(s) being discussed to be removed is A1+A2. Is the attached patch what everone agrees upon or have I not understood it? No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan gdb/ 2010-02-11 Jan Kratochvil * solib-svr4.c: Include gdbcmd.h. (solib_svr4_debug): New. (LM_ADDR_CHECK): Print successful prelink adjustment only if SOLIB_SVR4_DEBUG. (_initialize_svr4_solib): Register solib_svr4_debug. gdb/testsuite/ 2010-02-11 Jan Kratochvil * gdb.base/prelink.exp (set debug solib-svr4 1): New. --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -35,6 +35,7 @@ #include "regcache.h" #include "gdbthread.h" #include "observer.h" +#include "gdbcmd.h" #include "gdb_assert.h" @@ -48,6 +49,9 @@ #include "auxv.h" #include "exceptions.h" +/* Flag which indicates whether internal debug messages should be printed. */ +static int solib_svr4_debug; + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); static int svr4_have_link_map_offsets (void); static void svr4_relocate_main_executable (void); @@ -222,10 +226,13 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd) { l_addr = l_dynaddr - dynaddr; - warning (_(".dynamic section for \"%s\" " - "is not at the expected address"), so->so_name); - warning (_("difference appears to be caused by prelink, " - "adjusting expectations")); + if (solib_svr4_debug) + { + warning (_(".dynamic section for \"%s\" " + "is not at the expected address"), so->so_name); + warning (_("difference appears to be caused by prelink, " + "adjusting expectations")); + } } else warning (_(".dynamic section for \"%s\" " @@ -2033,4 +2040,14 @@ _initialize_svr4_solib (void) svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; svr4_so_ops.same = svr4_same; svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core; + + /* Debug this file's internals. */ + add_setshow_zinteger_cmd ("solib-svr4", class_maintenance, + &solib_svr4_debug, _("\ +Set internal debugging of shared library code for SVR4."), _("\ +Show internal debugging of shared library code for SVR4."), _("\ +When non-zero, SVR4 solib specific internal debugging is enabled."), + NULL, + NULL, + &setdebuglist, &showdebuglist); } --- a/gdb/testsuite/gdb.base/prelink.exp +++ b/gdb/testsuite/gdb.base/prelink.exp @@ -109,6 +109,9 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +# Print the "adjusting expectations" message. +gdb_test "set debug solib-svr4 1" + set test "prelink" global gdb_prompt gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {