sergio/takana
> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…
Etapa G: fuel-4 — buffer de cola para el VPS tras recuperar conexión
1From 5805151cffccc087942b9dd8d7ac10ca5f4f80a8 Mon Sep 17 00:00:00 2001
2From: lapla <me@lapla.dev>
3Date: Tue, 20 Jan 2026 18:47:13 +0900
4Subject: [PATCH] fix: Resolve weak undefined symbols to zero in read-only
5 sections (#1474)
6
7#1472
8
9When a weak undefined symbol is referenced from a read-only section via
10an absolute relocation, the resolved value should be 0, not the PLT
11entry address.
12---
13 libwild/src/elf_writer.rs | 6 ++++++
14 wild/tests/integration_tests.rs | 3 ++-
15 wild/tests/sources/undefined-weak-sym.c | 25 +++++++++++++++++++++++++
16 3 files changed, 33 insertions(+), 1 deletion(-)
17 create mode 100644 wild/tests/sources/undefined-weak-sym.c
18
19diff --git a/libwild/src/elf_writer.rs b/libwild/src/elf_writer.rs
20index 2923bc9e9..026636f0d 100644
21--- a/libwild/src/elf_writer.rs
22+++ b/libwild/src/elf_writer.rs
23@@ -2574,6 +2574,12 @@ fn write_absolute_relocation<A: Arch>(
24 &layout.merged_strings,
25 &layout.merged_string_start_addresses,
26 )
27+ } else if resolution.flags.is_dynamic()
28+ && resolution.flags.is_absolute()
29+ && !section_info.is_writable
30+ {
31+ // Weak undefined symbol referenced from a read-only section. Fill in as zero.
32+ Ok(0)
33 } else if resolution.flags.is_interposable() && section_info.is_writable {
34 table_writer.write_dynamic_symbol_relocation::<A>(
35 place,
36diff --git a/wild/tests/integration_tests.rs b/wild/tests/integration_tests.rs
37index bc4730412..9dd611ba7 100644
38--- a/wild/tests/integration_tests.rs
39+++ b/wild/tests/integration_tests.rs
40@@ -3320,7 +3320,8 @@ fn integration_test(
41 "wrap-real-only.c",
42 "ifunc-alias.c",
43 "ifunc-address-equality.c",
44- "stack-size.c"
45+ "stack-size.c",
46+ "undefined-weak-sym.c"
47 )]
48 program_name: &'static str,
49 #[allow(unused_variables)] setup_symlink: (),
50diff --git a/wild/tests/sources/undefined-weak-sym.c b/wild/tests/sources/undefined-weak-sym.c
51new file mode 100644
52index 000000000..b029ca7e2
53--- /dev/null
54+++ b/wild/tests/sources/undefined-weak-sym.c
55@@ -0,0 +1,25 @@
56+// A test for #1472.
57+
58+//#Object:runtime.c
59+//#CompArgs:-fno-PIC
60+//#Mode:dynamic
61+//#Shared:force-dynamic-linking.c
62+//#DiffIgnore:section.got
63+//#DiffIgnore:.dynamic.DT_NEEDED
64+//#DiffIgnore:.dynamic.DT_RELA
65+//#DiffIgnore:.dynamic.DT_RELAENT
66+//#DiffIgnore:rel.undefined-weak.dynamic.R_X86_64_GLOB_DAT
67+
68+#include "runtime.h"
69+
70+#define WEAK __attribute__((weak))
71+
72+int WEAK foo(void);
73+
74+void _start(void) {
75+ runtime_init();
76+ if (foo) {
77+ exit_syscall(foo());
78+ }
79+ exit_syscall(42);
80+}