mirror of
https://github.com/ziglang/zig.git
synced 2024-11-29 00:22:33 +00:00
fd6d5f1609
* Don't skip the TLS initialization (Fixes #9083) * Add a test case where a PIE program is built and run * Refactor the common initialization code in the Linux startup sequence.
16 lines
450 B
Zig
16 lines
450 B
Zig
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 = @intToPtr(*elf.Ehdr, 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);
|
|
}
|