w6a/ww: DATAR naming an undefined slot is a loud reject

A DATAR relocation against an undefined data slot was silently
dropped — the relocation vanished from the object. Reject loudly,
matching the cstage single-pass resolution behavior.
This commit is contained in:
2026-06-13 04:43:57 +09:00
parent 2ce94a194a
commit 95da870734
4 changed files with 170 additions and 8 deletions

View File

@@ -300,10 +300,17 @@ export fn encode(a: *asm_) i32 = {
// pointing at target. Slot must already be defined
// by a prior DATAW.
let holder: *asym = intern(a, p.from.asym);
if (holder.defined == 0) {
p = p.link; continue;
};
if (holder.isdata == 0) {
// #59: a DATAR slot with no prior DATAW definition must be
// a loud error, not a silently dropped relocation (the .o
// would ship a zero-filled pointer slot — a null pointer at
// link/runtime). Mirrors cmd/w6a/asm.c:363 (errs++ → main
// returns 1 before opening the output, so no .o is written).
if (holder.defined == 0 || holder.isdata == 0) {
let msg: str = "w6a: DATAR slot not yet defined as DATAW: ";
os.write(2, msg.ptr, msg.len: u64);
os.write(2, p.from.asym.ptr, p.from.asym.len: u64);
os.write(2, "\n".ptr, 1u64);
a.errs += 1;
p = p.link; continue;
};
let target: *asym = intern(a, p.to.asym);

View File

@@ -4023,10 +4023,17 @@ export fn encode(a: *asm_) i32 = {
// pointing at target. Slot must already be defined
// by a prior DATAW.
let holder: *asym = intern(a, p.from.asym);
if (holder.defined == 0) {
p = p.link; continue;
};
if (holder.isdata == 0) {
// #59: a DATAR slot with no prior DATAW definition must be
// a loud error, not a silently dropped relocation (the .o
// would ship a zero-filled pointer slot — a null pointer at
// link/runtime). Mirrors cmd/w6a/asm.c:363 (errs++ → main
// returns 1 before opening the output, so no .o is written).
if (holder.defined == 0 || holder.isdata == 0) {
let msg: str = "w6a: DATAR slot not yet defined as DATAW: ";
os.write(2, msg.ptr, msg.len: u64);
os.write(2, p.from.asym.ptr, p.from.asym.len: u64);
os.write(2, "\n".ptr, 1u64);
a.errs += 1;
p = p.link; continue;
};
let target: *asym = intern(a, p.to.asym);