From 8cc4c02b20282f584c5562a4c65e8159ad7922a1 Mon Sep 17 00:00:00 2001 From: Zeex Date: Thu, 27 Oct 2022 03:35:39 +0600 Subject: [PATCH 1/2] Fix compile error on Big Endian targets --- source/amx/amxdbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/amx/amxdbg.c b/source/amx/amxdbg.c index b0adcd60..a713f782 100644 --- a/source/amx/amxdbg.c +++ b/source/amx/amxdbg.c @@ -276,8 +276,8 @@ int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp) && (cell)line->address > (cell)(line - 1)->address) { #if BYTE_ORDER==BIG_ENDIAN for (index = 0; index <= (uint32_t)(1u << 16) - 1; index++) { - dbg_AlignCell(&linetbl[index].address); - dbg_Align32((uint32_t*)&linetbl[index].line); + dbg_AlignCell(&amxdbg->linetbl[index].address); + dbg_Align32((uint32_t*)&amxdbg->linetbl[index].line); line++; } /* for */ #endif From 2f86aa05411d0c914200801a2b9683dced7a7f65 Mon Sep 17 00:00:00 2001 From: Zeex Date: Thu, 27 Oct 2022 12:58:01 +0600 Subject: [PATCH 2/2] 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. --- source/amx/amx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/amx/amx.c b/source/amx/amx.c index 675576ff..aec92386 100644 --- a/source/amx/amx.c +++ b/source/amx/amx.c @@ -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; iaddress); + 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; idefsize); } /* 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; iaddress); if (USENAMETABLE(hdr))