From: Petr Pavlu <petr.pavlu@suse.com>
To: Jim Cromie <jim.cromie@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Jason Baron <jbaron@akamai.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-modules@vger.kernel.org
Subject: Re: [PATCH 5/5] dyndbg.lds.S: fix lost dyndbg sections in modules
Date: Tue, 5 May 2026 09:26:25 +0200 [thread overview]
Message-ID: <0487a38a-ddb0-4abd-a1f1-fd98551ccb09@suse.com> (raw)
In-Reply-To: <20260502-asm-generic-1-v1-5-1103ee0152df@gmail.com>
On 5/3/26 2:05 AM, Jim Cromie wrote:
> 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 declares the 2 BOUNDED_SECTION_BY calls, but wraps
> them with output section syntax to keep them as known and separate ELF
> sections in the module.ko. The KEEP fixes the lost section.
>
> 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 <arnd@arndb.de>
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
> ---
[...]
> diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.lds.h
> new file mode 100644
> index 000000000000..f95683aa16b6
> --- /dev/null
> +++ b/include/asm-generic/dyndbg.lds.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#ifndef __ASM_GENERIC_DYNDBG_LDS_H
> +#define __ASM_GENERIC_DYNDBG_LDS_H
> +
> +#include <asm-generic/bounded_sections.lds.h>
> +#define DYNDBG_SECTIONS() \
> + . = ALIGN(8); \
> + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \
> + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)
> +
> +#define MOD_DYNDBG_SECTIONS() \
> + __dyndbg : { \
> + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \
> + } \
> + __dyndbg_classes : { \
> + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \
> + }
The BOUNDED_SECTION_BY() macro always defines the __start and __end
symbols for the section. This is not ideal for modules because these
symbols are created even when no __dyndbg or __dyndbg_classes input
sections are present. Additionally, they cause MOD_DYNDBG_SECTIONS() to
produce dummy output sections with the same names in all modules, even
when dynamic debug is disabled in the config. This unnecessarily
pollutes the modules. Since modules are relocatable files, the usual
method for locating consolidated data in a module is to read its section
table.
The second problem is that MOD_DYNDBG_SECTIONS() should force the
address of all its output sections to 0. Otherwise, when linking modules
with 'ld.bfd -r', sections defined without an address inherit the
location counter, resulting in non-zero sh_addr values in the resulting
.ko files. Non-zero addresses are confusing in this context, typically
worse compressible, and may cause external tools to misbehave.
--
Thanks,
Petr
prev parent reply other threads:[~2026-05-05 7:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 0:05 [PATCH 0/5] PATCH 0/6] dyndbg: fix i386 alignment and KEEP module sections Jim Cromie
2026-05-03 0:05 ` [PATCH 1/5] vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h Jim Cromie
2026-05-03 0:05 ` [PATCH 2/5] vmlinux.lds.h: drop unused HEADERED_SECTION* macros Jim Cromie
2026-05-03 0:05 ` [PATCH 3/5] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 Jim Cromie
2026-05-03 0:05 ` [PATCH 4/5] vmlinux.lds.h: remove redundant ALIGN(8) directives Jim Cromie
2026-05-03 0:05 ` [PATCH 5/5] dyndbg.lds.S: fix lost dyndbg sections in modules Jim Cromie
2026-05-05 7:26 ` Petr Pavlu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0487a38a-ddb0-4abd-a1f1-fd98551ccb09@suse.com \
--to=petr.pavlu@suse.com \
--cc=arnd@arndb.de \
--cc=atomlin@atomlin.com \
--cc=da.gomez@kernel.org \
--cc=jbaron@akamai.com \
--cc=jim.cromie@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox