linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
@ 2025-06-03  3:48 Fangrui Song
  2025-06-03 21:52 ` Nathan Chancellor
  2025-06-10 21:40 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 4+ messages in thread
From: Fangrui Song @ 2025-06-03  3:48 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: linux-riscv, linux-kernel, llvm, Fangrui Song

.rodata is implicitly included in the PT_DYNAMIC segment due to
inheriting the segment of the preceding .dynamic section (in both GNU ld
and LLD).  When the .rodata section's size is not a multiple of 16
bytes on riscv64, llvm-readelf will report a "PT_DYNAMIC dynamic table
is invalid" warning.  Note: in the presence of the .dynamic section, GNU
readelf and llvm-readelf's -d option decodes the dynamic section using
the section.

This issue arose after commit 8f8c1ff879fab60f80f3a7aec3000f47e5b03ba9
("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which
placed .rodata directly after .dynamic by removing .eh_frame.

This patch resolves the implicit inclusion into PT_DYNAMIC by explicitly
specifying the :text output section phdr.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://github.com/ClangBuiltLinux/linux/issues/2093
Signed-off-by: Fangrui Song <i@maskray.me>
---
 arch/riscv/kernel/vdso/vdso.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
index abc69cda0445b1f500a89b47deefa31349103f08..62e0410f69f09e2bbf27101c000d604193f525cb 100644
--- a/arch/riscv/kernel/vdso/vdso.lds.S
+++ b/arch/riscv/kernel/vdso/vdso.lds.S
@@ -30,7 +30,7 @@ SECTIONS
 		*(.data .data.* .gnu.linkonce.d.*)
 		*(.dynbss)
 		*(.bss .bss.* .gnu.linkonce.b.*)
-	}
+	}						:text
 
 	.note		: { *(.note.*) }		:text	:note
 

---
base-commit: 1a3f6980889df3fc90ad3e4a525061d2c138adba
change-id: 20250602-riscv-vdso-13efdee34a24

Best regards,
-- 
Fangrui Song <i@maskray.me>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
  2025-06-03  3:48 [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment Fangrui Song
@ 2025-06-03 21:52 ` Nathan Chancellor
  2025-06-10 20:07   ` Palmer Dabbelt
  2025-06-10 21:40 ` patchwork-bot+linux-riscv
  1 sibling, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2025-06-03 21:52 UTC (permalink / raw)
  To: Fangrui Song
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-riscv,
	linux-kernel, llvm

On Mon, Jun 02, 2025 at 08:48:44PM -0700, Fangrui Song wrote:
> .rodata is implicitly included in the PT_DYNAMIC segment due to
> inheriting the segment of the preceding .dynamic section (in both GNU ld
> and LLD).  When the .rodata section's size is not a multiple of 16
> bytes on riscv64, llvm-readelf will report a "PT_DYNAMIC dynamic table
> is invalid" warning.  Note: in the presence of the .dynamic section, GNU
> readelf and llvm-readelf's -d option decodes the dynamic section using
> the section.
> 
> This issue arose after commit 8f8c1ff879fab60f80f3a7aec3000f47e5b03ba9
> ("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which
> placed .rodata directly after .dynamic by removing .eh_frame.
> 
> This patch resolves the implicit inclusion into PT_DYNAMIC by explicitly
> specifying the :text output section phdr.
> 
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2093
> Signed-off-by: Fangrui Song <i@maskray.me>

Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/riscv/kernel/vdso/vdso.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
> index abc69cda0445b1f500a89b47deefa31349103f08..62e0410f69f09e2bbf27101c000d604193f525cb 100644
> --- a/arch/riscv/kernel/vdso/vdso.lds.S
> +++ b/arch/riscv/kernel/vdso/vdso.lds.S
> @@ -30,7 +30,7 @@ SECTIONS
>  		*(.data .data.* .gnu.linkonce.d.*)
>  		*(.dynbss)
>  		*(.bss .bss.* .gnu.linkonce.b.*)
> -	}
> +	}						:text
>  
>  	.note		: { *(.note.*) }		:text	:note
>  
> 
> ---
> base-commit: 1a3f6980889df3fc90ad3e4a525061d2c138adba
> change-id: 20250602-riscv-vdso-13efdee34a24
> 
> Best regards,
> -- 
> Fangrui Song <i@maskray.me>
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
  2025-06-03 21:52 ` Nathan Chancellor
@ 2025-06-10 20:07   ` Palmer Dabbelt
  0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2025-06-10 20:07 UTC (permalink / raw)
  To: nathan
  Cc: i, Paul Walmsley, aou, Alexandre Ghiti, nick.desaulniers+lkml,
	morbo, justinstitt, linux-riscv, linux-kernel, llvm

On Tue, 03 Jun 2025 14:52:18 PDT (-0700), nathan@kernel.org wrote:
> On Mon, Jun 02, 2025 at 08:48:44PM -0700, Fangrui Song wrote:
>> .rodata is implicitly included in the PT_DYNAMIC segment due to
>> inheriting the segment of the preceding .dynamic section (in both GNU ld
>> and LLD).  When the .rodata section's size is not a multiple of 16
>> bytes on riscv64, llvm-readelf will report a "PT_DYNAMIC dynamic table
>> is invalid" warning.  Note: in the presence of the .dynamic section, GNU
>> readelf and llvm-readelf's -d option decodes the dynamic section using
>> the section.
>>
>> This issue arose after commit 8f8c1ff879fab60f80f3a7aec3000f47e5b03ba9
>> ("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which
>> placed .rodata directly after .dynamic by removing .eh_frame.
>>
>> This patch resolves the implicit inclusion into PT_DYNAMIC by explicitly
>> specifying the :text output section phdr.
>>
>> Reported-by: Nathan Chancellor <nathan@kernel.org>
>> Closes: https://github.com/ClangBuiltLinux/linux/issues/2093
>> Signed-off-by: Fangrui Song <i@maskray.me>
>
> Tested-by: Nathan Chancellor <nathan@kernel.org>

Thanks, I'll pick it up (might take a bit to show up on fixes, I'm 
trying to sort out another amdgpu stack warning...)

>
>> ---
>>  arch/riscv/kernel/vdso/vdso.lds.S | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
>> index abc69cda0445b1f500a89b47deefa31349103f08..62e0410f69f09e2bbf27101c000d604193f525cb 100644
>> --- a/arch/riscv/kernel/vdso/vdso.lds.S
>> +++ b/arch/riscv/kernel/vdso/vdso.lds.S
>> @@ -30,7 +30,7 @@ SECTIONS
>>  		*(.data .data.* .gnu.linkonce.d.*)
>>  		*(.dynbss)
>>  		*(.bss .bss.* .gnu.linkonce.b.*)
>> -	}
>> +	}						:text
>>
>>  	.note		: { *(.note.*) }		:text	:note
>>
>>
>> ---
>> base-commit: 1a3f6980889df3fc90ad3e4a525061d2c138adba
>> change-id: 20250602-riscv-vdso-13efdee34a24
>>
>> Best regards,
>> --
>> Fangrui Song <i@maskray.me>
>>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
  2025-06-03  3:48 [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment Fangrui Song
  2025-06-03 21:52 ` Nathan Chancellor
@ 2025-06-10 21:40 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-06-10 21:40 UTC (permalink / raw)
  To: Fangrui Song
  Cc: linux-riscv, paul.walmsley, palmer, aou, alex, nathan,
	nick.desaulniers+lkml, morbo, justinstitt, linux-kernel, llvm

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@dabbelt.com>:

On Mon, 02 Jun 2025 20:48:44 -0700 you wrote:
> .rodata is implicitly included in the PT_DYNAMIC segment due to
> inheriting the segment of the preceding .dynamic section (in both GNU ld
> and LLD).  When the .rodata section's size is not a multiple of 16
> bytes on riscv64, llvm-readelf will report a "PT_DYNAMIC dynamic table
> is invalid" warning.  Note: in the presence of the .dynamic section, GNU
> readelf and llvm-readelf's -d option decodes the dynamic section using
> the section.
> 
> [...]

Here is the summary with links:
  - riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
    https://git.kernel.org/riscv/c/e0eb1b6b0cd2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-10 22:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03  3:48 [PATCH] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment Fangrui Song
2025-06-03 21:52 ` Nathan Chancellor
2025-06-10 20:07   ` Palmer Dabbelt
2025-06-10 21:40 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).