linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts
@ 2025-02-04 17:48 Nathan Chancellor
  2025-02-06 13:05 ` Will Deacon
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2025-02-04 17:48 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: linux-arm-kernel, linux-kernel, llvm, stable, Nathan Chancellor

A recent LLVM commit [1] started generating an .ARM.attributes section
similar to the one that exists for 32-bit, which results in orphan
section warnings (or errors if CONFIG_WERROR is enabled) from the linker
because it is not handled in the arm64 linker scripts.

  ld.lld: error: arch/arm64/kernel/vdso/vgettimeofday.o:(.ARM.attributes) is being placed in '.ARM.attributes'
  ld.lld: error: arch/arm64/kernel/vdso/vgetrandom.o:(.ARM.attributes) is being placed in '.ARM.attributes'

  ld.lld: error: vmlinux.a(lib/vsprintf.o):(.ARM.attributes) is being placed in '.ARM.attributes'
  ld.lld: error: vmlinux.a(lib/win_minmax.o):(.ARM.attributes) is being placed in '.ARM.attributes'
  ld.lld: error: vmlinux.a(lib/xarray.o):(.ARM.attributes) is being placed in '.ARM.attributes'

Discard the new sections in the necessary linker scripts to resolve the
warnings, as the kernel and vDSO do not need to retain it, similar to
the .note.gnu.property section.

Cc: stable@vger.kernel.org
Fixes: b3e5d80d0c48 ("arm64/build: Warn on orphan section placement")
Link: https://github.com/llvm/llvm-project/commit/ee99c4d4845db66c4daa2373352133f4b237c942 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Changes in v2:
- Discard the section instead of adding it to the final artifacts to
  mirror the .note.gnu.property section handling (Will).
- Link to v1: https://lore.kernel.org/r/20250124-arm64-handle-arm-attributes-in-linker-script-v1-1-74135b6cf349@kernel.org
---
 arch/arm64/kernel/vdso/vdso.lds.S | 1 +
 arch/arm64/kernel/vmlinux.lds.S   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
index 4ec32e86a8da..8095fef66209 100644
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ b/arch/arm64/kernel/vdso/vdso.lds.S
@@ -80,6 +80,7 @@ SECTIONS
 		*(.data .data.* .gnu.linkonce.d.* .sdata*)
 		*(.bss .sbss .dynbss .dynsbss)
 		*(.eh_frame .eh_frame_hdr)
+		*(.ARM.attributes)
 	}
 }
 
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index f84c71f04d9e..e73326bd3ff7 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -162,6 +162,7 @@ SECTIONS
 	/DISCARD/ : {
 		*(.interp .dynamic)
 		*(.dynsym .dynstr .hash .gnu.hash)
+		*(.ARM.attributes)
 	}
 
 	. = KIMAGE_VADDR;

---
base-commit: 1dd3393696efba1598aa7692939bba99d0cffae3
change-id: 20250123-arm64-handle-arm-attributes-in-linker-script-82aee25313ac

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>



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

* Re: [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts
  2025-02-04 17:48 [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts Nathan Chancellor
@ 2025-02-06 13:05 ` Will Deacon
  2025-02-06 13:57   ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2025-02-06 13:05 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, llvm, stable

Hi Nathan,

On Tue, Feb 04, 2025 at 10:48:55AM -0700, Nathan Chancellor wrote:
> A recent LLVM commit [1] started generating an .ARM.attributes section
> similar to the one that exists for 32-bit, which results in orphan
> section warnings (or errors if CONFIG_WERROR is enabled) from the linker
> because it is not handled in the arm64 linker scripts.
> 
>   ld.lld: error: arch/arm64/kernel/vdso/vgettimeofday.o:(.ARM.attributes) is being placed in '.ARM.attributes'
>   ld.lld: error: arch/arm64/kernel/vdso/vgetrandom.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> 
>   ld.lld: error: vmlinux.a(lib/vsprintf.o):(.ARM.attributes) is being placed in '.ARM.attributes'
>   ld.lld: error: vmlinux.a(lib/win_minmax.o):(.ARM.attributes) is being placed in '.ARM.attributes'
>   ld.lld: error: vmlinux.a(lib/xarray.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> 
> Discard the new sections in the necessary linker scripts to resolve the
> warnings, as the kernel and vDSO do not need to retain it, similar to
> the .note.gnu.property section.
> 
> Cc: stable@vger.kernel.org
> Fixes: b3e5d80d0c48 ("arm64/build: Warn on orphan section placement")
> Link: https://github.com/llvm/llvm-project/commit/ee99c4d4845db66c4daa2373352133f4b237c942 [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Changes in v2:
> - Discard the section instead of adding it to the final artifacts to
>   mirror the .note.gnu.property section handling (Will).

Thanks for the v2. Just a minor nit:

> - Link to v1: https://lore.kernel.org/r/20250124-arm64-handle-arm-attributes-in-linker-script-v1-1-74135b6cf349@kernel.org
> ---
>  arch/arm64/kernel/vdso/vdso.lds.S | 1 +
>  arch/arm64/kernel/vmlinux.lds.S   | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
> index 4ec32e86a8da..8095fef66209 100644
> --- a/arch/arm64/kernel/vdso/vdso.lds.S
> +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> @@ -80,6 +80,7 @@ SECTIONS
>  		*(.data .data.* .gnu.linkonce.d.* .sdata*)
>  		*(.bss .sbss .dynbss .dynsbss)
>  		*(.eh_frame .eh_frame_hdr)
> +		*(.ARM.attributes)
>  	}

Can we chuck this in the earlier /DISCARD/ section along with
.note.gnu.property? i.e.


diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
index 4ec32e86a8da..47ad6944f9f0 100644
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ b/arch/arm64/kernel/vdso/vdso.lds.S
@@ -41,6 +41,7 @@ SECTIONS
         */
        /DISCARD/       : {
                *(.note.GNU-stack .note.gnu.property)
+               *(.ARM.attributes)
        }
        .note           : { *(.note.*) }                :text   :note


Will


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

* Re: [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts
  2025-02-06 13:05 ` Will Deacon
@ 2025-02-06 13:57   ` Nathan Chancellor
  2025-02-06 15:22     ` Will Deacon
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2025-02-06 13:57 UTC (permalink / raw)
  To: Will Deacon; +Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, llvm, stable

Hi Will,

On Thu, Feb 06, 2025 at 01:05:26PM +0000, Will Deacon wrote:
> On Tue, Feb 04, 2025 at 10:48:55AM -0700, Nathan Chancellor wrote:
> > A recent LLVM commit [1] started generating an .ARM.attributes section
> > similar to the one that exists for 32-bit, which results in orphan
> > section warnings (or errors if CONFIG_WERROR is enabled) from the linker
> > because it is not handled in the arm64 linker scripts.
> > 
> >   ld.lld: error: arch/arm64/kernel/vdso/vgettimeofday.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> >   ld.lld: error: arch/arm64/kernel/vdso/vgetrandom.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> > 
> >   ld.lld: error: vmlinux.a(lib/vsprintf.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> >   ld.lld: error: vmlinux.a(lib/win_minmax.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> >   ld.lld: error: vmlinux.a(lib/xarray.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > 
> > Discard the new sections in the necessary linker scripts to resolve the
> > warnings, as the kernel and vDSO do not need to retain it, similar to
> > the .note.gnu.property section.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: b3e5d80d0c48 ("arm64/build: Warn on orphan section placement")
> > Link: https://github.com/llvm/llvm-project/commit/ee99c4d4845db66c4daa2373352133f4b237c942 [1]
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > Changes in v2:
> > - Discard the section instead of adding it to the final artifacts to
> >   mirror the .note.gnu.property section handling (Will).
> 
> Thanks for the v2. Just a minor nit:
> 
> > - Link to v1: https://lore.kernel.org/r/20250124-arm64-handle-arm-attributes-in-linker-script-v1-1-74135b6cf349@kernel.org
> > ---
> >  arch/arm64/kernel/vdso/vdso.lds.S | 1 +
> >  arch/arm64/kernel/vmlinux.lds.S   | 1 +
> >  2 files changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
> > index 4ec32e86a8da..8095fef66209 100644
> > --- a/arch/arm64/kernel/vdso/vdso.lds.S
> > +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> > @@ -80,6 +80,7 @@ SECTIONS
> >  		*(.data .data.* .gnu.linkonce.d.* .sdata*)
> >  		*(.bss .sbss .dynbss .dynsbss)
> >  		*(.eh_frame .eh_frame_hdr)
> > +		*(.ARM.attributes)
> >  	}
> 
> Can we chuck this in the earlier /DISCARD/ section along with
> .note.gnu.property? i.e.

Sure, I don't see why not. Do you want the comment above it updated to
mention this section or should I leave it as is?

> diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
> index 4ec32e86a8da..47ad6944f9f0 100644
> --- a/arch/arm64/kernel/vdso/vdso.lds.S
> +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> @@ -41,6 +41,7 @@ SECTIONS
>          */
>         /DISCARD/       : {
>                 *(.note.GNU-stack .note.gnu.property)
> +               *(.ARM.attributes)
>         }
>         .note           : { *(.note.*) }                :text   :note
> 
> 
> Will


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

* Re: [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts
  2025-02-06 13:57   ` Nathan Chancellor
@ 2025-02-06 15:22     ` Will Deacon
  2025-02-06 16:54       ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2025-02-06 15:22 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, llvm, stable

On Thu, Feb 06, 2025 at 06:57:15AM -0700, Nathan Chancellor wrote:
> Hi Will,
> 
> On Thu, Feb 06, 2025 at 01:05:26PM +0000, Will Deacon wrote:
> > On Tue, Feb 04, 2025 at 10:48:55AM -0700, Nathan Chancellor wrote:
> > > A recent LLVM commit [1] started generating an .ARM.attributes section
> > > similar to the one that exists for 32-bit, which results in orphan
> > > section warnings (or errors if CONFIG_WERROR is enabled) from the linker
> > > because it is not handled in the arm64 linker scripts.
> > > 
> > >   ld.lld: error: arch/arm64/kernel/vdso/vgettimeofday.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> > >   ld.lld: error: arch/arm64/kernel/vdso/vgetrandom.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> > > 
> > >   ld.lld: error: vmlinux.a(lib/vsprintf.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > >   ld.lld: error: vmlinux.a(lib/win_minmax.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > >   ld.lld: error: vmlinux.a(lib/xarray.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > > 
> > > Discard the new sections in the necessary linker scripts to resolve the
> > > warnings, as the kernel and vDSO do not need to retain it, similar to
> > > the .note.gnu.property section.
> > > 
> > > Cc: stable@vger.kernel.org
> > > Fixes: b3e5d80d0c48 ("arm64/build: Warn on orphan section placement")
> > > Link: https://github.com/llvm/llvm-project/commit/ee99c4d4845db66c4daa2373352133f4b237c942 [1]
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > ---
> > > Changes in v2:
> > > - Discard the section instead of adding it to the final artifacts to
> > >   mirror the .note.gnu.property section handling (Will).
> > 
> > Thanks for the v2. Just a minor nit:
> > 
> > > - Link to v1: https://lore.kernel.org/r/20250124-arm64-handle-arm-attributes-in-linker-script-v1-1-74135b6cf349@kernel.org
> > > ---
> > >  arch/arm64/kernel/vdso/vdso.lds.S | 1 +
> > >  arch/arm64/kernel/vmlinux.lds.S   | 1 +
> > >  2 files changed, 2 insertions(+)
> > > 
> > > diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
> > > index 4ec32e86a8da..8095fef66209 100644
> > > --- a/arch/arm64/kernel/vdso/vdso.lds.S
> > > +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> > > @@ -80,6 +80,7 @@ SECTIONS
> > >  		*(.data .data.* .gnu.linkonce.d.* .sdata*)
> > >  		*(.bss .sbss .dynbss .dynsbss)
> > >  		*(.eh_frame .eh_frame_hdr)
> > > +		*(.ARM.attributes)
> > >  	}
> > 
> > Can we chuck this in the earlier /DISCARD/ section along with
> > .note.gnu.property? i.e.
> 
> Sure, I don't see why not. Do you want the comment above it updated to
> mention this section or should I leave it as is?

If you can think of something useful to add to the comment, don't let me
stop you!

Will


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

* Re: [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts
  2025-02-06 15:22     ` Will Deacon
@ 2025-02-06 16:54       ` Nathan Chancellor
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2025-02-06 16:54 UTC (permalink / raw)
  To: Will Deacon; +Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, llvm, stable

On Thu, Feb 06, 2025 at 03:22:47PM +0000, Will Deacon wrote:
> On Thu, Feb 06, 2025 at 06:57:15AM -0700, Nathan Chancellor wrote:
> > Hi Will,
> > 
> > On Thu, Feb 06, 2025 at 01:05:26PM +0000, Will Deacon wrote:
> > > On Tue, Feb 04, 2025 at 10:48:55AM -0700, Nathan Chancellor wrote:
> > > > A recent LLVM commit [1] started generating an .ARM.attributes section
> > > > similar to the one that exists for 32-bit, which results in orphan
> > > > section warnings (or errors if CONFIG_WERROR is enabled) from the linker
> > > > because it is not handled in the arm64 linker scripts.
> > > > 
> > > >   ld.lld: error: arch/arm64/kernel/vdso/vgettimeofday.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> > > >   ld.lld: error: arch/arm64/kernel/vdso/vgetrandom.o:(.ARM.attributes) is being placed in '.ARM.attributes'
> > > > 
> > > >   ld.lld: error: vmlinux.a(lib/vsprintf.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > > >   ld.lld: error: vmlinux.a(lib/win_minmax.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > > >   ld.lld: error: vmlinux.a(lib/xarray.o):(.ARM.attributes) is being placed in '.ARM.attributes'
> > > > 
> > > > Discard the new sections in the necessary linker scripts to resolve the
> > > > warnings, as the kernel and vDSO do not need to retain it, similar to
> > > > the .note.gnu.property section.
> > > > 
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: b3e5d80d0c48 ("arm64/build: Warn on orphan section placement")
> > > > Link: https://github.com/llvm/llvm-project/commit/ee99c4d4845db66c4daa2373352133f4b237c942 [1]
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > > ---
> > > > Changes in v2:
> > > > - Discard the section instead of adding it to the final artifacts to
> > > >   mirror the .note.gnu.property section handling (Will).
> > > 
> > > Thanks for the v2. Just a minor nit:
> > > 
> > > > - Link to v1: https://lore.kernel.org/r/20250124-arm64-handle-arm-attributes-in-linker-script-v1-1-74135b6cf349@kernel.org
> > > > ---
> > > >  arch/arm64/kernel/vdso/vdso.lds.S | 1 +
> > > >  arch/arm64/kernel/vmlinux.lds.S   | 1 +
> > > >  2 files changed, 2 insertions(+)
> > > > 
> > > > diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
> > > > index 4ec32e86a8da..8095fef66209 100644
> > > > --- a/arch/arm64/kernel/vdso/vdso.lds.S
> > > > +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> > > > @@ -80,6 +80,7 @@ SECTIONS
> > > >  		*(.data .data.* .gnu.linkonce.d.* .sdata*)
> > > >  		*(.bss .sbss .dynbss .dynsbss)
> > > >  		*(.eh_frame .eh_frame_hdr)
> > > > +		*(.ARM.attributes)
> > > >  	}
> > > 
> > > Can we chuck this in the earlier /DISCARD/ section along with
> > > .note.gnu.property? i.e.
> > 
> > Sure, I don't see why not. Do you want the comment above it updated to
> > mention this section or should I leave it as is?
> 
> If you can think of something useful to add to the comment, don't let me
> stop you!

Eh, I could not come up with much so I will leave it as is. v3 incoming
shortly.

Cheers,
Nathan


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

end of thread, other threads:[~2025-02-06 16:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-04 17:48 [PATCH v2] arm64: Handle .ARM.attributes section in linker scripts Nathan Chancellor
2025-02-06 13:05 ` Will Deacon
2025-02-06 13:57   ` Nathan Chancellor
2025-02-06 15:22     ` Will Deacon
2025-02-06 16:54       ` Nathan Chancellor

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