* Re: [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment
2026-06-10 1:31 [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment Nathan Chancellor
@ 2026-06-10 7:45 ` Thomas Weißschuh
2026-06-10 22:47 ` Nathan Chancellor
2026-06-10 15:50 ` Nick Desaulniers
2026-06-15 10:27 ` Thomas Bogendoerfer
2 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2026-06-10 7:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Thomas Gleixner, Thomas Bogendoerfer, Bill Wendling, Justin Stitt,
linux-mips, linux-kernel, llvm, Nick Desaulniers
On Tue, Jun 09, 2026 at 06:31:21PM -0700, Nathan Chancellor wrote:
> After commit 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into
> MIPS_GENERIC_GETTIMEOFDAY"), building ARCH=mips allnoconfig with LLVM=1
> shows some warnings from llvm-readelf while checking the VDSO for
> dynamic relocations:
>
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': invalid PT_DYNAMIC size (0xa4)
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
>
> The blamed commit alters the link order of objects into vdso.so.raw,
> placing vgettimeofday.o after sigreturn.o. This ultimately results in
> the .text section shrinking slightly in size, which in turn changes the
> offset of the .dynamic section.
>
> - [ 9] .text PROGBITS 000002f0 0002f0 000930 00 AX 0 0 16
> - [10] .dynamic DYNAMIC 00000c20 000c20 000090 08 A 5 0 4
> + [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> + [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
>
> Changing the offset of the .dynamic section causes the dynamic segment
> size to grow by the same amount, which triggers a warning in
> llvm-readelf because PT_DYNAMIC's p_filesz (0xa4) is no longer a
> multiple of its sh_entsize (8):
>
> - DYNAMIC 0x000c20 0x00000c20 0x00000c20 0x00098 0x00098 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
>
> The size of the dynamic segment was already incorrect before the blamed
> comment, as it should be 0x90 like the .dynamic section above (18
> entries at 8 bytes per entry); it just so happens that 0x98 % 8 is 0,
> whereas 0xa4 % 8 is 4, so there was no warning.
>
> Looking at the section to segment mapping of the dynamic segment reveals
> that it includes the .got section, as it is implicitly placed after
> .dynamic by ld.lld's orphan section heuristics and inherits its segments
> from the linker script.
>
> [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
> [11] .got PROGBITS 00000cb0 000cb0 000008 00 WAp 0 0 16
>
> Section to Segment mapping:
> Segment Sections...
> 00 .mips_abiflags
> 01 .reginfo
> 02 .mips_abiflags .reginfo .hash .dynsym .dynstr .gnu.version .gnu.version_d .note .text .dynamic .got
> 03 .dynamic .got
> 04 .note
>
> Explicitly describe the .got section in the MIPS VDSO linker script
> after .rodata, which switches back to the default text segment,
> resulting in a dynamic segment that is the exact size of the .dynamic
> section as expected with no other layout changes.
>
> - DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x00090 0x00090 R 0x4
>
> - 03 .dynamic .got
> + 03 .dynamic
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2166
> Fixes: 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into MIPS_GENERIC_GETTIMEOFDAY")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> The fixes tag feels a little strong since it seems like it has just been
> luck up until this point that there has been no warning but I decided to
> be conservative and include it regardless. Feel free to remove it if you
> see fit.
I have seen this issue independently from the commit blamed above.
It occurs at least on commit 2b7a25df823d ("Merge tag 'mm-nonmm-stable-2026-02-18-19-56'
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm").
If you want I can investigate more, but the Fixes above works for me, too.
> I think this should go via timers/vdso with the blamed commit. I plan to
> send a follow up series for 7.3 to add '--orphan-handling' to the MIPS
> VDSO to avoid issues like this in the future but that can go via the
> MIPS tree, as it is not really a fix and I will need to properly test
> it.
> ---
> arch/mips/vdso/vdso.lds.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S
> index 05badf3ae0ff..278ab6444e98 100644
> --- a/arch/mips/vdso/vdso.lds.S
> +++ b/arch/mips/vdso/vdso.lds.S
> @@ -56,6 +56,7 @@ SECTIONS
> .dynamic : { *(.dynamic) } :text :dynamic
>
> .rodata : { *(.rodata*) } :text
> + .got : { *(.got) }
>
> _end = .;
> PROVIDE(end = .);
>
> ---
> base-commit: 13f6218e6fe79dc64aed76d738b765b45f62492b
> change-id: 20260608-mips-vdso-fix-section-layout-262bc18d0c29
>
> Best regards,
> --
> Cheers,
> Nathan
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment
2026-06-10 7:45 ` Thomas Weißschuh
@ 2026-06-10 22:47 ` Nathan Chancellor
0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2026-06-10 22:47 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Thomas Gleixner, Thomas Bogendoerfer, Bill Wendling, Justin Stitt,
linux-mips, linux-kernel, llvm, Nick Desaulniers
On Wed, Jun 10, 2026 at 09:45:08AM +0200, Thomas Weißschuh wrote:
> On Tue, Jun 09, 2026 at 06:31:21PM -0700, Nathan Chancellor wrote:
> > The fixes tag feels a little strong since it seems like it has just been
> > luck up until this point that there has been no warning but I decided to
> > be conservative and include it regardless. Feel free to remove it if you
> > see fit.
>
> I have seen this issue independently from the commit blamed above.
> It occurs at least on commit 2b7a25df823d ("Merge tag 'mm-nonmm-stable-2026-02-18-19-56'
> of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm").
> If you want I can investigate more, but the Fixes above works for me, too.
Maybe it would be better to blame the original vDSO commit then?
Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO")
I cannot build with LLVM back that far but something tells me that this
could happen back then too just because .got is not described there. I
don't have a strong opinion though, this does not appear to be a
functional issue since llvm-readelf just falls back to using .dynamic
directly IIUC. I guess tglx could make the call during application if he
is okay with that?
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment
2026-06-10 1:31 [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment Nathan Chancellor
2026-06-10 7:45 ` Thomas Weißschuh
@ 2026-06-10 15:50 ` Nick Desaulniers
2026-06-15 10:27 ` Thomas Bogendoerfer
2 siblings, 0 replies; 5+ messages in thread
From: Nick Desaulniers @ 2026-06-10 15:50 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Thomas Weißschuh, Thomas Gleixner, Thomas Bogendoerfer,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Nick Desaulniers
On Tue, Jun 09, 2026 at 06:31:21PM -0700, Nathan Chancellor wrote:
> After commit 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into
> MIPS_GENERIC_GETTIMEOFDAY"), building ARCH=mips allnoconfig with LLVM=1
> shows some warnings from llvm-readelf while checking the VDSO for
> dynamic relocations:
>
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': invalid PT_DYNAMIC size (0xa4)
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
>
> The blamed commit alters the link order of objects into vdso.so.raw,
> placing vgettimeofday.o after sigreturn.o. This ultimately results in
> the .text section shrinking slightly in size, which in turn changes the
> offset of the .dynamic section.
>
> - [ 9] .text PROGBITS 000002f0 0002f0 000930 00 AX 0 0 16
> - [10] .dynamic DYNAMIC 00000c20 000c20 000090 08 A 5 0 4
> + [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> + [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
>
> Changing the offset of the .dynamic section causes the dynamic segment
> size to grow by the same amount, which triggers a warning in
> llvm-readelf because PT_DYNAMIC's p_filesz (0xa4) is no longer a
> multiple of its sh_entsize (8):
>
> - DYNAMIC 0x000c20 0x00000c20 0x00000c20 0x00098 0x00098 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
>
> The size of the dynamic segment was already incorrect before the blamed
> comment, as it should be 0x90 like the .dynamic section above (18
> entries at 8 bytes per entry); it just so happens that 0x98 % 8 is 0,
> whereas 0xa4 % 8 is 4, so there was no warning.
>
> Looking at the section to segment mapping of the dynamic segment reveals
> that it includes the .got section, as it is implicitly placed after
> .dynamic by ld.lld's orphan section heuristics and inherits its segments
> from the linker script.
>
> [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
> [11] .got PROGBITS 00000cb0 000cb0 000008 00 WAp 0 0 16
>
> Section to Segment mapping:
> Segment Sections...
> 00 .mips_abiflags
> 01 .reginfo
> 02 .mips_abiflags .reginfo .hash .dynsym .dynstr .gnu.version .gnu.version_d .note .text .dynamic .got
> 03 .dynamic .got
> 04 .note
>
> Explicitly describe the .got section in the MIPS VDSO linker script
> after .rodata, which switches back to the default text segment,
> resulting in a dynamic segment that is the exact size of the .dynamic
> section as expected with no other layout changes.
>
> - DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x00090 0x00090 R 0x4
>
> - 03 .dynamic .got
> + 03 .dynamic
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2166
> Fixes: 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into MIPS_GENERIC_GETTIMEOFDAY")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for the patch!
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> The fixes tag feels a little strong since it seems like it has just been
> luck up until this point that there has been no warning but I decided to
> be conservative and include it regardless. Feel free to remove it if you
> see fit.
>
> I think this should go via timers/vdso with the blamed commit. I plan to
> send a follow up series for 7.3 to add '--orphan-handling' to the MIPS
> VDSO to avoid issues like this in the future but that can go via the
> MIPS tree, as it is not really a fix and I will need to properly test
> it.
> ---
> arch/mips/vdso/vdso.lds.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S
> index 05badf3ae0ff..278ab6444e98 100644
> --- a/arch/mips/vdso/vdso.lds.S
> +++ b/arch/mips/vdso/vdso.lds.S
> @@ -56,6 +56,7 @@ SECTIONS
> .dynamic : { *(.dynamic) } :text :dynamic
>
> .rodata : { *(.rodata*) } :text
> + .got : { *(.got) }
>
> _end = .;
> PROVIDE(end = .);
>
> ---
> base-commit: 13f6218e6fe79dc64aed76d738b765b45f62492b
> change-id: 20260608-mips-vdso-fix-section-layout-262bc18d0c29
>
> Best regards,
> --
> Cheers,
> Nathan
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment
2026-06-10 1:31 [PATCH] MIPS: VDSO: Avoid including .got in dynamic segment Nathan Chancellor
2026-06-10 7:45 ` Thomas Weißschuh
2026-06-10 15:50 ` Nick Desaulniers
@ 2026-06-15 10:27 ` Thomas Bogendoerfer
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2026-06-15 10:27 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Thomas Weißschuh, Thomas Gleixner, Bill Wendling,
Justin Stitt, linux-mips, linux-kernel, llvm, Nick Desaulniers
On Tue, Jun 09, 2026 at 06:31:21PM -0700, Nathan Chancellor wrote:
> After commit 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into
> MIPS_GENERIC_GETTIMEOFDAY"), building ARCH=mips allnoconfig with LLVM=1
> shows some warnings from llvm-readelf while checking the VDSO for
> dynamic relocations:
>
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': invalid PT_DYNAMIC size (0xa4)
> llvm-readelf: warning: 'arch/mips/vdso/vdso.so.dbg.raw': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
>
> The blamed commit alters the link order of objects into vdso.so.raw,
> placing vgettimeofday.o after sigreturn.o. This ultimately results in
> the .text section shrinking slightly in size, which in turn changes the
> offset of the .dynamic section.
>
> - [ 9] .text PROGBITS 000002f0 0002f0 000930 00 AX 0 0 16
> - [10] .dynamic DYNAMIC 00000c20 000c20 000090 08 A 5 0 4
> + [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> + [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
>
> Changing the offset of the .dynamic section causes the dynamic segment
> size to grow by the same amount, which triggers a warning in
> llvm-readelf because PT_DYNAMIC's p_filesz (0xa4) is no longer a
> multiple of its sh_entsize (8):
>
> - DYNAMIC 0x000c20 0x00000c20 0x00000c20 0x00098 0x00098 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
>
> The size of the dynamic segment was already incorrect before the blamed
> comment, as it should be 0x90 like the .dynamic section above (18
> entries at 8 bytes per entry); it just so happens that 0x98 % 8 is 0,
> whereas 0xa4 % 8 is 4, so there was no warning.
>
> Looking at the section to segment mapping of the dynamic segment reveals
> that it includes the .got section, as it is implicitly placed after
> .dynamic by ld.lld's orphan section heuristics and inherits its segments
> from the linker script.
>
> [ 9] .text PROGBITS 000002f0 0002f0 000924 00 AX 0 0 16
> [10] .dynamic DYNAMIC 00000c14 000c14 000090 08 A 5 0 4
> [11] .got PROGBITS 00000cb0 000cb0 000008 00 WAp 0 0 16
>
> Section to Segment mapping:
> Segment Sections...
> 00 .mips_abiflags
> 01 .reginfo
> 02 .mips_abiflags .reginfo .hash .dynsym .dynstr .gnu.version .gnu.version_d .note .text .dynamic .got
> 03 .dynamic .got
> 04 .note
>
> Explicitly describe the .got section in the MIPS VDSO linker script
> after .rodata, which switches back to the default text segment,
> resulting in a dynamic segment that is the exact size of the .dynamic
> section as expected with no other layout changes.
>
> - DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x000a4 0x000a4 R 0x10
> + DYNAMIC 0x000c14 0x00000c14 0x00000c14 0x00090 0x00090 R 0x4
>
> - 03 .dynamic .got
> + 03 .dynamic
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2166
> Fixes: 2db1ec80dfd5 ("MIPS: VDSO: Fold MIPS_DISABLE_VDSO into MIPS_GENERIC_GETTIMEOFDAY")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> The fixes tag feels a little strong since it seems like it has just been
> luck up until this point that there has been no warning but I decided to
> be conservative and include it regardless. Feel free to remove it if you
> see fit.
>
> I think this should go via timers/vdso with the blamed commit. I plan to
> send a follow up series for 7.3 to add '--orphan-handling' to the MIPS
> VDSO to avoid issues like this in the future but that can go via the
> MIPS tree, as it is not really a fix and I will need to properly test
> it.
> ---
> arch/mips/vdso/vdso.lds.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S
> index 05badf3ae0ff..278ab6444e98 100644
> --- a/arch/mips/vdso/vdso.lds.S
> +++ b/arch/mips/vdso/vdso.lds.S
> @@ -56,6 +56,7 @@ SECTIONS
> .dynamic : { *(.dynamic) } :text :dynamic
>
> .rodata : { *(.rodata*) } :text
> + .got : { *(.got) }
>
> _end = .;
> PROVIDE(end = .);
>
> ---
> base-commit: 13f6218e6fe79dc64aed76d738b765b45f62492b
> change-id: 20260608-mips-vdso-fix-section-layout-262bc18d0c29
applied to mips-next
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 5+ messages in thread