From 8899ce56213961b9b2dd10ad70f16269ea76f9bc Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Mon, 11 May 2026 22:35:08 +0900 Subject: [PATCH] w6l/dynout: restore def INTERP after wwstage cgen def-str fix --- selfhost/cmd/w6l/dynout.ww | 23 ++++------------------- selfhost/cmd/w6l/main.combined.ww | 23 ++++------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/selfhost/cmd/w6l/dynout.ww b/selfhost/cmd/w6l/dynout.ww index adfe13f4..52f0401d 100644 --- a/selfhost/cmd/w6l/dynout.ww +++ b/selfhost/cmd/w6l/dynout.ww @@ -21,15 +21,6 @@ // [pad to next page] // [gotplt_off] .got.plt (writable; mapped by PT_LOAD #2) // [dynamic_off] .dynamic (writable; covered by PT_DYNAMIC) -// -// cgen workaround notes: -// - Two-level field assignments through pointers (e.g. r.sym.isdyn = 1) -// silently fail in the current wwstage cgen. We bind the inner -// pointer to a local first: `let sym = r.sym; sym.isdyn = 1;` -// - Tuple returns of (i32, str) drop the str payload. soversion -// returns a plain str instead. -// - `def NAME: str = "...";` produces a bogus str (len ends up adding -// to an offset accumulator). We use a fn returning the literal. use os; use mem; @@ -79,11 +70,7 @@ def STT_FUNC_D: u8 = 2u8; def PLT_STUB_BYTES_D: u64 = 8u64; def PAGE: u64 = 4096u64; -// The PT_INTERP literal. Returned via a fn to dodge `def : str = "..."` -// breakage in the current cgen. -fn interpstrv() str = { - return "/lib64/ld-linux-x86-64.so.2"; -}; +def INTERP: str = "/lib64/ld-linux-x86-64.so.2"; // ---- byte writers ------------------------------------------------------ @@ -421,8 +408,7 @@ export fn emitdynelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = { let ehdrsz: u64 = 64u64; let nphdrs: u64 = 4u64; let phdrsz: u64 = nphdrs * 56u64; - let islocal: str = interpstrv(); - let interpsz: u64 = (islocal.len: u64) + 1u64; + let interpsz: u64 = (INTERP.len: u64) + 1u64; let nsymstotal: u64 = 1u64 + nu; let dynsymsz: u64 = nsymstotal * 24u64; @@ -717,9 +703,8 @@ export fn emitdynelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = { dwr64(filebuf, p3 + 48u64, 8u64); // Sections. - let interplocal: str = interpstrv(); - dbcopy(filebuf, interpoff, interplocal.ptr, interplocal.len: u64); - dwr8(filebuf, interpoff + (interplocal.len: u64), 0u8); + dbcopy(filebuf, interpoff, INTERP.ptr, INTERP.len: u64); + dwr8(filebuf, interpoff + (INTERP.len: u64), 0u8); dbcopy(filebuf, dynstroff, dynstr, dynstrsz); dbcopy(filebuf, dynsymoff, dynsymbuf, dynsymsz); dbcopy(filebuf, hashoff, hashbuf, hashsz); diff --git a/selfhost/cmd/w6l/main.combined.ww b/selfhost/cmd/w6l/main.combined.ww index b1d1d88d..b7ec7674 100644 --- a/selfhost/cmd/w6l/main.combined.ww +++ b/selfhost/cmd/w6l/main.combined.ww @@ -1447,15 +1447,6 @@ export fn relocate(l: *lnk, base: u64) i32 = { // [pad to next page] // [gotplt_off] .got.plt (writable; mapped by PT_LOAD #2) // [dynamic_off] .dynamic (writable; covered by PT_DYNAMIC) -// -// cgen workaround notes: -// - Two-level field assignments through pointers (e.g. r.sym.isdyn = 1) -// silently fail in the current wwstage cgen. We bind the inner -// pointer to a local first: `let sym = r.sym; sym.isdyn = 1;` -// - Tuple returns of (i32, str) drop the str payload. soversion -// returns a plain str instead. -// - `def NAME: str = "...";` produces a bogus str (len ends up adding -// to an offset accumulator). We use a fn returning the literal. use os; use mem; @@ -1505,11 +1496,7 @@ def STT_FUNC_D: u8 = 2u8; def PLT_STUB_BYTES_D: u64 = 8u64; def PAGE: u64 = 4096u64; -// The PT_INTERP literal. Returned via a fn to dodge `def : str = "..."` -// breakage in the current cgen. -fn interpstrv() str = { - return "/lib64/ld-linux-x86-64.so.2"; -}; +def INTERP: str = "/lib64/ld-linux-x86-64.so.2"; // ---- byte writers ------------------------------------------------------ @@ -1847,8 +1834,7 @@ export fn emitdynelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = { let ehdrsz: u64 = 64u64; let nphdrs: u64 = 4u64; let phdrsz: u64 = nphdrs * 56u64; - let islocal: str = interpstrv(); - let interpsz: u64 = (islocal.len: u64) + 1u64; + let interpsz: u64 = (INTERP.len: u64) + 1u64; let nsymstotal: u64 = 1u64 + nu; let dynsymsz: u64 = nsymstotal * 24u64; @@ -2143,9 +2129,8 @@ export fn emitdynelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = { dwr64(filebuf, p3 + 48u64, 8u64); // Sections. - let interplocal: str = interpstrv(); - dbcopy(filebuf, interpoff, interplocal.ptr, interplocal.len: u64); - dwr8(filebuf, interpoff + (interplocal.len: u64), 0u8); + dbcopy(filebuf, interpoff, INTERP.ptr, INTERP.len: u64); + dwr8(filebuf, interpoff + (INTERP.len: u64), 0u8); dbcopy(filebuf, dynstroff, dynstr, dynstrsz); dbcopy(filebuf, dynsymoff, dynsymbuf, dynsymsz); dbcopy(filebuf, hashoff, hashbuf, hashsz);