All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
@ 2019-06-26  4:20 ` Nathan Chancellor
  0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2019-06-26  4:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Ard Biesheuvel
  Cc: linux-arm-kernel, linux-kernel, clang-built-linux,
	Nathan Chancellor, Fangrui Song, Peter Smith

After r363059 and r363928 in LLVM, a build using ld.lld as the linker
with CONFIG_RANDOMIZE_BASE enabled fails like so:

ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
__efistub_stext_offset; recompile with -fPIC

Fangrui and Peter figured out that ld.lld is incorrectly considering
__efistub_stext_offset as a relative symbol because of the order in
which symbols are evaluated. _text is treated as an absolute symbol
and stext is a relative symbol, making __efistub_stext_offset a
relative symbol.

Adding ABSOLUTE will force ld.lld to evalute this expression in the
right context and does not change ld.bfd's behavior. ld.lld will
need to be fixed but the developers do not see a quick or simple fix
without some research (see the linked issue for further explanation).
Add this simple workaround so that ld.lld can continue to link kernels.

Link: https://github.com/ClangBuiltLinux/linux/issues/561
Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
Debugged-by: Fangrui Song <maskray@google.com>
Debugged-by: Peter Smith <peter.smith@linaro.org>
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/arm64/kernel/image.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
index 04ca08086d35..9a2d2227907c 100644
--- a/arch/arm64/kernel/image.h
+++ b/arch/arm64/kernel/image.h
@@ -67,7 +67,7 @@
 
 #ifdef CONFIG_EFI
 
-__efistub_stext_offset = stext - _text;
+__efistub_stext_offset = ABSOLUTE(stext - _text);
 
 /*
  * The EFI stub has its own symbol namespace prefixed by __efistub_, to
-- 
2.22.0


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

* [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
@ 2019-06-26  4:20 ` Nathan Chancellor
  0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2019-06-26  4:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Ard Biesheuvel
  Cc: Fangrui Song, linux-kernel, clang-built-linux, Peter Smith,
	Nathan Chancellor, linux-arm-kernel

After r363059 and r363928 in LLVM, a build using ld.lld as the linker
with CONFIG_RANDOMIZE_BASE enabled fails like so:

ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
__efistub_stext_offset; recompile with -fPIC

Fangrui and Peter figured out that ld.lld is incorrectly considering
__efistub_stext_offset as a relative symbol because of the order in
which symbols are evaluated. _text is treated as an absolute symbol
and stext is a relative symbol, making __efistub_stext_offset a
relative symbol.

Adding ABSOLUTE will force ld.lld to evalute this expression in the
right context and does not change ld.bfd's behavior. ld.lld will
need to be fixed but the developers do not see a quick or simple fix
without some research (see the linked issue for further explanation).
Add this simple workaround so that ld.lld can continue to link kernels.

Link: https://github.com/ClangBuiltLinux/linux/issues/561
Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
Debugged-by: Fangrui Song <maskray@google.com>
Debugged-by: Peter Smith <peter.smith@linaro.org>
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/arm64/kernel/image.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
index 04ca08086d35..9a2d2227907c 100644
--- a/arch/arm64/kernel/image.h
+++ b/arch/arm64/kernel/image.h
@@ -67,7 +67,7 @@
 
 #ifdef CONFIG_EFI
 
-__efistub_stext_offset = stext - _text;
+__efistub_stext_offset = ABSOLUTE(stext - _text);
 
 /*
  * The EFI stub has its own symbol namespace prefixed by __efistub_, to
-- 
2.22.0


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

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
  2019-06-26  4:20 ` Nathan Chancellor
@ 2019-06-26  7:06   ` Ard Biesheuvel
  -1 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2019-06-26  7:06 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel,
	Linux Kernel Mailing List, clang-built-linux, Fangrui Song,
	Peter Smith

On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> with CONFIG_RANDOMIZE_BASE enabled fails like so:
>
> ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> __efistub_stext_offset; recompile with -fPIC
>
> Fangrui and Peter figured out that ld.lld is incorrectly considering
> __efistub_stext_offset as a relative symbol because of the order in
> which symbols are evaluated. _text is treated as an absolute symbol
> and stext is a relative symbol, making __efistub_stext_offset a
> relative symbol.
>
> Adding ABSOLUTE will force ld.lld to evalute this expression in the
> right context and does not change ld.bfd's behavior. ld.lld will
> need to be fixed but the developers do not see a quick or simple fix
> without some research (see the linked issue for further explanation).
> Add this simple workaround so that ld.lld can continue to link kernels.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/561
> Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> Debugged-by: Fangrui Song <maskray@google.com>
> Debugged-by: Peter Smith <peter.smith@linaro.org>
> Suggested-by: Fangrui Song <maskray@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  arch/arm64/kernel/image.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
> index 04ca08086d35..9a2d2227907c 100644
> --- a/arch/arm64/kernel/image.h
> +++ b/arch/arm64/kernel/image.h
> @@ -67,7 +67,7 @@
>
>  #ifdef CONFIG_EFI
>
> -__efistub_stext_offset = stext - _text;
> +__efistub_stext_offset = ABSOLUTE(stext - _text);
>
>  /*
>   * The EFI stub has its own symbol namespace prefixed by __efistub_, to
> --
> 2.22.0
>

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
@ 2019-06-26  7:06   ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2019-06-26  7:06 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Fangrui Song, Catalin Marinas, Linux Kernel Mailing List,
	clang-built-linux, Peter Smith, Will Deacon, linux-arm-kernel

On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> with CONFIG_RANDOMIZE_BASE enabled fails like so:
>
> ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> __efistub_stext_offset; recompile with -fPIC
>
> Fangrui and Peter figured out that ld.lld is incorrectly considering
> __efistub_stext_offset as a relative symbol because of the order in
> which symbols are evaluated. _text is treated as an absolute symbol
> and stext is a relative symbol, making __efistub_stext_offset a
> relative symbol.
>
> Adding ABSOLUTE will force ld.lld to evalute this expression in the
> right context and does not change ld.bfd's behavior. ld.lld will
> need to be fixed but the developers do not see a quick or simple fix
> without some research (see the linked issue for further explanation).
> Add this simple workaround so that ld.lld can continue to link kernels.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/561
> Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> Debugged-by: Fangrui Song <maskray@google.com>
> Debugged-by: Peter Smith <peter.smith@linaro.org>
> Suggested-by: Fangrui Song <maskray@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  arch/arm64/kernel/image.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
> index 04ca08086d35..9a2d2227907c 100644
> --- a/arch/arm64/kernel/image.h
> +++ b/arch/arm64/kernel/image.h
> @@ -67,7 +67,7 @@
>
>  #ifdef CONFIG_EFI
>
> -__efistub_stext_offset = stext - _text;
> +__efistub_stext_offset = ABSOLUTE(stext - _text);
>
>  /*
>   * The EFI stub has its own symbol namespace prefixed by __efistub_, to
> --
> 2.22.0
>

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

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
  2019-06-26  4:20 ` Nathan Chancellor
@ 2019-06-26  7:07   ` Ard Biesheuvel
  -1 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2019-06-26  7:07 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel,
	Linux Kernel Mailing List, clang-built-linux, Fangrui Song,
	Peter Smith

On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> with CONFIG_RANDOMIZE_BASE enabled fails like so:
>
> ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> __efistub_stext_offset; recompile with -fPIC
>
> Fangrui and Peter figured out that ld.lld is incorrectly considering
> __efistub_stext_offset as a relative symbol because of the order in
> which symbols are evaluated. _text is treated as an absolute symbol
> and stext is a relative symbol, making __efistub_stext_offset a
> relative symbol.
>
> Adding ABSOLUTE will force ld.lld to evalute this expression in the
> right context and does not change ld.bfd's behavior. ld.lld will
> need to be fixed but the developers do not see a quick or simple fix
> without some research (see the linked issue for further explanation).
> Add this simple workaround so that ld.lld can continue to link kernels.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/561
> Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> Debugged-by: Fangrui Song <maskray@google.com>
> Debugged-by: Peter Smith <peter.smith@linaro.org>
> Suggested-by: Fangrui Song <maskray@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  arch/arm64/kernel/image.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
> index 04ca08086d35..9a2d2227907c 100644
> --- a/arch/arm64/kernel/image.h
> +++ b/arch/arm64/kernel/image.h
> @@ -67,7 +67,7 @@
>
>  #ifdef CONFIG_EFI
>
> -__efistub_stext_offset = stext - _text;
> +__efistub_stext_offset = ABSOLUTE(stext - _text);
>
>  /*
>   * The EFI stub has its own symbol namespace prefixed by __efistub_, to
> --
> 2.22.0
>

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
@ 2019-06-26  7:07   ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2019-06-26  7:07 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Fangrui Song, Catalin Marinas, Linux Kernel Mailing List,
	clang-built-linux, Peter Smith, Will Deacon, linux-arm-kernel

On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> with CONFIG_RANDOMIZE_BASE enabled fails like so:
>
> ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> __efistub_stext_offset; recompile with -fPIC
>
> Fangrui and Peter figured out that ld.lld is incorrectly considering
> __efistub_stext_offset as a relative symbol because of the order in
> which symbols are evaluated. _text is treated as an absolute symbol
> and stext is a relative symbol, making __efistub_stext_offset a
> relative symbol.
>
> Adding ABSOLUTE will force ld.lld to evalute this expression in the
> right context and does not change ld.bfd's behavior. ld.lld will
> need to be fixed but the developers do not see a quick or simple fix
> without some research (see the linked issue for further explanation).
> Add this simple workaround so that ld.lld can continue to link kernels.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/561
> Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> Debugged-by: Fangrui Song <maskray@google.com>
> Debugged-by: Peter Smith <peter.smith@linaro.org>
> Suggested-by: Fangrui Song <maskray@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  arch/arm64/kernel/image.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
> index 04ca08086d35..9a2d2227907c 100644
> --- a/arch/arm64/kernel/image.h
> +++ b/arch/arm64/kernel/image.h
> @@ -67,7 +67,7 @@
>
>  #ifdef CONFIG_EFI
>
> -__efistub_stext_offset = stext - _text;
> +__efistub_stext_offset = ABSOLUTE(stext - _text);
>
>  /*
>   * The EFI stub has its own symbol namespace prefixed by __efistub_, to
> --
> 2.22.0
>

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

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
  2019-06-26  7:07   ` Ard Biesheuvel
@ 2019-06-26 10:32     ` Will Deacon
  -1 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2019-06-26 10:32 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Nathan Chancellor, Catalin Marinas, linux-arm-kernel,
	Linux Kernel Mailing List, clang-built-linux, Fangrui Song,
	Peter Smith

On Wed, Jun 26, 2019 at 09:07:00AM +0200, Ard Biesheuvel wrote:
> On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> > with CONFIG_RANDOMIZE_BASE enabled fails like so:
> >
> > ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> > __efistub_stext_offset; recompile with -fPIC
> >
> > Fangrui and Peter figured out that ld.lld is incorrectly considering
> > __efistub_stext_offset as a relative symbol because of the order in
> > which symbols are evaluated. _text is treated as an absolute symbol
> > and stext is a relative symbol, making __efistub_stext_offset a
> > relative symbol.
> >
> > Adding ABSOLUTE will force ld.lld to evalute this expression in the
> > right context and does not change ld.bfd's behavior. ld.lld will
> > need to be fixed but the developers do not see a quick or simple fix
> > without some research (see the linked issue for further explanation).
> > Add this simple workaround so that ld.lld can continue to link kernels.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/561
> > Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> > Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> > Debugged-by: Fangrui Song <maskray@google.com>
> > Debugged-by: Peter Smith <peter.smith@linaro.org>
> > Suggested-by: Fangrui Song <maskray@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> 
> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Thanks. I'll pick this up and add the link to the Clang issue as a comment
in the header.

Will

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

* Re: [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly
@ 2019-06-26 10:32     ` Will Deacon
  0 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2019-06-26 10:32 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Fangrui Song, Catalin Marinas, Linux Kernel Mailing List,
	clang-built-linux, Peter Smith, Nathan Chancellor,
	linux-arm-kernel

On Wed, Jun 26, 2019 at 09:07:00AM +0200, Ard Biesheuvel wrote:
> On Wed, 26 Jun 2019 at 06:20, Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > After r363059 and r363928 in LLVM, a build using ld.lld as the linker
> > with CONFIG_RANDOMIZE_BASE enabled fails like so:
> >
> > ld.lld: error: relocation R_AARCH64_ABS32 cannot be used against symbol
> > __efistub_stext_offset; recompile with -fPIC
> >
> > Fangrui and Peter figured out that ld.lld is incorrectly considering
> > __efistub_stext_offset as a relative symbol because of the order in
> > which symbols are evaluated. _text is treated as an absolute symbol
> > and stext is a relative symbol, making __efistub_stext_offset a
> > relative symbol.
> >
> > Adding ABSOLUTE will force ld.lld to evalute this expression in the
> > right context and does not change ld.bfd's behavior. ld.lld will
> > need to be fixed but the developers do not see a quick or simple fix
> > without some research (see the linked issue for further explanation).
> > Add this simple workaround so that ld.lld can continue to link kernels.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/561
> > Link: https://github.com/llvm/llvm-project/commit/025a815d75d2356f2944136269aa5874721ec236
> > Link: https://github.com/llvm/llvm-project/commit/249fde85832c33f8b06c6b4ac65d1c4b96d23b83
> > Debugged-by: Fangrui Song <maskray@google.com>
> > Debugged-by: Peter Smith <peter.smith@linaro.org>
> > Suggested-by: Fangrui Song <maskray@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> 
> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Thanks. I'll pick this up and add the link to the Clang issue as a comment
in the header.

Will

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

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

end of thread, other threads:[~2019-06-26 10:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26  4:20 [PATCH] arm64/efi: Mark __efistub_stext_offset as an absolute symbol explicitly Nathan Chancellor
2019-06-26  4:20 ` Nathan Chancellor
2019-06-26  7:06 ` Ard Biesheuvel
2019-06-26  7:06   ` Ard Biesheuvel
2019-06-26  7:07 ` Ard Biesheuvel
2019-06-26  7:07   ` Ard Biesheuvel
2019-06-26 10:32   ` Will Deacon
2019-06-26 10:32     ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.