From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796166151; b=evqtbNjXhCZJ14yqzKojqxKISJlXLjdUOlAMA6MXBnb5JVjs9qYkBogn4QE3X9G16NJB VwBa8LlRv0ZdMRij8KCuDzvE99uX8A/xd7ot9YpUpYIOU+YhjuT/ZPPFH/G6EqrE2DV/W 8iAenQkv/Nz+srH4kw6l3fNdhfuujZERoXW1hE/EUypaQ0ZFJTomAR4pM4nliv56UiOU6 gFH4KYRb6BauT+yiZNEuw9Ngm7+/IObv2BYjGENh4baKV1R8qVGoOMFlLgp1KCzzD4igG pr/gxTrTmXByW1/6dx3buaOt4BaykFqJgso+tuDpjaW2W1aknIdpLmS6RagU7p2Ee2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796166151; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=Dp0ptmMH9AiAjl0PEJod+jV7CN0+3XiY2yqBiZ8AFM4=; b=z2vfpEhb6Ua+EqFEYUFgVZta0nTFDNfvKvAEa+v4rj9b7vUcAwCl2guuzAIoJ6LuhlXS uG6Muv8RNzwZYuvBkK1XkjS9PYsTN+sCQ3DhYzbh99qSD6+mbQ/BZTyR/Em9KIqp+/mND JGZmVUfyRiNAJQTNvjHvy09N8PEx89WbKvvbZZgw4691pfXmCJA49CQEcLs6aCUplJ0Gz 16DBlobwT6x9Sd4k4CCsk1Ds1y71/URsxeIm/d/UFJNfevxhwnEXHn644u/Rh5yuMXObd cZ8Z7pW+HP006DnS3+Xdv/iG8UFEsASFS3bUSpiPJWc9HBaIBPQLtJR7G8CH0JpCw9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--yabinc.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=CsEXZupg; arc=none smtp.remote-ip=74.125.82.198 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBBC4606A320 for ; Tue, 1 Dec 2026 23:02:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBBC4606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yabinc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=CsEXZupg Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-375bac6bd21so11691937eec.0 for ; Tue, 01 Dec 2026 15:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796166150; x=1796770950; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Dp0ptmMH9AiAjl0PEJod+jV7CN0+3XiY2yqBiZ8AFM4=; b=CsEXZupghMPgK/D9rxq7HPsGRdM0KeFA+GCZ7Sq0B/uoSq6PohDNPwKcy5eee0XHcp DvuCswkHIehztzhsVGWWIduy/ZI5ulYH7uTO20E9NkUwFqXZGINDowaEViPxBzxQ9lcI YjJz5HCdVWkweRqne/crWzO/Z77sYAhC1eEjuyRWZkQsg2Gi+R8XVLQ5jylBCYAGO5u4 aHkGcbgO3RV0g5mb7KRqvlNZ523wDbSYvCsJxE7zwgDxy+g3ADeVGyMwQj4zUHjcUnr7 W3VnZy1fkNMbRRdQPEKYY0gyAbZSZUsDG4zYgxaSn1jm54f23e5N2CBSxhUpSwVUGnOq t6Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796166150; x=1796770950; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Dp0ptmMH9AiAjl0PEJod+jV7CN0+3XiY2yqBiZ8AFM4=; b=Th2JsQNe1xcYBo7znshD0Xs8TsyY796Vp/l3pBrkfD6ZQCG2WzpTraLyJMYhwPBSNh RResHGglBCNZmiYWEQbsQLpbCH57FMcmwJ5H3egFSVbeHZY2icim7Nblabrs7s1GHeRt aJopL8YEydoRFQwEcO5OvTuN1s5EgjwNjiQsv+z4GzDqhHrM7mFxti+OB5Hme1trKC4J uPp9lJbofhIcoQdsU5n6c4mz/4sxIkpGRIFLCESBVJgNZCLSXv4f1L5OT9lzIHboDbI1 FEUvY+wewx3Zmb2/SRxqB+XKtCZ+eZL9rTkWVwWZygi/4R+zxo4So7YssABIKkoRD2Rz hYoQ== X-Forwarded-Encrypted: i=1; AL+hErHx+oEG3E45l8eaTJ2SPzC8uVfy0p0lzNlZI1wAwmzMdXWKF1S/BPFjAH2QDnVpZsTfmYiXpzNMRPaPdY4=@vger.kernel.org X-Gm-Message-State: APuU4Z9Ob4LME8KFYBjLiTWwnoak184ZevNvgKy+SpFpLsi0gFIQVuGP qmpPpip8buxbjLNEX9/KafsNiIdIkluHEjFDJlxufm10BFNXndM0OZiMGUNxLfbM6RdOH3JNAhp Am+7Q X-Received: from dyco9.prod.google.com ([2002:a05:7300:51c9:b0:386:c6ca:4211]) (user=yabinc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:d18b:b0:386:b4f1:dab0 with SMTP id 5a478bee46e88-386b4f1e04fmr29595198eec.1.1796166149336; Tue, 01 Dec 2026 15:02:29 -0800 (PST) Date: Tue, 1 Dec 2026 23:02:28 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261201230228.579036-1-yabinc@google.com> Subject: [PATCH] kbuild: modinst: Strip .llvm_bb_addr_map on INSTALL_MOD_STRIP=1 From: Yabin Cui To: Nathan Chancellor , Nicolas Schier Cc: Rong Xu , Han Shen , Nick Desaulniers , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Yabin Cui Content-Type: text/plain; charset="UTF-8" When CONFIG_PROPELLER_CLANG is enabled without CLANG_PROPELLER_PROFILE_PREFIX, Clang and LLD emit non-SHF_ALLOC .llvm_bb_addr_map metadata sections (along with .rela.llvm_bb_addr_map relocation sections and, on arm64, associated $d mapping symbols in .symtab) into loadable .ko modules. These sections must remain in the unstripped build-tree .ko files so offline tools such as llvm-propeller can generate profiles from them, but they are unused at runtime and inflate installed modules when INSTALL_MOD_STRIP=1 is passed to modules_install because --strip-debug only removes standard debug sections. For example, across 405 stripped arm64 modules in a 6.18 kernel build, leaving .llvm_bb_addr_map, its relocations, and associated $d mapping symbols behind adds ~4.2 MB (~5.7%) uncompressed. Append --remove-section=.llvm_bb_addr_map to the default strip options in scripts/Makefile.modinst when INSTALL_MOD_STRIP=1 and CONFIG_PROPELLER_CLANG is enabled. Stripping inside cmd_strip runs before cmd_sign and module compression, preserving appended module signatures and compressed outputs while leaving custom INSTALL_MOD_STRIP values unchanged. Both llvm-strip and GNU strip support --remove-section=, remove all .llvm_bb_addr_map sections along with their .rela.llvm_bb_addr_map relocations and associated symbol table entries, and exit cleanly without warnings when .llvm_bb_addr_map is absent (for example, when building with CLANG_PROPELLER_PROFILE_PREFIX). Update the INSTALL_MOD_STRIP descriptions in scripts/Makefile.modinst, Documentation/kbuild/kbuild.rst, and Documentation/kbuild/makefiles.rst accordingly. Verified with out-of-tree LLVM=1 builds and modules_install on x86_64 (both llvm-strip and GNU strip 2.47) and arm64 (non-LTO and ThinLTO) with CONFIG_DEBUG_INFO=y and CONFIG_MODULE_SIG_ALL=y: - Unstripped build-tree .ko files retain .debug_*, .llvm_bb_addr_map, and .rela.llvm_bb_addr_map. - Installed .ko files with INSTALL_MOD_STRIP=1 and CONFIG_PROPELLER_CLANG=y strip all of those sections (and associated arm64 $d symbols) while keeping valid PKCS#7 appended signatures (unsigned prime_numbers.ko shrinks from 8384 to 7608 bytes on x86_64 and from 9168 to 8376 bytes on arm64, matching CONFIG_PROPELLER_CLANG=n installed sizes). - CONFIG_PROPELLER_CLANG=n passes only --strip-debug, and custom INSTALL_MOD_STRIP=--strip-unneeded overrides the defaults. The patch, documentation updates, changelog, and build/strip verification were prepared with assistance from Gemini based on the problem description and proposed fix. Fixes: d5dc95836147 ("kbuild: Add Propeller configuration for kernel build") Signed-off-by: Yabin Cui --- Documentation/kbuild/kbuild.rst | 6 ++++-- Documentation/kbuild/makefiles.rst | 7 ++++--- scripts/Makefile.modinst | 8 ++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index e71a692a559a..6fd22b0af069 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -270,8 +270,10 @@ INSTALL_MOD_STRIP ----------------- INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is '1', then -the default option --strip-debug will be used. Otherwise, -INSTALL_MOD_STRIP value will be used as the options to the strip command. +the default option --strip-debug will be used (along with +--remove-section=.llvm_bb_addr_map when CONFIG_PROPELLER_CLANG is +enabled). Otherwise, INSTALL_MOD_STRIP value will be used as the +options to the strip command. INSTALL_HDR_PATH ---------------- diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 535d30eef59a..69c8a8da6544 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -1686,9 +1686,10 @@ INSTALL_MOD_PATH, MODLIB INSTALL_MOD_STRIP If this variable is specified, it will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is "1", then the - default option --strip-debug will be used. Otherwise, the - INSTALL_MOD_STRIP value will be used as the option(s) to the strip - command. + default option --strip-debug will be used (along with + --remove-section=.llvm_bb_addr_map when CONFIG_PROPELLER_CLANG is + enabled). Otherwise, the INSTALL_MOD_STRIP value will be used as + the option(s) to the strip command. INSTALL_DTBS_PATH This variable specifies a prefix for relocations required by build diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 9ba45e5b32b1..1cef4b4485cd 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -75,12 +75,16 @@ quiet_cmd_install = INSTALL $@ # # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they # are installed. If INSTALL_MOD_STRIP is '1', then the default option -# --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used -# as the options to the strip command. +# --strip-debug will be used (along with --remove-section=.llvm_bb_addr_map +# when CONFIG_PROPELLER_CLANG is enabled). Otherwise, INSTALL_MOD_STRIP value +# will be used as the options to the strip command. ifdef INSTALL_MOD_STRIP ifeq ($(INSTALL_MOD_STRIP),1) strip-option := --strip-debug +ifdef CONFIG_PROPELLER_CLANG +strip-option += --remove-section=.llvm_bb_addr_map +endif else strip-option := $(INSTALL_MOD_STRIP) endif base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.56.1.911.g883d8bcb20-goog