From patchwork Wed Jan 24 06:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 25485 Received: (qmail 39050 invoked by alias); 24 Jan 2018 06:44:33 -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 39038 invoked by uid 89); 24 Jan 2018 06:44:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pg0-f51.google.com Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Jan 2018 06:44:30 +0000 Received: by mail-pg0-f51.google.com with SMTP id z17so2067711pgc.4 for ; Tue, 23 Jan 2018 22:44:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NDgQdsgU2j3uFkbf3grOiu92pwJM+VaN25xrYPgvxds=; b=ndFakYuxrCcV7sWK+18V/gA2sHIdT8WqMpA5oqvh/U+euksew9R4cGc8f1UsqI+mZE DcI7BtRACVs49BwqBgtdH1XCvZQgNaqytcZXcLQYTeC8q0R7yNCrCqRknQVexQw5XqU8 rDN+PjVa8NeF1DANW0yMJzEKmRaBD26LG0wpIVcb2o28fRIWGwNaL16vgIhyoVN7iQZ+ bAumbx5ERP+zczKamto95qGLZUDofDQthtK4PERbGLQAArxBZAP4cnYXxdep4AzOM6yv CHIIffAyOPoHU3ImHb9LU54esRdXpsYKbh3K3HCQqhiRhcqBnS08Dl8MGFsLmiTqWzdy oxVA== X-Gm-Message-State: AKwxytdi9tTK0e+t2EvQjC0eddySRNQi05KmEuUmKrviVHnbyJdRzdPw WIIHDWnUoO9cWvs2d94s4FuJOg== X-Google-Smtp-Source: AH8x224DK4mde6jflWGmJsH8oTwW4WWDlO11wpljEtBSb4aczIWAAzzhMXHCvYGOIJcTMYBWIghkdg== X-Received: by 10.101.65.9 with SMTP id w9mr10088356pgp.214.1516776268565; Tue, 23 Jan 2018 22:44:28 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-175-244-173.hdcz1.win.bigpond.net.au. [58.175.244.173]) by smtp.gmail.com with ESMTPSA id i11sm5435614pgq.34.2018.01.23.22.44.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 22:44:27 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 797ECC4958; Wed, 24 Jan 2018 17:14:23 +1030 (ACDT) Date: Wed, 24 Jan 2018 17:14:23 +1030 From: Alan Modra To: gdb-patches@sourceware.org Subject: Match speculative execution barriers in PowerPC PLT stubs Message-ID: <20180124064423.GO20622@bubble.grove.modra.org> References: <20180124062015.GN20622@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180124062015.GN20622@bubble.grove.modra.org> User-Agent: Mutt/1.5.24 (2015-08-30) This patch teaches gdb about the PLT stub code emitted by ld --no-speculate-indirect-jumps. Regression tested powerpc64-linux, powerpc-linux and powerpc64le-linux. OK? * ppc-linux-tdep.c (powerpc32_plt_stub): Match stub with speculative execution barrier. (powerpc32_plt_stub_so_1, powerpc32_plt_stub_so_2): Likewise. (ppc_skip_trampoline_code): Scan backwards 6 insns. Check that either "bctr" or "crset eq" is present in PLT stubs. * ppc64-tdep.c (ppc64_standard_linkage4): Match stub with speculative execution barrier. (ppc64_standard_linkage5): Likewise (ppc64_standard_linkage7, ppc64_standard_linkage8): Likewise. (ppc64_skip_trampoline_code_1): Check that either "bctr" or "crset eq" is present. diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index ed0ea13..541df39 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -256,24 +256,28 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, readbuf, writebuf); } -/* PLT stub in an executable. */ +/* PLT stub in an executable. The form with an execution barrier has + two more insns following the "crset eq" that we don't check. */ static const struct ppc_insn_pattern powerpc32_plt_stub[] = { { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */ { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */ { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */ - { 0xffffffff, 0x4e800420, 0 }, /* bctr */ + { 0xffffffff, 0x4e800420, 1 }, /* bctr