From patchwork Tue Oct 20 05:16:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 532781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 854221402B4 for ; Tue, 20 Oct 2015 16:16:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=SNXL2o6n; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=d7NvHTkgwDMS7CEHf Dn4M3/X8cZd2D6BZpc9mKPmXP8orx6nvcK5slMGxNc2vrrF/fJJBspdgX/OMO3Iy qyJPggLsEA1FAzcDcy0NexrhcGrCkNsV1pNKaMily8CDopyMoh3zx+gn8YE+dyzN g6xRIOpyIC/pg06HrpcECHj6gs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=Ro2xyuk/PwenH3rU2h6Kxu5 LL5M=; b=SNXL2o6n5CDImzwfyvUJTqhjd0MBl4H7nlDwBcC6OjRVMH6WnCJnx9t kKMlkXi5TrfV/ZVgrxR4nlVZOOj2V31Lq3+SY0e8fcjfZXxl+myBsvRfojRLPF/W XubdTACi15TlocIAqxhu8gPJRNYTBr+YCVqvRkNm4MtW/O+bUUmM= Received: (qmail 105968 invoked by alias); 20 Oct 2015 05:16:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105897 invoked by uid 89); 20 Oct 2015 05:16:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f53.google.com Received: from mail-pa0-f53.google.com (HELO mail-pa0-f53.google.com) (209.85.220.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 20 Oct 2015 05:16:41 +0000 Received: by pacfv9 with SMTP id fv9so9778109pac.3 for ; Mon, 19 Oct 2015 22:16:39 -0700 (PDT) X-Received: by 10.66.102.65 with SMTP id fm1mr1688171pab.12.1445318198950; Mon, 19 Oct 2015 22:16:38 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-163-67.gqzg1.fli.bigpond.net.au. [58.160.163.67]) by smtp.gmail.com with ESMTPSA id pf7sm1197506pbc.6.2015.10.19.22.16.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 22:16:38 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 767B8EA1537; Tue, 20 Oct 2015 15:46:33 +1030 (ACDT) Date: Tue, 20 Oct 2015 15:46:33 +1030 From: Alan Modra To: Szabolcs Nagy Cc: "gcc-patches@gcc.gnu.org" , David Edelsohn , gregor.richards@uwaterloo.ca, Rich Felker Subject: Re: [PATCH, rs6000] Pass --secure-plt to the linker Message-ID: <20151020051633.GM13961@bubble.grove.modra.org> References: <561FE77A.5000900@arm.com> <20151019111202.GJ13961@bubble.grove.modra.org> <5624EA40.70905@arm.com> <56254028.9040508@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56254028.9040508@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Mon, Oct 19, 2015 at 08:10:32PM +0100, Szabolcs Nagy wrote: > On 19/10/15 14:04, Szabolcs Nagy wrote: > >On 19/10/15 12:12, Alan Modra wrote: > >>On Thu, Oct 15, 2015 at 06:50:50PM +0100, Szabolcs Nagy wrote: > >>>A powerpc toolchain built with (or without) --enable-secureplt > >>>currently creates a binary that uses bss plt if > >>> > >>>(1) any of the linked PIC objects have bss plt relocs > >>>(2) or all the linked objects are non-PIC or have no relocs, > >>> > >>>because this is the binutils linker behaviour. > >>> > >>>This patch passes --secure-plt to the linker which makes the linker > >>>warn in case (1) and produce a binary with secure plt in case (2). > >> > >>The idea is OK I think, but > >> > >>>@@ -574,6 +577,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) > >>> %{R*} \ > >>> %(link_shlib) \ > >>> %{!T*: %(link_start) } \ > >>>+%{!static: %(link_secure_plt_default)} \ > >>> %(link_os)" > >> > >>this change needs to be conditional on !mbss-plt too. > >> > > > >OK, will change that. > > > >if -msecure-plt and -mbss-plt are supposed to affect > >linking too (not just code gen) then shall i add > >%{msecure-plt: --secure-plt} too? > > > > I added !mbss-plt only for now as a mix of -msecure-plt > and -mbss-plt options do not cancel each other in gcc, They do for code-gen since they share the same variable (see sysv4.opt), but I guess you meant as far as spec parsing goes. In hindsight, it might have been better if I'd spelled -mbss-plt as -mno-secure-plt. > the patch only changes behaviour for a secureplt toolchain. > > OK to commit? Apologies for not thinking of this before when I first reviewed the patch, but have you bootstrapped this patch on powerpc64-linux? I'm guessing not, because it occurs to me that --secure-plt is not a powerpc64-linux-ld option. So if you try to build a biarch compiler with --enable-secure-plt then ld will complain when attempting to link 64-bit binaries. You'll want this on top of your patch: diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 9599735..01fb880 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -174,20 +174,24 @@ extern int dot_symbols; #undef ASM_DEFAULT_SPEC #undef ASM_SPEC #undef LINK_OS_LINUX_SPEC +#undef LINK_SECURE_PLT_SPEC #ifndef RS6000_BI_ARCH #define ASM_DEFAULT_SPEC "-mppc64" #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)" #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)" +#define LINK_SECURE_PLT_SPEC "" #else #if DEFAULT_ARCH64_P #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}" #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)" #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}" +#define LINK_SECURE_PLT_SPEC "%{m32: " LINK_SECURE_PLT_DEFAULT_SPEC "}" #else #define ASM_DEFAULT_SPEC "-mppc%{m64:64}" #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)" #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}" +#define LINK_SECURE_PLT_SPEC "%{!m64: " LINK_SECURE_PLT_DEFAULT_SPEC "}" #endif #endif diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 93499e8..1bb400f 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -570,6 +570,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) : %(link_start_default) }" #define LINK_START_DEFAULT_SPEC "" +#define LINK_SECURE_PLT_SPEC LINK_SECURE_PLT_DEFAULT_SPEC #undef LINK_SPEC #define LINK_SPEC "\ @@ -577,7 +578,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) %{R*} \ %(link_shlib) \ %{!T*: %(link_start) } \ -%{!static: %{!mbss-plt: %(link_secure_plt_default)}} \ +%{!static: %{!mbss-plt: %(link_secure_plt)}} \ %(link_os)" /* Shared libraries are not default. */ @@ -893,7 +894,7 @@ ncrtn.o%s" { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ - { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ + { "link_secure_plt", LINK_SECURE_PLT_SPEC }, \ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \