From 90168f561ef92b38fc0680ad38a9d2663cb047b4 Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Mon, 27 Jul 2026 19:50:55 +0900 Subject: [PATCH] relibc: replace 2 panic-site unimplemented!() in dynamic linker with proper errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two catch-all branches in the dynamic linker panicked the process if an executable used a relocation type not handled by the explicit match arms. Both functions are Result-returning, but the catch-all used unimplemented!() which expands to panic!() — silently killing the process instead of returning Err. * ld_so/dso.rs:1129 (static_relocate): the _ => unimplemented!("relocation type {:?}", reloc.kind) arm panics for any relocation not in the match. Now returns Err(format!("unsupported relocation type {:?}", reloc.kind)). Process startup with an unfamiliar relocation type now fails gracefully at dlopen time instead of aborting. * ld_so/dso.rs:1203 (lazy_relocate): same pattern in the (reloc.kind, resolve) match. Now returns Err(format!("unsupported relocation type {:?} with resolve {:?}", reloc.kind, resolve)). This is the third round of relibc panic-site fixes (after RTLD_NOLOAD| RTLD_NOW and readdir_r). Found by the Round 10 audit (local/docs/3D-DESKTOP-COMPREHENSIVE-PLAN.md §10). --- src/ld_so/dso.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ld_so/dso.rs b/src/ld_so/dso.rs index dd210ced26..98d4a0b658 100644 --- a/src/ld_so/dso.rs +++ b/src/ld_so/dso.rs @@ -1126,7 +1126,9 @@ impl DSO { RelocationKind::TLSDESC => { self.do_tlsdesc_reloc(reloc, ptr.cast::(), global_scope) } - _ => unimplemented!("relocation type {:?}", reloc.kind), + _ => { + return Err(format!("unsupported relocation type {:?}", reloc.kind)); + } } Ok(()) @@ -1200,11 +1202,11 @@ impl DSO { } _ => { - unimplemented!( - "relocation type {:?} with resolve {:?}", + return Err(format!( + "unsupported relocation type {:?} with resolve {:?}", reloc.kind, resolve - ) + )); } } }