diff mbox series

powerpc/vmlinux.lds: Add .text.asan/tsan sections

Message ID 20230222060037.2897169-1-mpe@ellerman.id.au (mailing list archive)
State Accepted
Commit acd35dbab871d61021284ff06daccdc0ebb51e61
Headers show
Series powerpc/vmlinux.lds: Add .text.asan/tsan sections | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.

Commit Message

Michael Ellerman Feb. 22, 2023, 6 a.m. UTC
When KASAN/KCSAN are enabled clang generates .text.asan/tsan sections.
Because they are not mentioned in the linker script warnings are
generated, and when orphan handling is set to error that becomes a build
error, eg:

  ld.lld: error: vmlinux.a(init/main.o):(.text.tsan.module_ctor) is
  being placed in '.text.tsan.module_ctor' ld.lld: error:
  vmlinux.a(init/version.o):(.text.tsan.module_ctor) is being placed in
  '.text.tsan.module_ctor'

Fix it by adding the sections to our linker script, similar to the
generic change made in 848378812e40 ("vmlinux.lds.h: Handle clang's
module.{c,d}tor sections").

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/vmlinux.lds.S | 1 +
 1 file changed, 1 insertion(+)

Comments

Nathan Chancellor Feb. 22, 2023, 5:08 p.m. UTC | #1
On Wed, Feb 22, 2023 at 05:00:37PM +1100, Michael Ellerman wrote:
> When KASAN/KCSAN are enabled clang generates .text.asan/tsan sections.
> Because they are not mentioned in the linker script warnings are
> generated, and when orphan handling is set to error that becomes a build
> error, eg:
> 
>   ld.lld: error: vmlinux.a(init/main.o):(.text.tsan.module_ctor) is
>   being placed in '.text.tsan.module_ctor' ld.lld: error:
>   vmlinux.a(init/version.o):(.text.tsan.module_ctor) is being placed in
>   '.text.tsan.module_ctor'
> 
> Fix it by adding the sections to our linker script, similar to the
> generic change made in 848378812e40 ("vmlinux.lds.h: Handle clang's
> module.{c,d}tor sections").
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Indeed, I had not thought about architectures not using the TEXT_TEXT
macro.

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

> ---
>  arch/powerpc/kernel/vmlinux.lds.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index 958e77a24f85..7a2209767adf 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -125,6 +125,7 @@ SECTIONS
>  		 * included with the main text sections, so put it by itself.
>  		 */
>  		*(.sfpr);
> +		*(.text.asan.* .text.tsan.*)
>  		MEM_KEEP(init.text)
>  		MEM_KEEP(exit.text)
>  	} :text
> -- 
> 2.39.1
>
Michael Ellerman Feb. 23, 2023, 4:43 a.m. UTC | #2
Nathan Chancellor <nathan@kernel.org> writes:
> On Wed, Feb 22, 2023 at 05:00:37PM +1100, Michael Ellerman wrote:
>> When KASAN/KCSAN are enabled clang generates .text.asan/tsan sections.
>> Because they are not mentioned in the linker script warnings are
>> generated, and when orphan handling is set to error that becomes a build
>> error, eg:
>> 
>>   ld.lld: error: vmlinux.a(init/main.o):(.text.tsan.module_ctor) is
>>   being placed in '.text.tsan.module_ctor' ld.lld: error:
>>   vmlinux.a(init/version.o):(.text.tsan.module_ctor) is being placed in
>>   '.text.tsan.module_ctor'
>> 
>> Fix it by adding the sections to our linker script, similar to the
>> generic change made in 848378812e40 ("vmlinux.lds.h: Handle clang's
>> module.{c,d}tor sections").
>> 
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> Indeed, I had not thought about architectures not using the TEXT_TEXT
> macro.

I think it's just us. I have a plan to fix that but it's a bit involved.

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

Thanks.

cheers
Michael Ellerman March 4, 2023, 10:36 a.m. UTC | #3
On Wed, 22 Feb 2023 17:00:37 +1100, Michael Ellerman wrote:
> When KASAN/KCSAN are enabled clang generates .text.asan/tsan sections.
> Because they are not mentioned in the linker script warnings are
> generated, and when orphan handling is set to error that becomes a build
> error, eg:
> 
>   ld.lld: error: vmlinux.a(init/main.o):(.text.tsan.module_ctor) is
>   being placed in '.text.tsan.module_ctor' ld.lld: error:
>   vmlinux.a(init/version.o):(.text.tsan.module_ctor) is being placed in
>   '.text.tsan.module_ctor'
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/vmlinux.lds: Add .text.asan/tsan sections
      https://git.kernel.org/powerpc/c/acd35dbab871d61021284ff06daccdc0ebb51e61

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 958e77a24f85..7a2209767adf 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -125,6 +125,7 @@  SECTIONS
 		 * included with the main text sections, so put it by itself.
 		 */
 		*(.sfpr);
+		*(.text.asan.* .text.tsan.*)
 		MEM_KEEP(init.text)
 		MEM_KEEP(exit.text)
 	} :text