From 43878f51d94a6c6297053fff37426fa556b1ef9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 16 Oct 2024 05:43:17 +0200 Subject: [PATCH] glibc: Emit _IO_stdin_used reference in .rodata. This fixes an X86_64_32 relocation linker error when targeting gnux32. --- src/glibc.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glibc.zig b/src/glibc.zig index a7736a9827..fff050b311 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -1015,7 +1015,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi } } - try stubs_asm.appendSlice(".data\n"); + try stubs_asm.appendSlice(".rodata\n"); // For some targets, the real `libc.so.6` will contain a weak reference to `_IO_stdin_used`, // making the linker put the symbol in the dynamic symbol table. We likewise need to emit a @@ -1046,6 +1046,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi }); } + try stubs_asm.appendSlice(".data\n"); + const obj_inclusions_len = try inc_reader.readInt(u16, .little); sym_i = 0;