Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9239616rwd; Wed, 21 Jun 2023 05:05:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Ng46Qtg0pR8dVgnNL2aUwqUEFS2sLQ/V39KD3UxRuy4K9u+Ig5r2gUsYOd3CCX+pNj/TK X-Received: by 2002:a05:6a20:54a6:b0:122:2c01:9bd2 with SMTP id i38-20020a056a2054a600b001222c019bd2mr6166866pzk.37.1687349127519; Wed, 21 Jun 2023 05:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687349127; cv=none; d=google.com; s=arc-20160816; b=BfNJ2dYG2JbduIfBAL74mlQU6/+Xt0bC+p0oD7bQxj2DWAQ5XG6NtkXDwk5X5qaydQ B5iR7B+YYFlwin0DJgINkNJGWmlM1R1XA/i/B2tc09cjJxuglXFTqSSzhnWfmcSPm79Z t5fRQ2iAsSiEQMmEWh39obBvz/lHDT1S2iCaBkZ7F7aDA9lkouRedrLi2BUMBkOU+oXU XlPZUEyetV1TvLj4PHmq5MzWiEJHiuCL2yOER5K9gJKTH8713fWxTC81FM4DP+MiGfuE jWco7TiOdREXkwpXFRVbobs9IcCRTjIoWlZarjMbH1vf7lmUv37qR5XWU4w80vEnEgBu 2Yfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9diQLvSxjMs6xAGnA2pdApMjgni3zVWKA+Wt7BjIAVs=; b=MOzSqdbesO8upWOOm9kImajZq0PiiQjWUyyzR+Lzl00iip1jnwXs4fgMCEKP5LJ+yA IV6ue+3geMaRBOJR6UFfOap88tXGeY+WYCOVmA/d/wYev+a5ZWDd/cLK6l3xTdOgimtJ NG4qBcXzeFz/k4QP2nfJKhnfvpASiF84DP308vLA8DRQPPjuOnpXGksuyjwfIzs0zPks IuSAvNDpnBf3EY4vr5n4wwdcqkHrWOb4HTd6gBvDfqZ0qQD2xdPmdYcQwChngMQi7EFq 5L+aqnSsUFk47kgj1Umwx4xXRdbMvG5C88OuThpadSvIdSwke0tJwV3IaFw8rm5ZfUXT a1IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Dy+0Xpyk; 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 i68-20020a639d47000000b005347c4d09ddsi4035066pgd.678.2023.06.21.05.05.13; Wed, 21 Jun 2023 05:05:27 -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=Dy+0Xpyk; 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 S229699AbjFULpq (ORCPT + 99 others); Wed, 21 Jun 2023 07:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbjFULpp (ORCPT ); Wed, 21 Jun 2023 07:45:45 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 271931B4 for ; Wed, 21 Jun 2023 04:45:44 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f9b258f3a2so33192765e9.0 for ; Wed, 21 Jun 2023 04:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1687347942; x=1689939942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9diQLvSxjMs6xAGnA2pdApMjgni3zVWKA+Wt7BjIAVs=; b=Dy+0Xpykwbo8prZFI97d/boX6VfR8V7t3mPscGNYupuffVuSsN+OIVNiBfwuadRBPt dbBfLs1KQh1g2gAwl4OZKWwrHROh4D20WpcsiAjh7fIYsMLN+MKoxqnNmaRF4ZqAiv8g 5ants6B6Fah9aVcwXA94xxFJfew05/+MhpB7qrb28/49u8QJVOFhgr6Pc0+pg4njlYDk ZZHaMoUkSMuOePdfBP1Zu3jNxKaeJHbZDkPvMxbcqsPcRY9Og1W8pfLvrcEkQ7yZa/is JmVvCps1ZO/NLB+npPy2sRFIKHlWMQwYv35RQVe3vg513lhxT2g8xFBn57uJvJFyHa9T yZTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687347942; x=1689939942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9diQLvSxjMs6xAGnA2pdApMjgni3zVWKA+Wt7BjIAVs=; b=DiU9/Bg9Nz2Ytzck/aGnLwOYhX1ImG0zoR/6GHmoJk3G90xa+h15r0b5gcZtcatxZe uLPxsGa4T2K2QUX5p5z42qk+vGvgQGm2EtmNvc4mkm35df5vKdF2q8L97FoQg0+Zz6G0 TD1biiMAC7g7iVRs6cTp6Ic4ASO3JPvRgSaGVO6V9QUWtO+aC2BWidy/308VzPtOalNv wiWjmPdRleR9wCLl3aqIhVYx69Mdiu7FTjVV45M7VQ2w/B3Ke0L9PE/PY/V1ZvrDI/o0 MLEJCNQVNGD0tLbSSXua8oY8FNxIlI1XNbYkf7JLnZmkzh9cE+LdNIrqR5o84bGGOMsD +sig== X-Gm-Message-State: AC+VfDyFcorBS+Gvsnmgbt+DQNxBgHmz4ZzpU6m5dNI0gvxWz59I6Lq/ uaOMKXfVrd3DfAV8fJBAzFd1PF2PHLps8vRCWb4= X-Received: by 2002:a7b:ca57:0:b0:3f9:b4a0:6062 with SMTP id m23-20020a7bca57000000b003f9b4a06062mr4993654wml.24.1687347942509; Wed, 21 Jun 2023 04:45:42 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id v15-20020a1cf70f000000b003f8d770e935sm16097220wmh.0.2023.06.21.04.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 04:45:42 -0700 (PDT) From: Alexandre Ghiti To: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Cc: Alexandre Ghiti Subject: [RFC PATCH 1/1] libstub: zboot: Use -ffunction-sections + --gc-sections Date: Wed, 21 Jun 2023 13:44:39 +0200 Message-Id: <20230621114439.42851-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230621114439.42851-1-alexghiti@rivosinc.com> References: <20230621114439.42851-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=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 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 sections (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 := $(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/firmware/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 := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a -LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds +LDFLAGS_vmlinuz.efi.elf := -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