Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5419539rwb; Mon, 8 Aug 2022 19:24:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Leai8Gb+EqCYW/v+TwMyAKgJrnDsGdatkPHW7HVLG2IHj0Tx3MVMZw2SIorRRNKWH6wF5 X-Received: by 2002:a63:2dc6:0:b0:419:f2d0:4777 with SMTP id t189-20020a632dc6000000b00419f2d04777mr17649135pgt.203.1660011876989; Mon, 08 Aug 2022 19:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660011876; cv=none; d=google.com; s=arc-20160816; b=eUkp59tBDIbWXkQ3Msw5LfXv811Z6V1rhooy3qicEdgPjUmz/R2Y3EOHB2DxL4q2I3 q9jROU6MXvX1wefeG3ZmmAy24LBApRtU8zaet8j5B4SvSdWYa+V5P9v98jLI8BCBTSNg HC7ApPfeA3c9/aSh5N/avtfdHkxcShO5u3ddh/JwYq9LQHyFnY0XjulOxCueEjD/RxyV w3Q2Lfl6F0P466K1PuqcgI7mhaKp2ELlzn08DzxPomfypeaEDHQ/kzHigj5kEWOsf8rM SF57GVXMvOl8tEYJjLhVXf4VTut3zMfvn2/UoDgnG8S8MgfBtRRkeyoLyIodxbsAsaGo Nsvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Urt9D1pDp7wJLd+Y0cr81FZpsM8CKH8Y5Qhm/oGPRYw=; b=q7CKDSsY8ymfT3hW4o97AzoDpGV4rw3MzSmFk4qwQ8Tgq6MQQ8zXcVzNwAYccqmAxD mcEoGuwo/pP96AfRvJhAOVQe7seICBquvSP4vOpVMlO2TWD8EiXPDR1V9WrmAPsoLKp0 aopLlYXX6vicGvIFxTGsROKHUN9yOzk21zvSxzjcgpSLVHXJce5zhGZgRSl4DOJIQKy1 B2/Eg9K056QmmzNipK3fk2I4sj+pZc+PFvI8LIR8F2WnwYwBP8s1J8Hf3MTPTL2J+2q8 B9vD8V2Vrv5FnUBIGJ/bWMVaYLtgakYbpRiRCynAIYHuQ1yj6lDRbr+XmA9vOnYgiqS9 OXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qTFSHOsw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a17090a348700b001e29c6b2ff5si16377213pjb.151.2022.08.08.19.24.22; Mon, 08 Aug 2022 19:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qTFSHOsw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbiHIBhC (ORCPT + 99 others); Mon, 8 Aug 2022 21:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiHIBhA (ORCPT ); Mon, 8 Aug 2022 21:37:00 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E22DDEB2 for ; Mon, 8 Aug 2022 18:36:58 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so10835230pjf.2 for ; Mon, 08 Aug 2022 18:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=Urt9D1pDp7wJLd+Y0cr81FZpsM8CKH8Y5Qhm/oGPRYw=; b=qTFSHOsw7sTmZ8J+3Vb4qHel1OcWTR+DFo3zBm7rejaLneZfzv8fbBlKEI82iKj0RQ e+jrS2zD6zStvsHVIi4JXme6qY59WxDARcN0ESudFKRk3ocs1GP8Q6pG5Veu3MSnPQCI Ayp+NYTBLX5PUqCjo9FrffvUWwBA3AkTebPkkU3jgLOgUV/dsmsbZrYyCipdxjX80j16 78/kba/PeHWonaT7WtVi2qr/fHMKNWE57Kriq63D0lw1a3rSu1zzXcNFY53XhoezzhRN JUZLQbOcsCpATHVwB+tcPtk9Iwbfy0eAImwAKBpCg0Qpn1IgCNt7x/o0sHaol+6fPYEg z+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=Urt9D1pDp7wJLd+Y0cr81FZpsM8CKH8Y5Qhm/oGPRYw=; b=cLY3Xz6b8Wl5yLdtoAlFZfDdbp5jujKN08Bj7iU7pdZpbRcBXILUmnkskKZdlrasJJ OLeAGxNO5q2HCfmjaioMwbvyKHJV9VEhQloX8enKjrI0/+Pez+sS3BfhDzza0AlSasIC ahpQR2dwY8COuN/axM5Xgq43kAvx4z09NJLzC1C+CENWDXnIU8tO5wKgOZZFgB5zfSkE ++2Py5R1HnJZz+XPmhPeYCglyS4dyZfzevkxhUzFOmWBQs4KZ8IGBvYiIpsR6pzk5u5F 85b/n9szfBQ7iOJhehbgkyUW7OjEyyHdATuEWAsFPup0eUZxQ5dhTqcqU0bjPYcjGmpT 59RQ== X-Gm-Message-State: ACgBeo3pT6gQnStX7f/8n88Vm0pcFSlz5lFtiD/tj16G1V66Ep8/FTHl 8W1h97cjIDirbx9fDlFuBqMLzw== X-Received: by 2002:a17:903:41c4:b0:16d:cb15:290f with SMTP id u4-20020a17090341c400b0016dcb15290fmr20883166ple.47.1660009017786; Mon, 08 Aug 2022 18:36:57 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:bab6:334a:f9d5:62ba]) by smtp.gmail.com with ESMTPSA id j11-20020a17090aeb0b00b001e29ddf9f4fsm8807037pjz.3.2022.08.08.18.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 18:36:57 -0700 (PDT) Date: Mon, 8 Aug 2022 18:36:53 -0700 From: Fangrui Song To: Nick Desaulniers Cc: Linus Torvalds , Nathan Chancellor , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Nick Clifton , Jens Axboe , x86@kernel.org, "H. Peter Anvin" , Tom Rix , Masahiro Yamada , "Kirill A. Shutemov" , Nicolas Schier , Brijesh Singh , Michael Roth , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Ben Dooks , Heinrich Schuchardt Subject: Re: [PATCH] x86: assemble with -Wa,--noexecstack to avoid BFD 2.39 warning Message-ID: <20220809013653.xtmeekefwkbo46vk@google.com> References: <20220808192321.3490995-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,FSL_HELO_FAKE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-08-08, Linus Torvalds wrote: >On Mon, Aug 8, 2022 at 1:32 PM Nick Desaulniers wrote: >> >> Thanks for the link; I recall Ard mentioning the ELF segments are >> ignored by the kernels loader in another thread. > >Yeah, the kernel loader is not some generic ELF loader thing. > >> Perhaps we should be adding >> --no-warn-execstack >> wrapped in an ld-option check to KBUILD_LDFLAGS at the top level? > >I think both the linker flag and the assembler flag are the "correct" >thing to do. > >And yes, I don't think there is anything architecture-specific about >it, and the top-level Makefile is likely the right thing to modify. > >I'm a tiny bit worried about "what versions of as/ld accept those >flags", though. > > Linus > If most ports don't need executable stacks, I think using `-z noexecstack` is better than the binutils 2.39 specific --no-warn-execstack (not recognized by lld and older GNU ld, so a configure check will be needed). Then -Wa,--noexecstack is not necessary: if the built relocatable files are destined to be used with ld with -z noexecstack, the input .note.GNU-stack sections are really redundant. It would be a difficult story if the relocatable files can "leak" to the outside world where a GNU ld without -z noexecstack may be used. But IMO this is not the case for the kernel.