Align library table entires on Big Endian machines

Not doing this causes the VM to crash on startup inside amx_Init() when
extracting the names of linked libraries from the name table.
This commit is contained in:
Zeex 2022-10-27 12:58:01 +06:00
parent 8cc4c02b20
commit 2f86aa0541

View File

@ -1041,6 +1041,16 @@ int AMXAPI amx_Init(AMX *amx,void *program)
AMX_FUNCSTUB *fs;
int i,num;
fs=GETENTRY(hdr,publics,0);
assert(hdr->publics<=hdr->natives);
num=NUMENTRIES(hdr,publics,natives);
for (i=0; i<num; i++) {
amx_AlignCell(&fs->address);
if (USENAMETABLE(hdr))
amx_Align32(&((AMX_FUNCSTUBNT*)fs)->nameofs);
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
} /* for */
fs=GETENTRY(hdr,natives,0);
num=NUMENTRIES(hdr,natives,libraries);
for (i=0; i<num; i++) {
@ -1050,9 +1060,8 @@ int AMXAPI amx_Init(AMX *amx,void *program)
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
} /* for */
fs=GETENTRY(hdr,publics,0);
assert(hdr->publics<=hdr->natives);
num=NUMENTRIES(hdr,publics,natives);
fs=GETENTRY(hdr,libraries,0);
num=NUMENTRIES(hdr,libraries,pubvars);
for (i=0; i<num; i++) {
amx_AlignCell(&fs->address);
if (USENAMETABLE(hdr))