From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1793132533; b=VDuM+1T8dIIqILGsATQgB8HlalDQjBqy02irW8L38vhk9hz5zYc939YY+ihPirhrVifg kxBioJ4uXcnX+244aVi31ADoAV4tzoTfcJzfJsnPTt92BT1gNOFpWozXneM91auCOXrFV K7cg59H8MsAuJgWSGe90OyabscHWMCzDqaKYh68/Ie8erqsSKyIV8+m+CE8vFHGPBQYLA T/o+dQSeh47IhspPLoQ0Tfp9QELV6LDCRJPlaU8WqK7cFRVq3EcghlqWekV2kmXyIHIgh e6jdPveBSMZTS8fUT0dCbjavhlpJf0zNk+qqqzm4a05EDnzlRyPE704tfHcNx1bSBzA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793132533; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=NC9qvcyyabYBeEaWH7GJHJeHZrorUabfraI24jDZ6iY=; b=4Stj9hsqiHjcL+WMER3WwP/28XaBOB6MkhE7LE2ZohQzg2tt1wkDD8zxAe1+OuBpNqqP eqBu2FYNY5ABj1wy8xCCf79E89N1WxIg0kusY7pPTwrQu8frYwVux/eTVXxfGwZw1irXX LyiguRGPFiARGcjXV+rz6Vdoi2inggf9sdcE6z6PxFo8G0ZBm+sujadZC7pAZD42TqEG7 7NBeQSX0HEce52dUNfIQPYAqpdwwyz52nv2UE7qcAJcRgg9drtdGsNd5FGPxbgCGRYGVV 3uFzL54yU9gHGzmqUx33ZSNz/7Mu7j1bWVcYdieSAW84jzAmxs/U70gSsu3NMy5wTgw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MmdUdjye; arc=fail smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EBBC606A327; Tue, 27 Oct 2026 20:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MmdUdjye Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1793132532; b=N4iEXoynLsDIVGtAn2cw7rr+ypTMJfINLRq+tSF43GnAuiftQB26M9gRqKrq/U09bJWH TrWqQ+qh1IBr3zuTpOZIfzd+oVdFOH5AihWAIsn5tGn8LNUTuy+jqAYGGkvoUB243+HBB UJ06B3mxNPlJzal/Pem0WYdtOyy43ASPLYhEwNXsvs+sZA8iLkKhHLh3kDS9500UmNH23 io4BSFr/7sOZ2/QRAp2EHSXFheaSFdfd8hGGlBrRATwFwEjjaUw5jcpI5Yk7vadUBNz4a 0/ej6CQ+FXNS5rc4SEJkuL9BBO1lhYVsKUhTHZXBuf3/ca1KL7ARigd4wVT1jXTxCjg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1793132532; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=NC9qvcyyabYBeEaWH7GJHJeHZrorUabfraI24jDZ6iY=; b=i7E9/fqTH/6gCBCjiBgWbcMHbhaZhWYG8IujCH2VMha9ueEVjuPB1gNP6aJoIwGUGCMa RcGECtQu9rnzAZXVKVcy+n0xivsKLadXI1Xf4OwksQLkcxzGyIJMIoQFwuFbUCPiWI0p6 17lnqy+HapT5L/1aRge1M9bgP8MU9MR0d3xgn5OrQ8YZv6gzwNNMaQiQzQFkebPlToGFH khVlBSoVeNXxEzgUmugJlGgO6NbbApT1TsQe14ZG63Ymfx1a2kNRj3fgcVxclyQ5ld+xK AjAnq8XZZQn4bJ/1umj289HBwYGT6zCNxttC0lurTbISsF5VoeKgkeIASW79ktr1Ovw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 691541F031E3; Tue, 27 Oct 2026 20:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793132532; bh=NC9qvcyyabYBeEaWH7GJHJeHZrorUabfraI24jDZ6iY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=MmdUdjyeKMle6Lr+ZR8Yay6rEpvrPf+VYi9XHckuwvyoL4ZAct3+TrIqKcHR56g9K u4QPYrUgjCuDlbM8KwPRcO4nBJBaJFWguvUGUdL1KIuW7axhhp+uejLzvSyxhXqZn3 OoT/NH9ZUA8wlX9rFtkPp8Eq3NrsFDl+dUeM7T1/K3L8fiTtiqvdnnZzA645LINM0K /yxn6uZWEADgrrdlVa2SX8I8UD9Vz7moa1QKgzV9Ynnt02zqd1aaqHC134W8CSL/A6 QiAY54mS4LPdn768VltI83yWWDN/lUwlAc2/HZdR0M7Oivwk1ctb2M6Ve+N08o3xlD 8iPibG+rwGEIg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id CFC0C45209; Tue, 27 Oct 2026 20:22:09 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Tue, 27 Oct 2026 14:22:06 -0600 Subject: [PATCH v13 06/39] dyndbg.lds.S: fix lost dyndbg sections in modules 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 Content-Type: text/plain; charset="utf-8" Message-Id: <20261027-dd-cmap-part2-clean-v13-6-9267923be612@gmail.com> References: <20261027-dd-cmap-part2-clean-v13-0-9267923be612@gmail.com> In-Reply-To: <20261027-dd-cmap-part2-clean-v13-0-9267923be612@gmail.com> To: Jason Baron , Shuah Khan , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Jonathan Corbet , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier , Shuah Khan , Randy Dunlap , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Jonathan Corbet , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-pm@vger.kernel.org, Jason Baron , Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793132527; l=5098; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=eZWQ3goXmct9svzcYam5cB2wbeXp5w4fDAcHi11IsRs=; b=rr9GdMdGpAwS7pPzsye5nsxCNnBuN4B9La/NcNeJke1xHgp7JBr4sUh4Iqk4O54hSCcy09Nnz hFNDd7f3vkuC0tWXMUaeZvy3FcVMpPXxpXVPGKcdCdPl66f9Ilajy2s X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com Content-Transfer-Encoding: 7bit From: Jim Cromie With CONFIG_DRM_USE_DYNAMIC_DEBUG=y, several build configs had problems with __dyndbg* sections getting lost in drm drivers. Fix this by following the model demonstrated in codetag.lds.h. Introduce include/asm-generic/dyndbg.lds.h, to bundle dynamic-debug's multiple sections together, into 2 macros: vmlinux.lds.h DATA_DATA: move the 2 BOUNDED_SECTION_BY(__dyndbg*) calls into dyndbg.lds.h DYNDBG_SECTIONS(). vmlinux.lds.h now includes the new file and calls the new macro. MOD_DYNDBG_SECTIONS keeps the 2 sections by name, aligns them and sets the output address to 0 when the sections are empty. dyndbg.lds.h includes (reuses) bounded-section.lds.h scripts/module.lds.S: now calls MOD_DYNDBG_SECTIONS right before the CODETAG macro (consistent with their placements in vmlinux.lds.h), and also includes dyndbg.lds.h This isolates vmlinux.lds.h from further __dyndbg section additions. CC: Arnd Bergmann Signed-off-by: Jim Cromie Reviewed-by: Petr Pavlu --- v3: move #includes to top, drop extra ALIGN(8) in DYNDBG_SECTIONS, add RvBy v2: Address linker script review feedback for relocatable modules. MOD_DYNDBG_SECTIONS() used the BOUNDED_SECTION_BY() macro, which proved problematic for kernel modules for two reasons: 1. Unwanted Empty Sections: BOUNDED_SECTION_BY() automatically generates `__start` and `__stop` symbols. When applied to `MOD_DYNDBG_SECTIONS()`, the linker assumes the sections are populated due to the symbol definitions, forcing an empty `__dyndbg` and `__dyndbg_classes` output section in every compiled module, even those without dynamic debug configuration. Since the module loader uses `section_objs()` to locate data via ELF headers instead of relying on `__start`/`__stop` symbols, these assignments are completely unnecessary. 2. Non-zero Output Addresses: During relocatable linking (e.g., `ld.bfd -r`), omitting an explicit base address causes the section to inherit the current location counter. This results in non-zero sh_addr values in `.ko` files, which is confusing, degrades compressibility, and can cause issues with external tools parsing the ELF. Fix both issues by dropping `BOUNDED_SECTION_BY()` in favor of a simple `KEEP(*(...))` constraint and explicitly defining the sections with a `0` base address: `__dyndbg 0 : ALIGN(8) { ... }`. fixup-inc-vml --- MAINTAINERS | 1 + include/asm-generic/dyndbg.lds.h | 18 ++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 6 ++---- scripts/module.lds.S | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 942a93e21d75..9fee1d699164 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9259,6 +9259,7 @@ DYNAMIC DEBUG M: Jason Baron M: Jim Cromie S: Maintained +F: include/asm-generic/dyndbg.lds.h F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.lds.h new file mode 100644 index 000000000000..9d8951bef688 --- /dev/null +++ b/include/asm-generic/dyndbg.lds.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DYNDBG_LDS_H +#define __ASM_GENERIC_DYNDBG_LDS_H + +#include +#define DYNDBG_SECTIONS() \ + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) + +#define MOD_DYNDBG_SECTIONS() \ + __dyndbg 0 : ALIGN(8) { \ + KEEP(*(__dyndbg)) \ + } \ + __dyndbg_classes 0 : ALIGN(8) { \ + KEEP(*(__dyndbg_classes)) \ + } + +#endif /* __ASM_GENERIC_DYNDBG_LDS_H */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index c3376665d027..48f00c5e8762 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -52,6 +52,7 @@ #include #include +#include #ifndef LOAD_OFFSET #define LOAD_OFFSET 0 @@ -344,10 +345,7 @@ *(.data..do_once) \ STRUCT_ALIGN(); \ *(__tracepoints) \ - /* implement dynamic printk debug */ \ - . = ALIGN(8); \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + DYNDBG_SECTIONS() \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ diff --git a/scripts/module.lds.S b/scripts/module.lds.S index d0f200428957..5950ff8edc31 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -5,6 +5,7 @@ */ #include +#include SECTIONS { /DISCARD/ : { @@ -56,6 +57,7 @@ SECTIONS { *(.rodata..L*) } + MOD_DYNDBG_SECTIONS() MOD_SEPARATE_CODETAG_SECTIONS() } -- 2.56.0