linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO
@ 2022-06-30 15:31 Nathan Chancellor
  2022-06-30 15:31 ` [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-06-30 15:31 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Joey Gouly, Vincenzo Frascino, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, llvm, patches, Nathan Chancellor

Hi all,

This small series fixes two issues I noticed with the orphan section
warnings in the 32-bit vDSO. See the individual commits for the boring
details.

They are based on for-next/vdso. I compiled with LLVM 11, LLVM 15, and
GCC 12.1.0 + binutils 2.38 with no additional warnings/errors.

Nathan Chancellor (2):
  arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS
  arm64: vdso32: Add DWARF_DEBUG

 arch/arm64/kernel/vdso32/vdso.lds.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: 4274929c7ee6f442c3f89c5da64d112a9de4a6ba
-- 
2.37.0


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

* [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS
  2022-06-30 15:31 [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Nathan Chancellor
@ 2022-06-30 15:31 ` Nathan Chancellor
  2022-06-30 15:35   ` Nathan Chancellor
  2022-06-30 15:31 ` [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG Nathan Chancellor
  2022-07-01 15:41 ` [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Will Deacon
  2 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2022-06-30 15:31 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Joey Gouly, Vincenzo Frascino, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, llvm, patches, Nathan Chancellor

When building the 32-bit vDSO after commit 5c4fb60816ea ("arm64: vdso32:
add ARM.exidx* sections"), ld.lld 11 fails to link:

  ld.lld: error: could not allocate headers
  ld.lld: error: unable to place section .text at file offset [0x2A0, 0xBB1]; check your linker script for overflows
  ld.lld: error: unable to place section .comment at file offset [0xBB2, 0xC8A]; check your linker script for overflows
  ld.lld: error: unable to place section .symtab at file offset [0xC8C, 0xE0B]; check your linker script for overflows
  ld.lld: error: unable to place section .strtab at file offset [0xE0C, 0xF1C]; check your linker script for overflows
  ld.lld: error: unable to place section .shstrtab at file offset [0xF1D, 0xFAA]; check your linker script for overflows
  ld.lld: error: section .ARM.exidx file range overlaps with .hash
  >>> .ARM.exidx range is [0x90, 0xCF]
  >>> .hash range is [0xB4, 0xE3]

  ld.lld: error: section .hash file range overlaps with .ARM.attributes
  >>> .hash range is [0xB4, 0xE3]
  >>> .ARM.attributes range is [0xD0, 0x10B]

  ld.lld: error: section .ARM.attributes file range overlaps with .dynsym
  >>> .ARM.attributes range is [0xD0, 0x10B]
  >>> .dynsym range is [0xE4, 0x133]

  ld.lld: error: section .ARM.exidx virtual address range overlaps with .hash
  >>> .ARM.exidx range is [0x90, 0xCF]
  >>> .hash range is [0xB4, 0xE3]

  ld.lld: error: section .ARM.exidx load address range overlaps with .hash
  >>> .ARM.exidx range is [0x90, 0xCF]
  >>> .hash range is [0xB4, 0xE3]

This was fixed in ld.lld 12 with a change to match GNU ld's semantics of
placing non-SHF_ALLOC sections after SHF_ALLOC sections.

To workaround this issue, move the .ARM.exidx section before the
.comment, .symtab, .strtab, and .shstrtab sections (ELF_DETAILS) so that
those sections remain contiguous with the .ARM.attributes section.

Fixes: 5c4fb60816ea ("arm64: vdso32: add ARM.exidx* sections")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/arm64/kernel/vdso32/vdso.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S
index 6e67a6524d58..c25bed8e6df1 100644
--- a/arch/arm64/kernel/vdso32/vdso.lds.S
+++ b/arch/arm64/kernel/vdso32/vdso.lds.S
@@ -56,8 +56,8 @@ SECTIONS
 
 	.rel.dyn	: { *(.rel*) }
 
-	ELF_DETAILS
 	.ARM.exidx : { *(.ARM.exidx*) }
+	ELF_DETAILS
 	.ARM.attributes 0 : { *(.ARM.attributes) }
 
 	/DISCARD/	: {
-- 
2.37.0


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

* [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG
  2022-06-30 15:31 [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Nathan Chancellor
  2022-06-30 15:31 ` [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS Nathan Chancellor
@ 2022-06-30 15:31 ` Nathan Chancellor
  2022-06-30 21:08   ` Nick Desaulniers
  2022-07-01 15:41 ` [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Will Deacon
  2 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2022-06-30 15:31 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Joey Gouly, Vincenzo Frascino, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, llvm, patches, Nathan Chancellor

When building the 32-bit vDSO with LLVM 15 and CONFIG_DEBUG_INFO, there
are the following orphan section warnings:

  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_abbrev) is being placed in '.debug_abbrev'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_info) is being placed in '.debug_info'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_str_offsets) is being placed in '.debug_str_offsets'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_str) is being placed in '.debug_str'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_addr) is being placed in '.debug_addr'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_line) is being placed in '.debug_line'
  ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_line_str) is being placed in '.debug_line_str'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_loclists) is being placed in '.debug_loclists'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_abbrev) is being placed in '.debug_abbrev'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_info) is being placed in '.debug_info'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_rnglists) is being placed in '.debug_rnglists'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_str_offsets) is being placed in '.debug_str_offsets'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_str) is being placed in '.debug_str'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_addr) is being placed in '.debug_addr'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_frame) is being placed in '.debug_frame'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_line) is being placed in '.debug_line'
  ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_line_str) is being placed in '.debug_line_str'

These are DWARF5 sections, as that is the implicit default version for
clang-14 and newer when just '-g' is used. All DWARF sections are
handled by the DWARF_DEBUG macro from include/asm-generic/vmlinux.lds.h
so use that macro here to fix the warnings regardless of DWARF version.

Fixes: 9d4775b332e1 ("arm64: vdso32: enable orphan handling for VDSO")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/arm64/kernel/vdso32/vdso.lds.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S
index c25bed8e6df1..8d95d7d35057 100644
--- a/arch/arm64/kernel/vdso32/vdso.lds.S
+++ b/arch/arm64/kernel/vdso32/vdso.lds.S
@@ -57,6 +57,7 @@ SECTIONS
 	.rel.dyn	: { *(.rel*) }
 
 	.ARM.exidx : { *(.ARM.exidx*) }
+	DWARF_DEBUG
 	ELF_DETAILS
 	.ARM.attributes 0 : { *(.ARM.attributes) }
 
-- 
2.37.0


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

* Re: [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS
  2022-06-30 15:31 ` [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS Nathan Chancellor
@ 2022-06-30 15:35   ` Nathan Chancellor
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-06-30 15:35 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Joey Gouly, Vincenzo Frascino, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, llvm

On Thu, Jun 30, 2022 at 08:31:20AM -0700, Nathan Chancellor wrote:
> When building the 32-bit vDSO after commit 5c4fb60816ea ("arm64: vdso32:
> add ARM.exidx* sections"), ld.lld 11 fails to link:
> 
>   ld.lld: error: could not allocate headers
>   ld.lld: error: unable to place section .text at file offset [0x2A0, 0xBB1]; check your linker script for overflows
>   ld.lld: error: unable to place section .comment at file offset [0xBB2, 0xC8A]; check your linker script for overflows
>   ld.lld: error: unable to place section .symtab at file offset [0xC8C, 0xE0B]; check your linker script for overflows
>   ld.lld: error: unable to place section .strtab at file offset [0xE0C, 0xF1C]; check your linker script for overflows
>   ld.lld: error: unable to place section .shstrtab at file offset [0xF1D, 0xFAA]; check your linker script for overflows
>   ld.lld: error: section .ARM.exidx file range overlaps with .hash
>   >>> .ARM.exidx range is [0x90, 0xCF]
>   >>> .hash range is [0xB4, 0xE3]
> 
>   ld.lld: error: section .hash file range overlaps with .ARM.attributes
>   >>> .hash range is [0xB4, 0xE3]
>   >>> .ARM.attributes range is [0xD0, 0x10B]
> 
>   ld.lld: error: section .ARM.attributes file range overlaps with .dynsym
>   >>> .ARM.attributes range is [0xD0, 0x10B]
>   >>> .dynsym range is [0xE4, 0x133]
> 
>   ld.lld: error: section .ARM.exidx virtual address range overlaps with .hash
>   >>> .ARM.exidx range is [0x90, 0xCF]
>   >>> .hash range is [0xB4, 0xE3]
> 
>   ld.lld: error: section .ARM.exidx load address range overlaps with .hash
>   >>> .ARM.exidx range is [0x90, 0xCF]
>   >>> .hash range is [0xB4, 0xE3]
> 
> This was fixed in ld.lld 12 with a change to match GNU ld's semantics of
> placing non-SHF_ALLOC sections after SHF_ALLOC sections.
> 
> To workaround this issue, move the .ARM.exidx section before the
> .comment, .symtab, .strtab, and .shstrtab sections (ELF_DETAILS) so that
> those sections remain contiguous with the .ARM.attributes section.
> 
> Fixes: 5c4fb60816ea ("arm64: vdso32: add ARM.exidx* sections")

This should have been included to point out the exact commit that fixed
this in ld.lld, I can resend if necessary (since I also screwed up the
patches@lists.linux.dev domain...)

Link: https://github.com/llvm/llvm-project/commit/ec29538af2e0886a65f479d6a533956a1c478132

> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/arm64/kernel/vdso32/vdso.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S
> index 6e67a6524d58..c25bed8e6df1 100644
> --- a/arch/arm64/kernel/vdso32/vdso.lds.S
> +++ b/arch/arm64/kernel/vdso32/vdso.lds.S
> @@ -56,8 +56,8 @@ SECTIONS
>  
>  	.rel.dyn	: { *(.rel*) }
>  
> -	ELF_DETAILS
>  	.ARM.exidx : { *(.ARM.exidx*) }
> +	ELF_DETAILS
>  	.ARM.attributes 0 : { *(.ARM.attributes) }
>  
>  	/DISCARD/	: {
> -- 
> 2.37.0
> 

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

* Re: [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG
  2022-06-30 15:31 ` [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG Nathan Chancellor
@ 2022-06-30 21:08   ` Nick Desaulniers
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Desaulniers @ 2022-06-30 21:08 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, Will Deacon, Joey Gouly, Vincenzo Frascino,
	linux-arm-kernel, linux-kernel, llvm, patches

On Thu, Jun 30, 2022 at 8:32 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building the 32-bit vDSO with LLVM 15 and CONFIG_DEBUG_INFO, there
> are the following orphan section warnings:
>
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_abbrev) is being placed in '.debug_abbrev'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_info) is being placed in '.debug_info'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_str_offsets) is being placed in '.debug_str_offsets'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_str) is being placed in '.debug_str'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_addr) is being placed in '.debug_addr'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_line) is being placed in '.debug_line'
>   ld.lld: warning: arch/arm64/kernel/vdso32/note.o:(.debug_line_str) is being placed in '.debug_line_str'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_loclists) is being placed in '.debug_loclists'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_abbrev) is being placed in '.debug_abbrev'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_info) is being placed in '.debug_info'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_rnglists) is being placed in '.debug_rnglists'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_str_offsets) is being placed in '.debug_str_offsets'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_str) is being placed in '.debug_str'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_addr) is being placed in '.debug_addr'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_frame) is being placed in '.debug_frame'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_line) is being placed in '.debug_line'
>   ld.lld: warning: arch/arm64/kernel/vdso32/vgettimeofday.o:(.debug_line_str) is being placed in '.debug_line_str'
>
> These are DWARF5 sections, as that is the implicit default version for

Most of these are DWARF v5, but some like .debug_info and .debug_line
are DWARF v2; this isn't specifically a DWARF v5 issue, more so just
an issue with CONFIG_DEBUG_INFO.  Not worth a v2 IMO though.  Thanks
for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> clang-14 and newer when just '-g' is used. All DWARF sections are
> handled by the DWARF_DEBUG macro from include/asm-generic/vmlinux.lds.h
> so use that macro here to fix the warnings regardless of DWARF version.
>
> Fixes: 9d4775b332e1 ("arm64: vdso32: enable orphan handling for VDSO")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/arm64/kernel/vdso32/vdso.lds.S | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S
> index c25bed8e6df1..8d95d7d35057 100644
> --- a/arch/arm64/kernel/vdso32/vdso.lds.S
> +++ b/arch/arm64/kernel/vdso32/vdso.lds.S
> @@ -57,6 +57,7 @@ SECTIONS
>         .rel.dyn        : { *(.rel*) }
>
>         .ARM.exidx : { *(.ARM.exidx*) }
> +       DWARF_DEBUG
>         ELF_DETAILS
>         .ARM.attributes 0 : { *(.ARM.attributes) }
>
> --
> 2.37.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO
  2022-06-30 15:31 [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Nathan Chancellor
  2022-06-30 15:31 ` [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS Nathan Chancellor
  2022-06-30 15:31 ` [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG Nathan Chancellor
@ 2022-07-01 15:41 ` Will Deacon
  2 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2022-07-01 15:41 UTC (permalink / raw)
  To: Nathan Chancellor, Catalin Marinas
  Cc: kernel-team, Will Deacon, linux-kernel, Joey Gouly,
	Nick Desaulniers, Vincenzo Frascino, patches, linux-arm-kernel,
	llvm

On Thu, 30 Jun 2022 08:31:19 -0700, Nathan Chancellor wrote:
> This small series fixes two issues I noticed with the orphan section
> warnings in the 32-bit vDSO. See the individual commits for the boring
> details.
> 
> They are based on for-next/vdso. I compiled with LLVM 11, LLVM 15, and
> GCC 12.1.0 + binutils 2.38 with no additional warnings/errors.
> 
> [...]

Applied to arm64 (for-next/vdso), thanks!

[1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS
      https://git.kernel.org/arm64/c/859716b4131f
[2/2] arm64: vdso32: Add DWARF_DEBUG
      https://git.kernel.org/arm64/c/9e07352ef779

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

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

end of thread, other threads:[~2022-07-01 15:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 15:31 [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Nathan Chancellor
2022-06-30 15:31 ` [PATCH 1/2] arm64: vdso32: Shuffle .ARM.exidx section above ELF_DETAILS Nathan Chancellor
2022-06-30 15:35   ` Nathan Chancellor
2022-06-30 15:31 ` [PATCH 2/2] arm64: vdso32: Add DWARF_DEBUG Nathan Chancellor
2022-06-30 21:08   ` Nick Desaulniers
2022-07-01 15:41 ` [PATCH 0/2] arm64: vdso32: Small fixes for ld.lld 11 and CONFIG_DEBUG_INFO Will Deacon

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).