mirror of
https://github.com/ziglang/zig.git
synced 2025-12-12 09:13:11 +00:00
Instead, we now have a looser helper called `checkContains(...)` that will match on any occurrence similarly to `std.mem.indexOf()`. While at it, I have cleaned up other combinators to make the entire API more consistent, and so: * `checkStart(phrase)` is now `checkStart()` followed by `checkExact(phrase)` * `checkNext(phrase)` if matching exactly is now `checkExact(phrase)` * `checkNext(phrase)` if matching loosely is now `checkContains(phrase)` * `checkNext(phrase)` if matching exactly with var extractors is now `checkExtract(phrase)` Finally, `ElfDumper` is now dumping contents of `.symtab` and `.dynsym` symbol tables. I have also removed dumping of symtabs as optional - they are now always dumped which cleaned up the implementation even more.
49 lines
1.8 KiB
Zig
49 lines
1.8 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const test_step = b.step("test", "Test");
|
|
b.default_step = test_step;
|
|
|
|
if (@import("builtin").os.tag == .windows) {
|
|
// TODO: Fix open handle in wasm-linker refraining rename from working on Windows.
|
|
return;
|
|
}
|
|
|
|
const lib = b.addSharedLibrary(.{
|
|
.name = "lib",
|
|
.root_source_file = .{ .path = "lib.zig" },
|
|
.optimize = .ReleaseSafe, // to make the output deterministic in address positions
|
|
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
|
|
});
|
|
lib.use_lld = false;
|
|
lib.export_symbol_names = &.{ "foo", "bar" };
|
|
lib.global_base = 0; // put data section at address 0 to make data symbols easier to parse
|
|
|
|
const check_lib = lib.checkObject();
|
|
|
|
check_lib.checkStart();
|
|
check_lib.checkExact("Section global");
|
|
check_lib.checkExact("entries 3");
|
|
check_lib.checkExact("type i32"); // stack pointer so skip other fields
|
|
check_lib.checkExact("type i32");
|
|
check_lib.checkExact("mutable false");
|
|
check_lib.checkExtract("i32.const {foo_address}");
|
|
check_lib.checkExact("type i32");
|
|
check_lib.checkExact("mutable false");
|
|
check_lib.checkExtract("i32.const {bar_address}");
|
|
check_lib.checkComputeCompare("foo_address", .{ .op = .eq, .value = .{ .literal = 4 } });
|
|
check_lib.checkComputeCompare("bar_address", .{ .op = .eq, .value = .{ .literal = 0 } });
|
|
|
|
check_lib.checkStart();
|
|
check_lib.checkExact("Section export");
|
|
check_lib.checkExact("entries 3");
|
|
check_lib.checkExact("name foo");
|
|
check_lib.checkExact("kind global");
|
|
check_lib.checkExact("index 1");
|
|
check_lib.checkExact("name bar");
|
|
check_lib.checkExact("kind global");
|
|
check_lib.checkExact("index 2");
|
|
|
|
test_step.dependOn(&check_lib.step);
|
|
}
|