v4: mkf18a, the host tool that builds a train's F18 artifact (ADR step 3, task 3)
The artifact's layout and its check (artifact.h, artifact.c), the tool (tools/f18a.c, mkf18a.c) and make -C v4 artifacts. test_mkf18a, 83 checks at both widths, failed against a stub first. Gates: test, test-32 and sanitize pass, POST 990/990. Plan section 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
||||
* Copyright (c) 2023-2026 Robert A. James
|
||||
*/
|
||||
/* artifact.h -- a train's engine, as an F18 artifact: its layout, and the check of it.
|
||||
*
|
||||
* docs/v4.0.0/ARTIFACT.md, as ruled. The records are 32-bit units, low byte first; the code is cells of
|
||||
* the build's width, each low byte first. In order:
|
||||
* header 16, provenance 64, exports E x 8, imports I x 6, relocations R x 2, verification 18,
|
||||
* string pool S, code C cells
|
||||
* The string pool's unit 0 is always 0, so an offset of 0 means "none" (ARTIFACT.md section 5).
|
||||
*
|
||||
* v4_f18a_check is section 7, "what makes a valid artifact": what the tool writes, and what placement
|
||||
* checks before it places anything.
|
||||
*/
|
||||
#ifndef V4_ARTIFACT_H
|
||||
#define V4_ARTIFACT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define V4_F18A_MAGIC 0x41383146u /* "F18A", low byte first */
|
||||
#define V4_F18A_ABI 0u
|
||||
#define V4_F18A_HEADER 16u
|
||||
#define V4_F18A_PROV 64u
|
||||
#define V4_F18A_EXPORT 8u
|
||||
#define V4_F18A_IMPORT 6u
|
||||
#define V4_F18A_RELOC 2u
|
||||
#define V4_F18A_VERIFY 18u
|
||||
#define V4_F18A_INTERNAL 0xFFFFFFFFu /* a relocation within the code: the base is added */
|
||||
#define V4_F18A_WHOLE 7u /* a relocation's slot: the whole cell holds the address */
|
||||
#define V4_F18A_PORTS 0x80000000u /* an export's capabilities: it touches ports */
|
||||
|
||||
/* Where each part is, in units from the start, and the counts. */
|
||||
typedef struct {
|
||||
uint32_t cell_bits, node_words;
|
||||
uint32_t e, i, r, s, c;
|
||||
size_t exports, imports, relocs, verify, pool, code;
|
||||
} v4_f18a_layout;
|
||||
|
||||
/* The unit at unit offset `u`. */
|
||||
uint32_t v4_f18a_unit(const unsigned char *a, size_t u);
|
||||
|
||||
/* 1 and *lay if the `len` bytes at `a` are a valid artifact of `cell_bits`-bit cells; else 0 and *why. */
|
||||
int v4_f18a_check(const unsigned char *a, size_t len, unsigned cell_bits, v4_f18a_layout *lay, const char **why);
|
||||
|
||||
#endif /* V4_ARTIFACT_H */
|
||||
Reference in New Issue
Block a user