Files
arti 29c30ddcc6 tms-link: read ar archives and extract members selectively
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).
2026-11-16 02:56:44 +00:00

35 lines
1.2 KiB
Lua

-- lib-check.lua -- read the M8 native-library gate marker words.
--
-- The driver writes five words at 018A8000 + n*0x20:
-- 0: (int)(1.5 + 2.5) == 4 (flib FD$ADD + FD$DTOI)
-- 1: (int)(1.5 * 2.5) == 3 (flib FD$MUL + FD$DTOI)
-- 2: isascii('A') != 0 (rts.lib _isascii)
-- 3: isascii(0xC8) == 0 (rts.lib _isascii)
-- 4: 0x4C494231 ("LIB1" sentinel)
dofile(os.getenv("M4_LOADER_LUA"))
local ENDF = tonumber(os.getenv("LOADER_END") or "3400")
local frames = 0
local checked = false
emu.register_frame_done(function()
frames = frames + 1
if frames == ENDF - 1 and not checked then
checked = true
local prog = manager.machine.devices[':maincpu'].spaces['program']
local got = {}
for i = 0, 4 do
got[i] = prog:read_u32(0x018A8000 + i * 0x20)
end
print(string.format("M8 LIB: sum=%d product=%d asciiA=%d asciiC8=%d sentinel=%08X",
got[0], got[1], got[2], got[3], got[4]))
if got[0] == 4 and got[1] == 3 and got[2] ~= 0 and
got[3] == 0 and got[4] == 0x4C494231 then
print("M8 LIB MAME: PASS")
else
print("M8 LIB MAME: FAIL (want 4 3 nonzero 0 4C494231)")
end
end
end, "m8-lib-check")