diff --git a/test/cases/pic_freestanding.zig b/test/cases/pic_freestanding.zig new file mode 100644 index 0000000000..86e37662e2 --- /dev/null +++ b/test/cases/pic_freestanding.zig @@ -0,0 +1,14 @@ +const builtin = @import("builtin"); +const std = @import("std"); + +fn _start() callconv(.naked) void {} + +comptime { + @export(&_start, .{ .name = if (builtin.cpu.arch.isMIPS()) "__start" else "_start" }); +} + +// compile +// backend=stage2,llvm +// target=arm-freestanding,armeb-freestanding,thumb-freestanding,thumbeb-freestanding,aarch64-freestanding,aarch64_be-freestanding,loongarch64-freestanding,mips-freestanding,mipsel-freestanding,mips64-freestanding,mips64el-freestanding,powerpc-freestanding,powerpcle-freestanding,powerpc64-freestanding,powerpc64le-freestanding,riscv32-freestanding,riscv64-freestanding,s390x-freestanding,x86-freestanding,x86_64-freestanding +// pic=true +// output_mode=Exe diff --git a/test/cases/pic_linux.zig b/test/cases/pic_linux.zig new file mode 100644 index 0000000000..a699db95a3 --- /dev/null +++ b/test/cases/pic_linux.zig @@ -0,0 +1,14 @@ +const std = @import("std"); + +// Eventually, this test should be made to work without libc by providing our +// own `__tls_get_addr` implementation. powerpcle-linux should be added to the +// target list here when that happens. +// +// https://github.com/ziglang/zig/issues/20625 +pub fn main() void {} + +// run +// backend=stage2,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,powerpc64-linux,powerpc64le-linux,riscv32-linux,riscv64-linux,s390x-linux,x86-linux,x86_64-linux +// pic=true +// link_libc=true diff --git a/test/cases/pie_freestanding.zig b/test/cases/pie_freestanding.zig new file mode 100644 index 0000000000..9a86ddbc42 --- /dev/null +++ b/test/cases/pie_freestanding.zig @@ -0,0 +1,16 @@ +const builtin = @import("builtin"); +const std = @import("std"); + +// The self-hosted backends currently output a bunch of bad relocations for PIE, +// so this test is LLVM only for now. +fn _start() callconv(.naked) void {} + +comptime { + @export(&_start, .{ .name = if (builtin.cpu.arch.isMIPS()) "__start" else "_start" }); +} + +// compile +// backend=llvm +// target=arm-freestanding,armeb-freestanding,thumb-freestanding,thumbeb-freestanding,aarch64-freestanding,aarch64_be-freestanding,loongarch64-freestanding,mips-freestanding,mipsel-freestanding,mips64-freestanding,mips64el-freestanding,powerpc-freestanding,powerpcle-freestanding,powerpc64-freestanding,powerpc64le-freestanding,riscv32-freestanding,riscv64-freestanding,s390x-freestanding,x86-freestanding,x86_64-freestanding +// pie=true +// output_mode=Exe diff --git a/test/cases/pie_linux.zig b/test/cases/pie_linux.zig new file mode 100644 index 0000000000..293a172e9c --- /dev/null +++ b/test/cases/pie_linux.zig @@ -0,0 +1,10 @@ +const std = @import("std"); + +// The self-hosted backends can't handle `.hidden _DYNAMIC` and `.weak _DYNAMIC` +// directives in inline assembly yet, so this test is LLVM only for now. +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,s390x-linux,x86-linux,x86_64-linux +// pie=true