zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 7b92d5f4052be651e9bc5cd4ad78a69ccbee865d (tree)
parent 26825e95066c104585d248787c0e56ce4e8413e0
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Mon, 22 Sep 2025 18:36:47 +0200

std.pie: fix register constraint in getDynamicSymbol() for s390x (#25327)

If the compiler happens to pick `ret = r0`, then this will assemble to
`ag r0, 0` which is obviously not what we want. Using `a` instead of `r` will
ensure that we get an appropriate address register, i.e. `r1` through `r15`.

Re-enable pie_linux for s390x-linux which was disabled in
ed7ff0b693037078f451a7c6c1124611060f4892.
Diffstat:
Mlib/std/pie.zig | 2+-
Mtest/cases/pie_linux.zig | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/std/pie.zig b/lib/std/pie.zig @@ -177,7 +177,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { \\ jg 2f \\ 1: .quad _DYNAMIC - . \\ 2: - : [ret] "=r" (-> [*]const elf.Dyn), + : [ret] "=a" (-> [*]const elf.Dyn), ), // The compiler does not necessarily have any obligation to load the `l7` register (pointing // to the GOT), so do it ourselves just in case. diff --git a/test/cases/pie_linux.zig b/test/cases/pie_linux.zig @@ -6,5 +6,5 @@ pub fn main() void {} // run // backend=llvm -// target=arm-linux,armeb-linux,thumb-linux,thumbeb-linux,aarch64-linux,aarch64_be-linux,loongarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux,powerpc-linux,powerpcle-linux,powerpc64-linux,powerpc64le-linux,riscv32-linux,riscv64-linux,x86-linux,x86_64-linux +// target=arm-linux,armeb-linux,thumb-linux,thumbeb-linux,aarch64-linux,aarch64_be-linux,loongarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux,powerpc-linux,powerpcle-linux,powerpc64-linux,powerpc64le-linux,riscv32-linux,riscv64-linux,s390x-linux,x86-linux,x86_64-linux // pie=true