Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2265245rwl; Mon, 26 Dec 2022 11:35:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAmIieTdPXKetQJb9c8OIBd0feOxTxJmigtk/oK1nDZEADI3VEoRLJZ8zLxOXtIfJExOnm X-Received: by 2002:aa7:9156:0:b0:57e:f1a2:1981 with SMTP id 22-20020aa79156000000b0057ef1a21981mr23466852pfi.8.1672083351749; Mon, 26 Dec 2022 11:35:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672083351; cv=none; d=google.com; s=arc-20160816; b=HJ44hYX7OTHfSmZJBbgJSb6fF4ltHWGY005H6KqTGpmfq5641o/jyzsM3BvDzzcD8t ewuw71IoocZ1HygP6dL1M70GZ7P22oZJdgobEa39zLd97L3g0Y57MSdlcgoBCxvYQ6Ca kD3MaxMV00KvRDyX0G/iXn4KQ4i1gAPA4Tu7j02amVE9BARtIlfCjgh/Ul2u7222J9SB s34s10EdoQQLr4YjslcPFv4rQfWZSvoe7AnnkC5QX9QrO1qe3h9S+Esm8BYxTuOYFXwi meG3ssP4VmqTWpMHyzE350ZPc9Y+1w/rw9deGnKEE3wUvQDb1kcLjp5t5sdrk9UnPkWZ jKxA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=c+YSKywIw14qN+SMPZxnWKtZk2NzbYHtLGw0UPBx/kY=; b=Ia4x42OYQBhKCnEBv7or6jE36WG6h/VlaI+imIRd4jZz//8ZFIJN+uaIbWPhjN+dub h3IlrMk6zu5gzxNaJG/lvLz42Yg7YKgrz+q6N0GTVBcDfqCAXWE/yRu/GTtEvI8+y86w FI2uXZn6nkoFBLH3CMdBHIcBk160Z++lt4kKMNfdqIOXqSjm8PBmjW8W3iiGUz2R95fv 4My0TySEeoeiV2+/mEyFJBmNjB8TyO4LAqRf0wIk7/RAy0MfitvZ831np9lCRlFBg5E9 azqLS9kOOpPfJK38rJj9JoLFXKcpHYhf4GSnyDHNACEXnFwl04zRzuIVdThf7lXvPebg NTcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FYKcKWr0; 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 x21-20020aa79415000000b005774d572ad3si11134687pfo.31.2022.12.26.11.35.35; Mon, 26 Dec 2022 11:35:51 -0800 (PST) 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=FYKcKWr0; 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 S232221AbiLZSqJ (ORCPT + 67 others); Mon, 26 Dec 2022 13:46:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiLZSqH (ORCPT ); Mon, 26 Dec 2022 13:46:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90A4BF9; Mon, 26 Dec 2022 10:46:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 346B360EF7; Mon, 26 Dec 2022 18:46:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C8DDC433EF; Mon, 26 Dec 2022 18:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672080361; bh=11fqsHGDwlwZxXJ1I41qluVDDxZF3poiwCovlkcoHk8=; h=From:To:Cc:Subject:Date:From; b=FYKcKWr0aibziaNfZxLDzsqJAbxmWqPqNL9fzxTN/GiM2Es+IyAru6i78RMDQBZLE AJUFihUysrNIL0HrQ7zpLpvvkdPgE0VYc5vBp4fKBFnNNQlMhrbm00lvDfpgtSLKKg eim1FHPTBoPExSY3hwYvEfmjXyOtt1Dj67HK9QqTjVJo+p9qc5cgbAewgJVrZCOzT4 0tHVbx22psxKKIAqN+WZbenpOIcf+3onOeOwXutik0uK8+veuaP18Ac4NPX6bRlKWt SyA2x9mAeRdasCG3zdQ0tBnmM0ej0+jVoZ/9M/lHcope8kbXIpFPT6m44J+tUvdMjC F/6LEe+RzHNJg== From: Masahiro Yamada To: linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Thorsten Leemhuis , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Dennis Gilmore , Albert Ou , Arnd Bergmann , Jisheng Zhang , Nicolas Schier , Palmer Dabbelt , Paul Walmsley , Masahiro Yamada Subject: [PATCH v2] arch: fix broken BuildID for arm64 and riscv Date: Tue, 27 Dec 2022 03:45:37 +0900 Message-Id: <20221226184537.744960-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS 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 Dennis Gilmore reports that the BuildID is missing in the arm64 vmlinux since commit 994b7ac1697b ("arm64: remove special treatment for the link order of head.o"). The issue is that the type of .notes section, which contains the BuildID, changed from NOTES to PROGBITS. Ard Biesheuvel figured out that whichever object gets linked first gets to decide the type of a section. The PROGBITS type is the result of the compiler emitting .note.GNU-stack as PROGBITS rather than NOTE. While Ard provided a fix for arm64, I want to fix this globally because the same issue is happening on riscv since commit 2348e6bf4421 ("riscv: remove special treatment for the link order of head.o"). This problem will happen in general for other architectures if they start to drop unneeded entries from scripts/head-object-list.txt. Discard .note.GNU-stack in include/asm-generic/vmlinux.lds.h. Link: https://lore.kernel.org/lkml/CAABkxwuQoz1CTbyb57n0ZX65eSYiTonFCU8-LCQc=74D=xE=rA@mail.gmail.com/ Fixes: 994b7ac1697b ("arm64: remove special treatment for the link order of head.o") Fixes: 2348e6bf4421 ("riscv: remove special treatment for the link order of head.o") Reported-by: Dennis Gilmore Suggested-by: Ard Biesheuvel Signed-off-by: Masahiro Yamada --- Changes in v2: - discard .note.GNU-stack before .notes because many architectures call DISCARDS at the end of their linker scripts include/asm-generic/vmlinux.lds.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index a94219e9916f..659bf3b31c91 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -891,7 +891,12 @@ #define PRINTK_INDEX #endif +/* + * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler. + * Otherwise, the type of .notes section would become PROGBITS instead of NOTES. + */ #define NOTES \ + /DISCARD/ : { *(.note.GNU-stack) } \ .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ BOUNDED_SECTION_BY(.note.*, _notes) \ } NOTES_HEADERS \ -- 2.34.1