[PATCH] kbuild: exclude .rodata.(cst|str)* when building ranges

Kris Van Hees posted 1 patch 11 months, 1 week ago
There is a newer version of this series
scripts/generate_builtin_ranges.awk | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] kbuild: exclude .rodata.(cst|str)* when building ranges
Posted by Kris Van Hees 11 months, 1 week ago
The .rodata.(cst|str)* sections are often resized during the final
linking and since these sections do not cover actual symbols there is
no need to include them in the modules.builtin.ranges data.

When these sections were included in processing and resizing occurred,
modules were reported with ranges that extended beyond their true end,
causing subsequent symbols (in address order) to be associated with
the wrong module.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
---
 scripts/generate_builtin_ranges.awk | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/generate_builtin_ranges.awk b/scripts/generate_builtin_ranges.awk
index b9ec761b3bef..d4bd5c2b998c 100755
--- a/scripts/generate_builtin_ranges.awk
+++ b/scripts/generate_builtin_ranges.awk
@@ -282,6 +282,11 @@ ARGIND == 2 && !anchor && NF == 2 && $1 ~ /^0x/ && $2 !~ /^0x/ {
 # section.
 #
 ARGIND == 2 && sect && NF == 4 && /^ [^ \*]/ && !($1 in sect_addend) {
+	# There are a few sections with constant data (without symbols) that
+	# can get resized during linking, so it is best to ignore them.
+	if ($1 ~ /^\.rodata\.(cst|str)[0-9]/)
+		next;
+
 	if (!($1 in sect_base)) {
 		sect_base[$1] = base;
 
-- 
2.45.2
Re: [PATCH] kbuild: exclude .rodata.(cst|str)* when building ranges
Posted by Masahiro Yamada 11 months ago
On Thu, Mar 6, 2025 at 4:28 AM Kris Van Hees <kris.van.hees@oracle.com> wrote:
>
> The .rodata.(cst|str)* sections are often resized during the final
> linking and since these sections do not cover actual symbols there is
> no need to include them in the modules.builtin.ranges data.
>
> When these sections were included in processing and resizing occurred,
> modules were reported with ranges that extended beyond their true end,
> causing subsequent symbols (in address order) to be associated with
> the wrong module.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
> ---

Applied with the following tag:

Fixes: 5f5e7344322f ("kbuild: generate offset range data for builtin modules")

Please let me know if this is wrong.

-- 
Best Regards
Masahiro Yamada
Re: [PATCH] kbuild: exclude .rodata.(cst|str)* when building ranges
Posted by Masahiro Yamada 11 months ago
On Tue, Mar 11, 2025 at 6:17 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Thu, Mar 6, 2025 at 4:28 AM Kris Van Hees <kris.van.hees@oracle.com> wrote:
> >
> > The .rodata.(cst|str)* sections are often resized during the final
> > linking and since these sections do not cover actual symbols there is
> > no need to include them in the modules.builtin.ranges data.
> >
> > When these sections were included in processing and resizing occurred,
> > modules were reported with ranges that extended beyond their true end,
> > causing subsequent symbols (in address order) to be associated with
> > the wrong module.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> > Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
> > ---
>
> Applied with the following tag:
>
> Fixes: 5f5e7344322f ("kbuild: generate offset range data for builtin modules")
>
> Please let me know if this is wrong.


Ah, v2 was submitted already.
I will take that one.


-- 
Best Regards
Masahiro Yamada
Re: [PATCH] kbuild: exclude .rodata.(cst|str)* when building ranges
Posted by Steven Rostedt 11 months ago
On Wed,  5 Mar 2025 14:27:58 -0500
Kris Van Hees <kris.van.hees@oracle.com> wrote:

> The .rodata.(cst|str)* sections are often resized during the final
> linking and since these sections do not cover actual symbols there is
> no need to include them in the modules.builtin.ranges data.
> 
> When these sections were included in processing and resizing occurred,
> modules were reported with ranges that extended beyond their true end,
> causing subsequent symbols (in address order) to be associated with
> the wrong module.

If that's the case, shouldn't this be considered a fix, and include a fixes
tag as well as Cc stable?

-- Steve


> 
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
> ---