Implement M8.1 native .lib linking: System V !<arch> parsing (/ symbol index, // long-name table, /N references, even-byte padding, loud malformed/truncated errors), in-memory member objects labelled lib(member), and extraction in the archive's own symbol-table order driven by currently undefined globals, iterated to a fixpoint without re-extracting a member. Duplicate definitions and unresolved references fail with object/member names. Accept archive paths and -l/-lL in the CLI, preserve layout/map/debug behavior, and let scripts/m4/run.sh pass M4_NATIVE_LIBS/M4_NATIVE_RTS archives to tms-link. Relocation addends are now applied as signed 32-bit values (needed by the termtris rts.lib link). Tests: tms-link archive fixtures and real flib extraction, m7 archive/-l parity, m5 native termtris with tms-link+rts.lib (dis34 match), m6 i64/runtime GSPLNK gates, and scripts/tests/m8/native-lib.sh (FLIB.LIB + RTS.LIB, MAME markers, GSPLNK byte/symbol parity).
27 lines
891 B
C
27 lines
891 B
C
/* M8 native-library gate driver.
|
|
*
|
|
* The double operations lower to flib.lib's FD$ADD/FD$MUL and the fptosi
|
|
* conversions to FD$DTOI; isascii is the rts.lib member. The markers are
|
|
* fixed bit addresses in the prog region because the linker map's symbol
|
|
* values are not needed by this tiny check.
|
|
*/
|
|
#define MARK(n) (*(volatile unsigned int *)(0x018A8000u + (n) * 0x20u))
|
|
|
|
extern int isascii(int);
|
|
|
|
static volatile double fa = 1.5;
|
|
static volatile double fb = 2.5;
|
|
|
|
int libcheck_test(void)
|
|
{
|
|
double sum = fa + fb;
|
|
double product = fa * fb;
|
|
|
|
MARK(0) = (unsigned)(int)sum; /* 4: FD$ADD + FD$DTOI */
|
|
MARK(1) = (unsigned)(int)product; /* 3: FD$MUL + FD$DTOI */
|
|
MARK(2) = (unsigned)isascii('A'); /* 1: rts.lib _isascii */
|
|
MARK(3) = (unsigned)isascii(0xC8); /* 0: rts.lib _isascii */
|
|
MARK(4) = 0x4C494231u; /* "LIB1" sentinel */
|
|
return 0;
|
|
}
|