Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31617401rwd; Fri, 7 Jul 2023 01:50:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlER354U8IA2zq3qYy7oaD7PO4QzFYT3Lg2fPj0TdMyniX41HzfXSYJO41yGTUPdbCIPFV4T X-Received: by 2002:a05:6808:8e9:b0:3a1:de77:2cc2 with SMTP id d9-20020a05680808e900b003a1de772cc2mr4004083oic.20.1688719820376; Fri, 07 Jul 2023 01:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688719820; cv=none; d=google.com; s=arc-20160816; b=ok8rW6gt4edFp6qyA1N1VKgE4S5nBV8LLBcAR5992IBhNm+P9oJnBwVc59/xeuB5l8 C+XA/nk6k5fGb1+nehVqFCqbU9Pr4wnImxRhPsox91ef1OB8sfORok8zJTMBV+YYRFui zi4jXu4MDQ6V+8CS2Frh/a6RdBZSfgVbHSPPIyZdNLIfeEBxUXMMyVJNpZU+WEHrfSjo /j+R1V44IVHDQjEdR2HmybFuI6xa/OeoXvWvA9SjsQCmkoM0yRbfQphbVLJIpZweT87a 571EzjjYCD4R2zFo3UYVa+wvy1ztQbAiSJ3GNdR+Fla3I4yL4tLuOWPmYn2ag8VzDMha xU0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cHVkELtqpPJzMQPTOmwgIGakK6IucMPt24mBQ2xmz/M=; fh=DCzauN9QpbSNFNaJhdMz+2/F0x6tZh3ncH2KRRwr+3E=; b=yYxu4LZMKpzV2W8rJdBc2ifqRmqm8yZP+V2YxrZmHAaOrWCcufmiaB5mRof+VTwyAy TJN1cXFwXipkOVwWoU5MSuWmQl0RFdtCHdmAwlH6IkqWAo29FjNytzKrMRyrFEGKwuLq 7uw0aWR89ZIO2/Fqgrt1pj9AdpCpU3+e0XN1yYF2qWH8gScD/On0CoTXtG0yKWm/eRSf j09M7qfbn5ezBG4wIuxdtwT6NbhLBXmBpxUA7OSaIlLifWkP5sij3zUPblK5E3xQj++G dBtpk/82AwMjbbmfJW0TBxlHZke7hqwnpvVZXQzJ2KqBCu0uyDE5s92OGpiRrpvXKwar XHsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mN/qZAh8"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn20-20020a17090b189400b0026306d2d484si1600074pjb.111.2023.07.07.01.50.06; Fri, 07 Jul 2023 01:50:20 -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=@kernel.org header.s=k20201202 header.b="mN/qZAh8"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbjGGIrt (ORCPT + 99 others); Fri, 7 Jul 2023 04:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjGGIrs (ORCPT ); Fri, 7 Jul 2023 04:47:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E9051FCE; Fri, 7 Jul 2023 01:47:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E7D7E61728; Fri, 7 Jul 2023 08:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49FF9C433C9; Fri, 7 Jul 2023 08:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688719666; bh=nDLct84XbdvtTYSifKLyBbzOc2cgi6lSKASzLLiQ2+A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mN/qZAh84pxtr7Lom14e6yhynXc0nKRJPNWUYAUMB8VTt5ihMY6ZXxJibGusmCFtH 5Xl8yUMyBQPwUbJRAOcriN3X1o2/GsPTu11BqXQSJNwiFGZMn1VhyRn3Rf+dfrWfRR ITYJxFW8+YY0MlzJjBAPutpzxsIPcixTdtSL4dncl5uGoy8PnC7fD1ttbfgejN7821 V7Z5R5J37L+xN0ldk/0dWQ4U4pK31n3iBduFfe0Xxz9n9/VMPMQywRY6d2gJr1g7Na dXcLnNj3lagJNsNxQrZRgYB15nMm+1RZFDJMiEY6Lj3l8XS9HZC3mVgFCsbYBaNRTY QuaWFWYVuzyRQ== Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2b701e1c80fso23829661fa.2; Fri, 07 Jul 2023 01:47:46 -0700 (PDT) X-Gm-Message-State: ABy/qLZlyzGMptLH/A/J0Uu+PuYhNOdNJ8S3pBi57lKolDEExnzWenXF djsX9EilgX/fxviezn+OaANL7W9kGzaSjYywOh0= X-Received: by 2002:a2e:87c3:0:b0:2b6:bd09:4d64 with SMTP id v3-20020a2e87c3000000b002b6bd094d64mr3335448ljj.34.1688719664209; Fri, 07 Jul 2023 01:47:44 -0700 (PDT) MIME-Version: 1.0 References: <20230621114439.42851-1-alexghiti@rivosinc.com> <20230621114439.42851-2-alexghiti@rivosinc.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 7 Jul 2023 10:47:32 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/1] libstub: zboot: Use -ffunction-sections + --gc-sections To: Alexandre Ghiti Cc: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Fri, 7 Jul 2023 at 10:44, Alexandre Ghiti wrote= : > > Hi Ard, > > On Wed, Jun 21, 2023 at 1:45=E2=80=AFPM Alexandre Ghiti wrote: > > > > Static linking is done at an object file (actually section) granularity= , > > meaning that if a function in an object has an undefined reference, the > > link will fail, even though this function is not used in the resulting > > ELF. > > > > To avoid such failures, allow the linker to garbage collect unused sect= ions > > (which actually are functions). > > > > Signed-off-by: Alexandre Ghiti > > --- > > drivers/firmware/efi/libstub/Makefile | 1 + > > drivers/firmware/efi/libstub/Makefile.zboot | 2 +- > > 2 files changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/e= fi/libstub/Makefile > > index 3abb2b357482..6182366d00c0 100644 > > --- a/drivers/firmware/efi/libstub/Makefile > > +++ b/drivers/firmware/efi/libstub/Makefile > > @@ -40,6 +40,7 @@ KBUILD_CFLAGS :=3D $(subst $(CC_FLAGS= _FTRACE),,$(cflags-y)) \ > > -ffreestanding \ > > -fno-stack-protector \ > > $(call cc-option,-fno-addrsig) \ > > + -ffunction-sections \ > > -D__DISABLE_EXPORTS > > > > # > > diff --git a/drivers/firmware/efi/libstub/Makefile.zboot b/drivers/firm= ware/efi/libstub/Makefile.zboot > > index 89ef820f3b34..5bb52d262133 100644 > > --- a/drivers/firmware/efi/libstub/Makefile.zboot > > +++ b/drivers/firmware/efi/libstub/Makefile.zboot > > @@ -51,7 +51,7 @@ $(obj)/zboot-header.o: $(srctree)/drivers/firmware/ef= i/libstub/zboot-header.S FO > > > > ZBOOT_DEPS :=3D $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/= libstub/lib.a > > > > -LDFLAGS_vmlinuz.efi.elf :=3D -T $(srctree)/drivers/firmware/efi/libstu= b/zboot.lds > > +LDFLAGS_vmlinuz.efi.elf :=3D -T $(srctree)/drivers/firmware/efi/libstu= b/zboot.lds --gc-sections > > $(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE > > $(call if_changed,ld) > > > > -- > > 2.39.2 > > > > Sorry to bother you, do you have any opinion about this patch? Does > that make sense? If not, I should find another solution for my riscv > KASLR series! > Hi, Apologies for the delay in responding. I have been away and email tends to pile up a bit. The patch by itself looks fine to me, but I do wonder if your series could be improved slightly by moving those newly shared pieces into a separate source file, rather than to an existing one.