arm64: Link with -z notext
PATCH 1/1 arm64: Link with -z notext
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
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
defined in lib/libcflat.a(processor.o)
referenced byprocessor.c
processor.o:(vector_names) in archivelib/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.
--- arm/Makefile.arm64 | 1 + 1 file changed, 1 insertion(+)
arm/Makefile.arm64 +1 -0
@@ -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, "")
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
Andrew Jones
AppliedQuoted 37 lines · Ricardo Koller
Building the tests on arm64 fails when using LLD (the LLVM linker):
ld.lld: error: can't create dynamic relocation
R_AARCH64_ABS64against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the outputQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
defined in lib/libcflat.a(processor.o)
referenced byprocessor.c
processor.o:(vector_names) in archivelib/libcflat.aThe 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 notextinto the arm64 linker flags.Signed-off-by Ricardo Koller <[email protected]>--- arm/Makefile.arm64 | 1 + 1 file changed, 1 insertion(+)arm/Makefile.arm64 +1
-0@@ -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, "")Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
Applied to arm/queue and merged to master.
Thanks,
drew