All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] arm64: Link with -z notext
@ 2021-08-19 22:30 Ricardo Koller
  2021-08-31 10:31 ` Andrew Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Koller @ 2021-08-19 22:30 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, drjones
  Cc: oupton, jacobhxu, jingzhangos, pshier, rananta, reijiw, Ricardo Koller

Building the tests on arm64 fails when using LLD (the LLVM linker):

  ld.lld: error: can't create dynamic relocation R_AARCH64_ABS64 against
  local symbol in readonly segment; recompile object files with -fPIC or
  pass '-Wl,-z,notext' to allow text relocations in the output
  >>> defined in lib/libcflat.a(processor.o)
  >>> referenced by processor.c
  >>>               processor.o:(vector_names) in archive lib/libcflat.a

The reason is that LLD defaults to errors for text relocations. The GNU
LD defaults to let it go. In fact, the same error can be reproduced when
using GNU LD with the '-z text' arg (to error on text relocations):

  aarch64-linux-gnu-ld: read-only segment has dynamic relocations

Fix this link error by adding `-z notext` into the arm64 linker flags.

Signed-off-by: Ricardo Koller <ricarkol@google.com>
---
 arm/Makefile.arm64 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index dbc7524..e8a38d7 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -7,6 +7,7 @@ bits = 64
 ldarch = elf64-littleaarch64
 
 arch_LDFLAGS = -pie -n
+arch_LDFLAGS += -z notext
 CFLAGS += -mstrict-align
 
 mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "")
-- 
2.33.0.rc2.250.ged5fa647cd-goog


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

* Re: [kvm-unit-tests PATCH] arm64: Link with -z notext
  2021-08-19 22:30 [kvm-unit-tests PATCH] arm64: Link with -z notext Ricardo Koller
@ 2021-08-31 10:31 ` Andrew Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Jones @ 2021-08-31 10:31 UTC (permalink / raw)
  To: Ricardo Koller
  Cc: kvm, Paolo Bonzini, oupton, jacobhxu, jingzhangos, pshier,
	rananta, reijiw

On Thu, Aug 19, 2021 at 03:30:47PM -0700, Ricardo Koller wrote:
> Building the tests on arm64 fails when using LLD (the LLVM linker):
> 
>   ld.lld: error: can't create dynamic relocation R_AARCH64_ABS64 against
>   local symbol in readonly segment; recompile object files with -fPIC or
>   pass '-Wl,-z,notext' to allow text relocations in the output
>   >>> defined in lib/libcflat.a(processor.o)
>   >>> referenced by processor.c
>   >>>               processor.o:(vector_names) in archive lib/libcflat.a
> 
> The reason is that LLD defaults to errors for text relocations. The GNU
> LD defaults to let it go. In fact, the same error can be reproduced when
> using GNU LD with the '-z text' arg (to error on text relocations):
> 
>   aarch64-linux-gnu-ld: read-only segment has dynamic relocations
> 
> Fix this link error by adding `-z notext` into the arm64 linker flags.
> 
> Signed-off-by: Ricardo Koller <ricarkol@google.com>
> ---
>  arm/Makefile.arm64 | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
> index dbc7524..e8a38d7 100644
> --- a/arm/Makefile.arm64
> +++ b/arm/Makefile.arm64
> @@ -7,6 +7,7 @@ bits = 64
>  ldarch = elf64-littleaarch64
>  
>  arch_LDFLAGS = -pie -n
> +arch_LDFLAGS += -z notext
>  CFLAGS += -mstrict-align
>  
>  mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "")
> -- 
> 2.33.0.rc2.250.ged5fa647cd-goog
>

Applied to arm/queue and merged to master.

Thanks,
drew 


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

end of thread, other threads:[~2021-08-31 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 22:30 [kvm-unit-tests PATCH] arm64: Link with -z notext Ricardo Koller
2021-08-31 10:31 ` Andrew Jones

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.