w6l: link GNU long-name archive members; bad members fail the link

The archive walk skipped every member whose header name starts
with '/', which also dropped GNU long-name members (/N) -- any
member with a >15-char filename silently never linked. Only '/ '
(symbol index) and '//' (long-name table) are non-objects; /N
members index by content (names are never consulted). A member
that fails loadimage in the selective pull also stayed silently
unlinked with rc=0; it now reports and fails the link (rule 7).
wwstage w6l diagnostics ride the same .len idiom as the w6a sweep.
This commit is contained in:
2026-08-09 01:07:19 +09:00
parent 4fe2e25da4
commit 5006bf4fb9
5 changed files with 58 additions and 14 deletions

View File

@@ -316,9 +316,17 @@ fn loadarchive(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
let hdrend: u64 = pos + 60u64;
if (hdrend + hdrsize > len) { break; };
let first: u8 = buf[pos];
// Skip the symbol table ('/'), long-name table ('//'), and
// any padding entries (NUL or space leading byte).
if (first != '/' && first != 0u8 && first != ' ') {
// '/'-led names: '/ ' is the symbol index and '//' the GNU
// long-name table — neither is an object. '/N' (digits) IS
// a real member whose name lives in that table; names are
// never consulted here, so index it by content. Pre-fix
// every long-named (>15 char) member was silently skipped
// and its definitions never linked.
let second: u8 = buf[pos + 1u64];
let special: bool = (first == '/'
&& (second == ' ' || second == '/'))
|| first == 0u8 || first == ' ';
if (!special) {
let m: *armember = alloc(armember { size = hdrsize })!;
let mbs: []u8 = alloc([], hdrsize)!;
let mb: *u8 = mbs.ptr;
@@ -347,6 +355,15 @@ fn loadarchive(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
if (loadimage(l, path, m.data, m.size) == 0) {
m.loaded = 1;
changed = 1;
} else {
// a member that fails to parse must
// fail the link, not stay silently
// unlinked (rule 7). Consumed either
// way.
let mbad: str = "w6l: bad archive member\n";
os.write(2, mbad.ptr, mbad.len: u64);
l.errs += 1;
m.loaded = 1;
};
};
};