Files

43 lines
1.3 KiB
C

/* M7.1 odd-offset pointer `.data` gate (native path only).
*
* The target packs records, so `struct oddptr { char c; long long *p; }` puts
* the pointer at byte offset 1. GSPA's only 32-bit relocatable directive is
* `.long`, which it implicitly 16-bit aligns, so the raw text path must reject
* this shape loudly. The TI-COFF object path writes the field unaligned and
* emits an R-RELLONG at the odd byte; data.sh links that object with GSPLNK,
* runs it in MAME and checks the pointer value and raw bytes.
*
* Markers 26..29 are c, p == &x, and the two words of *p. The raw 5-byte
* object is copied to 0x018A9000 + 96*8; the pointer bytes are compared with
* the linked address of x from marker 25.
*/
typedef unsigned int u32;
#define MARK(n) (*(volatile u32 *)(0x018A8000u + (u32)(n) * 0x20u))
#define OUTB(n) (*(volatile unsigned char *)(0x018A9000u + (u32)(n) * 8u))
extern volatile long long x;
struct oddptr {
char c;
long long *p;
};
volatile struct oddptr odd = { 0x5A, (long long *)&x };
void data_odd_run(void)
{
const volatile unsigned char *p =
(const volatile unsigned char *)&odd;
u32 i;
MARK(26) = (u32)(unsigned char)odd.c;
MARK(27) = (u32)(odd.p == &x);
MARK(28) = (u32)(unsigned long long)*odd.p;
MARK(29) = (u32)((unsigned long long)*odd.p >> 32);
for (i = 0; i < (u32)sizeof(odd); i++)
OUTB(96u + i) = p[i];
}