Skip to content

Commit 7b92d5f

Browse files
authored
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 ed7ff0b.
1 parent 26825e9 commit 7b92d5f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/std/pie.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
177177
\\ jg 2f
178178
\\ 1: .quad _DYNAMIC - .
179179
\\ 2:
180-
: [ret] "=r" (-> [*]const elf.Dyn),
180+
: [ret] "=a" (-> [*]const elf.Dyn),
181181
),
182182
// The compiler does not necessarily have any obligation to load the `l7` register (pointing
183183
// to the GOT), so do it ourselves just in case.

test/cases/pie_linux.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pub fn main() void {}
66

77
// run
88
// backend=llvm
9-
// 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
9+
// 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
1010
// pie=true

0 commit comments

Comments
 (0)