Skip to content

Repair assembly/C offset synchronization for runtime_sh4_minimal.S #14

@drpaneas

Description

@drpaneas

Summary

The runtime still relies on hardcoded .equ offsets in runtime/runtime_sh4_minimal.S, but the current gen-offsets.c / asm-offsets.h pipeline is incomplete and make check-offsets does not validate the assembly constants actually in use.

Why

  • Assembly context-switch code depends on struct field offsets matching C layouts exactly.
  • The current generated runtime/asm-offsets.h is only a placeholder with include guards and no offset definitions.
  • make check-offsets validates that placeholder output, not the hardcoded .equ constants consumed by the assembly.
  • This creates silent-corruption risk: a C struct layout change can make the assembly read or write the wrong fields.

Evidence

  • runtime/runtime_sh4_minimal.S still defines local .equ constants such as G_CONTEXT.
  • runtime/asm-offsets.h currently contains only include guards and no offset values.
  • Makefile explicitly notes that check-offsets does not validate the hardcoded .equ values.
  • runtime/gen-offsets.c still exists and is intended to describe the C-side layout being checked.

Direction

  • Make one source of truth for assembly-visible offsets.
  • Either generate a real include file consumed by assembly, or add a direct build-time/runtime verification step against the .equ constants actually used.
  • Ensure make check-offsets fails when assembly constants drift from the C layout.
  • Document the supported workflow for changing G / context-related structs once the synchronization path is real.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions