Which are data import relocations. Even though each symbol is 4 bytes apart, their actual sizes can be much larger, like the GsDRAWENV symbol which is of type DRAWENV:
/*
* Rectangle:
*/
typedef struct {
short x, y; /* offset point on VRAM */
short w, h; /* width and height */
} RECT;
/*
* Environment
*/
typedef struct {
u_long tag;
u_long code[15];
} DR_ENV; /* Packed Drawing Environment */
typedef struct {
RECT clip; /* clip area */
short ofs[2]; /* drawing offset */
RECT tw; /* texture window */
u_short tpage; /* texture page */
u_char dtd; /* dither flag (0:off, 1:on) */
u_char dfe; /* flag to draw on display area (0:off 1:on) */
u_char isbg; /* enable to auto-clear */
u_char r0, g0, b0; /* initital background color */
DR_ENV dr_env; /* reserved */
} DRAWENV;
But ghidra treats as if the data WAS in the relocation segment instead, which result in really wrong code:
In this case, the PutDrawEnv is being called on the GsDRAWENV location, but PutDispEnv is supposed to be called on the GsDISPENV location, which isn't what the import currently is doing here. It's using GsDISPENV again.
It's also visible in the disassembly window:
IDA:
.text:00000304 la $s0, GsDISPENV
.text:0000030C addiu $v0, $s0, (PSDBASEX - 0x48)
.text:00000310 sh $zero, (GsDISPENV - 0x48)($s0)
Try loading GS_001.OBJ from LIBGS.LIB. Under IDA, you'll get the following:
Which are data import relocations. Even though each symbol is 4 bytes apart, their actual sizes can be much larger, like the
GsDRAWENV
symbol which is of typeDRAWENV
:But ghidra treats as if the data WAS in the relocation segment instead, which result in really wrong code:
In this case, the
PutDrawEnv
is being called on theGsDRAWENV
location, butPutDispEnv
is supposed to be called on theGsDISPENV
location, which isn't what the import currently is doing here. It's usingGsDISPENV
again.It's also visible in the disassembly window:
IDA:
ghidra:
Even though the IDA output is a bit more confusing, it's properly referencing
GsDISPENV
instead ofGsDRAWENV
.