feat(asm): emit RISC-V GOOBJ with the shared emitter

Assisted-by: DeepSeek V4 Pro
This commit is contained in:
2026-08-13 12:07:29 +02:00
parent 31ee8e7941
commit 9b5c878f9e
9 changed files with 358 additions and 383 deletions
+6 -4
View File
@@ -299,10 +299,12 @@ boundaries, plus flat `pcfile`, `pcline` and `pcinline` tables — so a
gasm-assembled object drops into a `go build` in place of the toolchain's.
The object preamble (the version-and-experiment header the linker compares
verbatim) is captured from the installed `go tool asm`, so the output is
always consistent with the toolchain that links it. LoongArch GOOBJ emission
uses the same shared emitter with the loong64 marker and R_LOONG64_ADDR_HI/LO
relocation types, and the emitted object links into a real `go build` for
`GOARCH=loong64`. Per function, the emitter also writes the two DWARF
always consistent with the toolchain that links it. RISC-V and LoongArch
GOOBJ emission share this emitter: the loong64 marker with
R_LOONG64_ADDR_HI/LO relocation types, and the riscv64 marker with a single
R_RISCV_PCREL_ITYPE/STYPE relocation per AUIPC pair — the model `cmd/asm`
writes, not the ELF HI20/LO12 pair — and both link into a real `go build` for
their `GOARCH`. Per function, the emitter also writes the two DWARF
symbols the linker's DWARF pass reads verbatim — the subprogram DIE
(`SDWARFFCN`) and the `.debug_line` state-machine program (`SDWARFLINES`),
both built the way `cmd/asm` builds them (the DIE carries the