From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2851 invoked by alias); 12 Mar 2010 15:28:49 -0000 Received: (qmail 2842 invoked by uid 22791); 12 Mar 2010 15:28:49 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_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; Fri, 12 Mar 2010 15:28:44 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2CFSaM9018299 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Mar 2010 10:28:36 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2CFSXW6003845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Mar 2010 10:28:35 -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 o2CFSX6s013546; Fri, 12 Mar 2010 16:28:33 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o2CFSVlj013544; Fri, 12 Mar 2010 16:28:31 +0100 Date: Fri, 12 Mar 2010 15:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Daniel Jacobowitz Subject: Re: RFC: Verify AT_ENTRY before using it Message-ID: <20100312152830.GA13120@host0.dyn.jankratochvil.net> References: <20100224224913.GA25437@caradoc.them.org> <20100225221620.GA7830@host0.dyn.jankratochvil.net> <20100226211216.GC2630@caradoc.them.org> <20100301200428.GA14079@host0.dyn.jankratochvil.net> <20100308220635.GC2629@caradoc.them.org> <20100310211138.GA11271@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100310211138.GA11271@host0.dyn.jankratochvil.net> 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-03/txt/msg00453.txt.bz2 On Wed, 10 Mar 2010 22:11:38 +0100, Jan Kratochvil wrote: > It has been checked-in without the warning() calls. [...] > http://sourceware.org/ml/gdb-cvs/2010-03/msg00096.html > > --- src/gdb/ChangeLog 2010/03/10 18:41:37 1.11466 > +++ src/gdb/ChangeLog 2010/03/10 20:50:48 1.11467 > @@ -1,3 +1,16 @@ > +2010-03-10 Jan Kratochvil > + Daniel Jacobowitz > + > + * solib-svr4.c (read_program_header): Support type == -1 to read > + all program headers. > + (read_program_headers_from_bfd): New function. > + (svr4_static_exec_displacement): Remove and move the comment ... > + (svr4_exec_displacement): ... here. Remove variable found. New > + variable displacement. Check also DYNAMIC. Verify DISPLACEMENT > + alignment for ELF targets. Compare target vs. exec_bfd PHDRs for ELF > + targets using read_program_headers_from_bfd. Remove the call of > + svr4_static_exec_displacement. Is it OK also for gdb_7_1-branch? Otherwise the minimized attached patch also works for me. Still I would prefer the full patch from the master branch. No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. Thanks, Jan gdb/ 2010-03-12 Jan Kratochvil * solib-svr4.c (svr4_relocate_main_executable): Delay the svr4_exec_displacement call. Return on non-DYNAMIC exec_bfd. --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1719,7 +1719,15 @@ svr4_exec_displacement (void) static void svr4_relocate_main_executable (void) { - CORE_ADDR displacement = svr4_exec_displacement (); + CORE_ADDR displacement; + + /* Therefore for ELF it is ET_EXEC and not ET_DYN. Both shared libraries + being executed themselves and PIE (Position Independent Executable) + executables are ET_DYN. */ + if (exec_bfd && (bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0) + return; + + displacement = svr4_exec_displacement (); /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new difference of in-memory vs. in-file addresses and we could already