[lld] [lld] Add target support for SystemZ (s390x) (PR #75643)

Tulio Magno Quites Machado Filho via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 07:11:19 PST 2024


tuliom wrote:

> I suspect the reason lld doesn't do that is because the section may not be writable, and so it thinks it cannot put dynamic relocations there. Does `-z notext` help?

@uweigand You're right. It does help! Thanks!

This is what I did:

```
diff --git a/Makefile b/Makefile
index a171eafce2a3..f6b8d50bb9e1 100644
--- a/Makefile
+++ b/Makefile
@@ -1031,7 +1031,7 @@ KBUILD_RUSTFLAGS += $(KRUSTFLAGS)
 KBUILD_LDFLAGS_MODULE += --build-id=sha1
 LDFLAGS_vmlinux += --build-id=sha1
 
-KBUILD_LDFLAGS += -z noexecstack
+KBUILD_LDFLAGS += -z noexecstack -z notext
 ifeq ($(CONFIG_LD_IS_BFD),y)
 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
 endif
```

After applying this change, I hit the same issue reported in my previous comment:

```
$ make -kj"$(nproc)" V=1 LD=/usr/bin/ld.lld lld.config bzImage
...
# GZIP    arch/s390/boot/vmlinux.bin.gz
  cat arch/s390/boot/vmlinux.bin | gzip -n -f -9 > arch/s390/boot/vmlinux.bin.gz
ld.lld: error: section .ipldata virtual address range overlaps with .head.text
>>> .ipldata range is [0x38, 0x237]
>>> .head.text range is [0x200, 0x102CF]

ld.lld: error: section .head.text virtual address range overlaps with .discard.addressable
>>> .head.text range is [0x200, 0x102CF]
>>> .discard.addressable range is [0x238, 0x307]

ld.lld: error: section .init.text virtual address range overlaps with .parmarea
>>> .init.text range is [0x102D0, 0x106CF]
>>> .parmarea range is [0x10400, 0x1147F]

ld.lld: error: section .ipldata load address range overlaps with .head.text
>>> .ipldata range is [0x38, 0x237]
>>> .head.text range is [0x200, 0x102CF]

ld.lld: error: section .head.text load address range overlaps with .discard.addressable
>>> .head.text range is [0x200, 0x102CF]
>>> .discard.addressable range is [0x238, 0x307]

ld.lld: error: section .init.text load address range overlaps with .parmarea
>>> .init.text range is [0x102D0, 0x106CF]
>>> .parmarea range is [0x10400, 0x1147F]
make[3]: *** [arch/s390/boot/Makefile:82: arch/s390/boot/vmlinux.syms] Error 1
# OBJCOPY arch/s390/boot/piggy.o
  objcopy -O binary -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed arch/s390/boot/vmlinux.bin.gz arch/s390/boot/piggy.o
make[3]: Target 'arch/s390/boot/bzImage' not remade because of errors.
make[2]: *** [arch/s390/Makefile:135: bzImage] Error 2
```

https://github.com/llvm/llvm-project/pull/75643


More information about the llvm-commits mailing list