aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/pie/main.zig
blob: edf6a3fcaae80606ea6959d0d40b0135e4b60297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const std = @import("std");
const elf = std.elf;

threadlocal var foo: u8 = 42;

test "Check ELF header" {
    // PIE executables are marked as ET_DYN, regular exes as ET_EXEC.
    const header = @as(*elf.Ehdr, @ptrFromInt(std.process.getBaseAddress()));
    try std.testing.expectEqual(elf.ET.DYN, header.e_type);
}

test "TLS is initialized" {
    // Ensure the TLS is initialized by the startup code.
    try std.testing.expectEqual(@as(u8, 42), foo);
}