From patchwork Fri Dec 5 18:29:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 4087 Received: (qmail 28956 invoked by alias); 5 Dec 2014 18:29:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28942 invoked by uid 89); 5 Dec 2014 18:29:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Dec 2014 18:29:30 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB5ITSiH023280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 5 Dec 2014 13:29:29 -0500 Received: from host2.jankratochvil.net (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sB5ITP6s007735 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO) for ; Fri, 5 Dec 2014 13:29:27 -0500 Date: Fri, 5 Dec 2014 19:29:25 +0100 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch 15/14] GDB/GCC compile function pointers [Re: [PATCH v4 00/14] let gdb reuse gcc's C compiler] Message-ID: <20141205182925.GA25151@host2.jankratochvil.net> References: <20141123192713.32193.57150.stgit@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141123192713.32193.57150.stgit@host1.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, not sure if it is already approved or under review but here is one fix-up of the submitted code. To be integrated during check-in. Jan diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 6d3d16e..bb6705f 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -636,12 +636,13 @@ String quoting is parsed like in shell, for example:\n\ /* Override flags possibly coming from DW_AT_producer. */ compile_args = xstrdup ("-O0 -gdwarf-4" - /* We use -fPIC Otherwise GDB would need to reserve space large enough for + /* We use -fPIE Otherwise GDB would need to reserve space large enough for any object file in the inferior in advance to get the final address when to link the object file to and additionally the default system linker script would need to be modified so that one can specify there the - absolute target address. */ - " -fPIC" + absolute target address. + -fPIC is not used at is would require from GDB to generate .got. */ + " -fPIE" /* We don't want warnings. */ " -w" /* Override CU's possible -fstack-protector-strong. */ diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index d0dd791..fb8b390 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -259,6 +259,11 @@ gdb_test_no_output "end" "compile code -r multiline 4" gdb_test "print 'compile.c'::globalshadow" " = 77000" \ "check globalshadow with -r" +# Test GOT vs. resolving jit function pointers. + +gdb_test_no_output "compile -raw -- int func(){return 21;} _gdb_expr(){int (*funcp)()=func; if (funcp()!=21) abort();}" \ + "pointer to jit function" + # # Test the case where the registers structure would not normally have # any fields.