# DF-5658 — vkernel64 genassym.c emits only 5 of the 26 GD_* macros global.s consumes: 13 silently-vanished `.set` exports for fields that EXIST (DF-5596 twin, 13×), plus the 8 GD_PRV_* dangles split out as DF-5659

**Evidence class: build-diff on the guest's VKERNEL64 build tree** (the vkernel
is a *user program* linked with plain `cc` — see `sys/platform/vkernel64/conf/Makefile:23-25`).

## What to run

Everything was executed on the QEMU guest (DragonFly 6.5-DEVELOPMENT,
`env.txt`) whose `/usr/src` is MD5-identical to the audit tree for all 9 files
involved (genassym.c, global.s, swtch.s, locore.s, fork_tramp.s, conf/files,
VKERNEL64 config, globaldata.h, thread.h — MD5s in `env.txt`).

```sh
# 1. create the VKERNEL64 build tree
cd /usr/src/sys/config && config VKERNEL64          # -> /usr/src/sys/compile/VKERNEL64
cd /usr/src/sys/compile/VKERNEL64

# 2. regen assym.s through the REAL kern.post.mk rules (see build.log)
make assym.s global.o                                # both exit 0, -Werror
nm global.o                                          # -> nm_global_pristine.txt / run.log

# 3. independent value check (offset_check.c, exact genassym CFLAGS)
sh $(sed 's|genassym.c|/tmp/offset_check.c|' checker.cmd) -Wno-nested-externs -o /tmp/oc.o
cc /tmp/oc.o -o /tmp/oc && /tmp/oc                    # -> offset_check.out (65 lines)

# 4. end-to-end link proof (build-id stub works around the unrelated
#    kern_mib.c __build_id buster — see VERDICT.md "Incidental")
cc -g -Wl,--export-dynamic -o /tmp/kernel.dangleproof $(make -V SYSTEM_OBJS) \
   vers.o /tmp/bidstub.o -pthread -Wl,--hash-style=sysv -Wl,-z,max-page-size=0x200000
nm /tmp/kernel.dangleproof | grep ' U GD_'           # -> 21 undefined
objdump -r /tmp/kernel.dangleproof | grep -c GD_     # -> 0 relocations

# 5. fix validation
cd /usr/src && patch -p1 < fix.diff                  # genassym.c +13 ASSYM, global.s -8 PRV
cd sys/compile/VKERNEL64 && rm -f genassym.o assym.s global.o
make assym.s global.o locore.o swtch.o fork_tramp.o  # -> fix_build.log
# relink as in step 4 -> /tmp/kernel.fixed
nm /tmp/kernel.fixed | grep -c ' U GD_'              # -> 0
nm /tmp/kernel.fixed | grep -E ' [ADB] gd_'          # -> 18 exports (fix_run.log)
```

## Expected results

| Step | pristine | patched |
|---|---|---|
| `assym.s` defines | 44 | 57 |
| `global.o` defined gd_*/globaldata | 5+1 | 18+1 |
| `global.o` undefined ASSYM macros | 21 (`U GD_CURRENTLDT`, …) | 0 |
| final binary undefined GD_* | 21 | 0 |
| final binary gd_* exports | 5 | 18 |
| relocations against GD_* | 0 | 0 |
| checker vs assym.s values | 44/44 match | — |

Key restored values (independent-TU verified, `offset_check.out`):
`gd_currentldt=0x3f14` (right after `gd_spending=0x3f0c`+`gd_sdelayed=0x3f10`,
matching `globaldata.h:74-78` field order), `gd_reqflags=0x18`, `gd_cnt=0xa8`,
`gd_intr_nesting_level=0xa0`, `gd_common_tssd=0x3a80`, `gd_tss_gdt=0x3a88`,
`gd_common_tss=0x3a98`, `gd_savefpu=0x3b00`, `gd_fpu_lock=0x3f00`,
`gd_fpending=0x3f04`, `gd_ipending=0x3f08`, `gd_ss_eflags=0x3f48`.

## Files

- `run.log` / `nm_global_pristine.txt` / `final_binary_baseline.txt` — the dangle proof (object + final binary)
- `build.log` / `checker.cmd` / `checker_build.log` — regen + independent-TU build
- `offset_check.c` / `offset_check.out` — 44 ASSYM values verified; `CHECK_*`/`MISSING_*` extras
- `assym.pristine.s` / `assym.fixed.s` — 44 → 57 defines
- `vkbuild.log` — FULL untrimmed 547-object VKERNEL64 build incl. the link failure (`__build_id_*`)
- `link.log` / `link2.log` — baseline/patched final-binary links
- `fixbuild.log` / `fixbuild2.log` / `fix_run.log` / `final_binary_fixed.txt` — fix validation
- `fix.diff` — git-apply-clean against pristine `sys/` (verified with `git apply --check`)
- `env.txt` — guest uname/cc/ncpu + source MD5 identity
