From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39764 invoked by alias); 9 Oct 2018 08:26:47 -0000 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 Received: (qmail 127239 invoked by uid 89); 9 Oct 2018 08:20:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=March, msp430tdepc, UD:msp430-tdep.c, UD:sh X-HELO: EUR02-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr00087.outbound.protection.outlook.com (HELO EUR02-AM5-obe.outbound.protection.outlook.com) (40.107.0.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Oct 2018 08:20:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mDWsdj0Hau/QHxT17IW6jWU0bBHjvkmN5P/r8DKq2tM=; b=Vhor4SBYrPKZkyCd25GTzmn5Yb9o4e9weGmnK0zell0Q6ptrveOq75p0MvFm5yGU2MNNdsFAP6Mb9tCh63sxgkMOQ7B2D5He+GMOASgi9GslcEfjR9QfFYOuaOPqvDz77LboEx8am8WKz4AnIIzN+h3p06bx8y8ijagWLjhdwsA= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.226.148) by DB6PR0802MB2517.eurprd08.prod.outlook.com (10.172.251.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.21; Tue, 9 Oct 2018 08:20:52 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::7073:f11c:4e4:cb13]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::7073:f11c:4e4:cb13%5]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 08:20:52 +0000 From: Alan Hayward To: GDB Patches CC: nd Subject: [PING][PATCH v2 0/2] Aarch64: Fix segfault when casting dummy calls Date: Tue, 09 Oct 2018 08:26:00 -0000 Message-ID: <3DF26781-3D5E-4A95-9427-7369E2DEFA01@arm.com> References: <20181001155255.14859-1-alan.hayward@arm.com> In-Reply-To: <20181001155255.14859-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00203.txt.bz2 Ping. > On 1 Oct 2018, at 16:52, Alan Hayward wrote: >=20 > This is a reworking of a patch I posted in March. > V1 had a long discussion which was then paused to wait for > Pedro's IFUNC rewrite. >=20 >=20 > Prevent the int cast in the following causing a segfault on aarch64: > (gdb) b foo if (int)strcmp(name,"abc") =3D=3D 0 > (gdb) run >=20 >=20 > This is because to aarch64_push_dummy_call determines the return type > of the function and then does not check for null pointer. >=20 > A null pointer for the return type means either 1) the call has a > cast or 2) an error has occured. > You can see this in infcall.c:call_function_by_hand_dummy(): >=20 > CORE_ADDR funaddr =3D find_function_addr (function, &values_type, &ftype= ); >=20 > if (values_type =3D=3D NULL) > values_type =3D default_return_type; > if (values_type =3D=3D NULL) > { > const char *name =3D get_function_name (funaddr, > name_buf, sizeof (name_buf)); > error (_("'%s' has unknown return type; " > "cast the call to its declared return type"), > name); > } >=20 > In aarch64_push_dummy_call we do not have default_return_type, so cannot > determine between the two cases. >=20 > (In addition, aarch64_push_dummy_call incorrectly resolves the return > type for IFUNC). >=20 >=20 > However, aarch64_push_dummy_call only requires the return value in order > to calculate lang_struct_return ... which has previously been calculated > in the caller: >=20 > This is slightly awkward, ideally the flag "lang_struct_return" > would be passed to the targets implementation of push_dummy_call. > Rather that change the target interface we call the language code > directly ourselves. >=20 > The fix is simple: > Patch 1: Update gdbarch interface to pass lang_struct_return. > Patch 2: Remove incorrect code and use the passed in lang_struct_return. >=20 > Built on x86 target all build and tested on aarch64. >=20 >=20 >=20 > Alan Hayward (2): > Add lang_struct_return to _push_dummy_call > Aarch64: Fix segfault when casting dummy calls >=20 > gdb/aarch64-tdep.c | 29 +----- > gdb/alpha-tdep.c | 3 +- > gdb/amd64-tdep.c | 3 +- > gdb/amd64-windows-tdep.c | 3 +- > gdb/arc-tdep.c | 2 +- > gdb/arm-tdep.c | 2 +- > gdb/avr-tdep.c | 3 +- > gdb/bfin-tdep.c | 1 + > gdb/cris-tdep.c | 3 +- > gdb/csky-tdep.c | 3 +- > gdb/frv-tdep.c | 3 +- > gdb/gdbarch.c | 4 +- > gdb/gdbarch.h | 4 +- > gdb/gdbarch.sh | 2 +- > gdb/h8300-tdep.c | 3 +- > gdb/hppa-tdep.c | 6 +- > gdb/i386-darwin-tdep.c | 3 +- > gdb/i386-tdep.c | 2 +- > gdb/ia64-tdep.c | 3 +- > gdb/infcall.c | 3 +- > gdb/iq2000-tdep.c | 3 +- > gdb/lm32-tdep.c | 3 +- > gdb/m32c-tdep.c | 2 +- > gdb/m32r-tdep.c | 2 +- > gdb/m68hc11-tdep.c | 3 +- > gdb/m68k-tdep.c | 2 +- > gdb/mep-tdep.c | 2 +- > gdb/mips-tdep.c | 15 +-- > gdb/mn10300-tdep.c | 1 + > gdb/msp430-tdep.c | 3 +- > gdb/nds32-tdep.c | 3 +- > gdb/nios2-tdep.c | 3 +- > gdb/or1k-tdep.c | 3 +- > gdb/ppc-sysv-tdep.c | 6 +- > gdb/ppc-tdep.h | 2 + > gdb/riscv-tdep.c | 1 + > gdb/rl78-tdep.c | 3 +- > gdb/rs6000-aix-tdep.c | 3 +- > gdb/rs6000-lynx178-tdep.c | 3 +- > gdb/rx-tdep.c | 2 +- > gdb/s390-tdep.c | 3 +- > gdb/score-tdep.c | 3 +- > gdb/sh-tdep.c | 2 + > gdb/sparc-tdep.c | 3 +- > gdb/sparc64-tdep.c | 3 +- > gdb/spu-tdep.c | 3 +- > gdb/testsuite/gdb.base/condbreak-solib-lib.cc | 21 +++++ > .../gdb.base/condbreak-solib-main.cc | 33 +++++++ > gdb/testsuite/gdb.base/condbreak-solib.exp | 93 +++++++++++++++++++ > gdb/tic6x-tdep.c | 3 +- > gdb/tilegx-tdep.c | 1 + > gdb/v850-tdep.c | 1 + > gdb/vax-tdep.c | 2 +- > gdb/xstormy16-tdep.c | 1 + > gdb/xtensa-tdep.c | 1 + > 55 files changed, 246 insertions(+), 77 deletions(-) > create mode 100644 gdb/testsuite/gdb.base/condbreak-solib-lib.cc > create mode 100644 gdb/testsuite/gdb.base/condbreak-solib-main.cc > create mode 100644 gdb/testsuite/gdb.base/condbreak-solib.exp >=20 > --=20 > 2.17.1 (Apple Git-112) >=20