From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2B0E1A00C9; Tue, 18 Jun 2024 12:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718714431; cv=none; b=Qkd7kDS9LznR3SZX0ntMK+VhvPhR6+EEMdXhIYCvqwfSNzCEQPew9CSnd7pgLp3yHLp5SZTuzFzffB9OuGvf1pEX3bjhRxvT657PbW8vpRJPzx3tlzYCiYlIOQKv6xxM5sjpDdLkEp/GeIV5bKl2G+VrK4GCQdIouCRX8oNVNko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718714431; c=relaxed/simple; bh=byH65kRaOvolxPCmYoBw5pOGPfUusJTXCS2NhP+CBds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ECsJtLoSS0J3zX/u8+R/uxc5hGLD9AebwGEBDrGhS8sjkPGoQe0zmZa9PvChOlvgKREiyAlknLCoADzAOw2IAOZKMOOafyHpC04NoaA+wfPalb7QZV4bUobzAjMv/AMlUlc6ljZMBKYw/w2+FQlUUUFUVNW4KLd1ceBhbqEVhXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IPlR+dQN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IPlR+dQN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D3EC32786; Tue, 18 Jun 2024 12:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718714430; bh=byH65kRaOvolxPCmYoBw5pOGPfUusJTXCS2NhP+CBds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IPlR+dQNM9zKfIEOra0KXGbbQc3hawYUhNZPbMV2dt+lWiWgfzOqjvBpCSYlK/C5C 4TeM0YH8p6hiCVDJrqBdPk/YGenPnSWj/s3+B/tNZ2K2u6cmxV7uXEcxcaIZQ4myP9 fn3aSHxbQwRnydSj3vLoQ7hGIMGaJ3U6vRR4QP9ezL2LK+CV2i5EkqXrDbJ0RfZaMe eVkYTGvN80v190a7ISrw5l7W9ov67DV1PMXcEiVYjb/x5xoZ4X9K6x+GCLKQUo9KFB eCeINfe1Wy2u6rbi2n6vJYo+r0XS/08/QOJ4qY8bAgFJAoa+/MH2b3TWd48/PfPzSV l4tROXuBb+bZw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Huacai Chen , Ard Biesheuvel , Sasha Levin , chenhuacai@kernel.org, linux-efi@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 6.1 06/29] efi/libstub: zboot.lds: Discard .discard sections Date: Tue, 18 Jun 2024 08:39:32 -0400 Message-ID: <20240618124018.3303162-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240618124018.3303162-1-sashal@kernel.org> References: <20240618124018.3303162-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.94 Content-Transfer-Encoding: 8bit From: Nathan Chancellor [ Upstream commit 5134acb15d9ef27aa2b90aad46d4e89fcef79fdc ] When building ARCH=loongarch defconfig + CONFIG_UNWINDER_ORC=y using LLVM, there is a warning from ld.lld when linking the EFI zboot image due to the use of unreachable() in number() in vsprintf.c: ld.lld: warning: drivers/firmware/efi/libstub/lib.a(vsprintf.stub.o):(.discard.unreachable+0x0): has non-ABS relocation R_LARCH_32_PCREL against symbol '' If the compiler cannot eliminate the default case for any reason, the .discard.unreachable section will remain in the final binary but the entire point of any section prefixed with .discard is that it is only used at compile time, so it can be discarded via /DISCARD/ in a linker script. The asm-generic vmlinux.lds.h includes .discard and .discard.* in the COMMON_DISCARDS macro but that is not used for zboot.lds, as it is not a kernel image linker script. Add .discard and .discard.* to /DISCARD/ in zboot.lds, so that any sections meant to be discarded at link time are not included in the final zboot image. This issue is not specific to LoongArch, it is just the first architecture to select CONFIG_OBJTOOL, which defines annotate_unreachable() as an asm statement to add the .discard.unreachable section, and use the EFI stub. Closes: https://github.com/ClangBuiltLinux/linux/issues/2023 Signed-off-by: Nathan Chancellor Acked-by: Huacai Chen Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- drivers/firmware/efi/libstub/zboot.lds | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds index 93d33f68333b2..a7fffbad6d46a 100644 --- a/drivers/firmware/efi/libstub/zboot.lds +++ b/drivers/firmware/efi/libstub/zboot.lds @@ -34,6 +34,7 @@ SECTIONS } /DISCARD/ : { + *(.discard .discard.*) *(.modinfo .init.modinfo) } } -- 2.43.0