Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31620405rwd; Fri, 7 Jul 2023 01:53:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlG4dIoBTMLCCOoB5e0THmdJY7jOJ0c59eH5VZpeTJM4jSR5I2fDfKVn5gfaNsBR2wSiWNfI X-Received: by 2002:a05:6358:341a:b0:135:46d9:12f7 with SMTP id h26-20020a056358341a00b0013546d912f7mr4131868rwd.26.1688720027407; Fri, 07 Jul 2023 01:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688720027; cv=none; d=google.com; s=arc-20160816; b=h3y/8F9756njgcN6XwZ//OO4bRMOMvh5PD1xpN++ScGv0IsoobXT3vyR9Tm6KJfkih 5ZGhZQxpDKfYHuRZzb0R+LlObzyrVEBTUqyUcneAF5FfUQS3x3nStGWnbeyJJTnkUzP0 dhobGGgYRubJVvaSqshnSlZkTIxkt7pxW/L0UK2s2/WNEV6bTPbRMGzIsQvPFEKpL6oU 9MRx3g0jo6WFiun8makohngt9kVIhHGF18uMdgR2aXJOCLjT3v/FbqvWsrpDaeyJT89I EuKVi3++/fPG5/xk00pmlluwJiXNHDsTveLb3pymm14bzd4fjp1/L6NgiTREeXWchtGl LHJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:to:subject:message-id :date:from:in-reply-to:references:mime-version:dkim-signature; bh=A6MNmBZkZiwOWAtBo5QJa5YcHi+crvtXYiCkURW4I84=; fh=N4RB/NeFQc52yA3H0ssIcBFRb414My+lVuZEx9KBJwo=; b=mKqOsaY5kF5+FzrCUQz+3saYfEt3X9SKShTRXqCRioROmQ4VE7d2LStNOnoJ0g+7nW IXVhHp/KFH8IYOl+Wmtrtgs9VtQUJFKq+WdGIW5rD5Nw4Xa1PDywSTCaKWyugzG2DcEc 59ifADTtp0CQj978149UdXkhlWDEgVgU7rO/k9OS/pDxDi6dlip4DlYEt7Gt1j004CAR 9cTbAA2Vaw5p/f4nOcrNH93QWg8JPnF5LpF77w3mmnGA1og9NYUOqp6N/iI5uO9gZXZR ja8b6XLBvR/Vt6PpMxIQXoH7E/IxiLWEaks+palGndTNj8RHjRv1fLBOkKd882aG12Bg KASw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=yg3BmoXx; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a63ff41000000b0055768bf4256si3292447pgk.525.2023.07.07.01.53.32; Fri, 07 Jul 2023 01:53:47 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=yg3BmoXx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbjGGIo6 (ORCPT + 99 others); Fri, 7 Jul 2023 04:44:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjGGIo4 (ORCPT ); Fri, 7 Jul 2023 04:44:56 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F16A1FCE for ; Fri, 7 Jul 2023 01:44:55 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f9fdb0ef35so2580489e87.0 for ; Fri, 07 Jul 2023 01:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1688719493; x=1691311493; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A6MNmBZkZiwOWAtBo5QJa5YcHi+crvtXYiCkURW4I84=; b=yg3BmoXxjDcdSv5i03LxVrD3ErleVKEvveBCzB9wVppBkxmVVOo1/C1qa4vTEYwFTF 1/ZrXF3+wXYGlpJtKaJbBOhGeZCr0InhsluSYas5tIXewsDSgpMMeUB1x8zxjo9G43x8 McOXOwRMT2UX7LmrMR31DvkVETOarvIavhRgfje0XkaIjsf2HywbjbN5U3ThxNucHplL Tq+Co0K7dvqc0+2OvgBgvqiu1AKztrQDfxdlMRuk2n2IU4DagLXpLwWZ4VfSiTZ6LQ7+ TuAFSmecXiWGzRvCTm5zHnhZbhzt1ZlXzFE4T/EqQpk4pxGlkgBg+JJ8hb/x5NvYmREC cfxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688719493; x=1691311493; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A6MNmBZkZiwOWAtBo5QJa5YcHi+crvtXYiCkURW4I84=; b=ac+QDsMJrujKpIoL3qNTn4JuAfzQ8UR0rFBEOaSFqUzSHTLISU0ZPv/Ux8pnPpiI0H 6w3MWNPO2/2XffWQzrBzqxuRy4LhztBXjW2mu3elznGwfzJkWlEHFReJUxtFmtsfUMF4 YFFtKtm19unNcf/m7XnWsTn50ijKtsVeZP250qFI6O6wceHAkdQmTaYoTvXEA/YemLgi AcAM5G9RfOZaAKRl6Tk+/Q/9lCIc9bVwXWUx1HH1vPWAR3aIErXMZLNdfOSh0wdFVawy 8hmxeF5YpJs3jdFShOVc1fA86kmoU8AizpBku4S6auNjJq5D5viFtjKvbjvhDHve1OXJ o1Mw== X-Gm-Message-State: ABy/qLbZwuspgA4XXW1lAhdsdkF8vXIfXcfrei3Fx06m3H4j+I70kKKz ySDZFMFcu227NdZy5i3yi+0xnIipjvMF+jk4RZzIdvyHHV/NWlsL X-Received: by 2002:a05:6512:3c87:b0:4fb:7642:88dd with SMTP id h7-20020a0565123c8700b004fb764288ddmr3539103lfv.67.1688719493532; Fri, 07 Jul 2023 01:44:53 -0700 (PDT) MIME-Version: 1.0 References: <20230621114439.42851-1-alexghiti@rivosinc.com> <20230621114439.42851-2-alexghiti@rivosinc.com> In-Reply-To: <20230621114439.42851-2-alexghiti@rivosinc.com> From: Alexandre Ghiti Date: Fri, 7 Jul 2023 10:44:42 +0200 Message-ID: Subject: Re: [RFC PATCH 1/1] libstub: zboot: Use -ffunction-sections + --gc-sections To: Ard Biesheuvel , 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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 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 sectio= ns > (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/efi= /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_F= TRACE),,$(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/firmwa= re/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/efi/= libstub/zboot-header.S FO > > ZBOOT_DEPS :=3D $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/li= bstub/lib.a > > -LDFLAGS_vmlinuz.efi.elf :=3D -T $(srctree)/drivers/firmware/efi/libstub/= zboot.lds > +LDFLAGS_vmlinuz.efi.elf :=3D -T $(srctree)/drivers/firmware/efi/libstub/= 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! Thanks, Alex