From 341882fc1a655137c7a68cdf45c77d5d53c0e522 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:25:41 -0300 Subject: Load libraries from Zig 0.17.1's incremental linker `-fincremental` selects Zig's new ELF linker, and 0.17.1's writes DT_VERSYM without DT_VERDEF or DT_VERNEED when nothing is versioned: glibc then reads a null version table at the first relocation against an export, and dlopen faults. When a library has that shape, the host loads a copy of it in an anonymous memory file with DT_VERSYM dropped (nothing in it is versioned, so nothing is lost); the build's own file is never written, and every other library loads as before. The copy is 10 ms for the counter's 28 MB library. Fixed in Zig after 0.17.1 (6d27011edb): the check then never fires. The reload test's second build goes through the new linker. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 5f464ab..adefcf2 100644 --- a/build.zig +++ b/build.zig @@ -202,6 +202,9 @@ pub fn build(b: *Build) void { // field name, through the real dlopen path and the headless host. const v1 = sb.app(.{ .name = "counter", .root_source_file = b.path("test/counter_v1.zig") }).addLibrary(); const v2 = sb.app(.{ .name = "counter", .root_source_file = b.path("test/counter_v2.zig") }).addLibrary(); + // v2 through the linker `-fincremental` uses, whose 0.17.1 libraries + // glibc loads only after the host's fixup (`withoutVersym`). + v2.use_new_linker = true; // Command.shape on the native host: the parity cases, screenshotted // and checked pixel by pixel (tools/shapes_web.mjs compares the same // sketch in headless Chrome: `zig build test-web`). -- cgit v1.3