Skip to content

Commit

Permalink
plt: add API versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
stsp committed Sep 11, 2024
1 parent f379f4b commit c95a82d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/libc/dj64/plt.S
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ plt_init:
movl %fs:STUBINFO_SELF_SIZE, %ecx
movl %fs:STUBINFO_MEM_BASE, %edx
call ctrl
jc 2f
/* free mem */
movl $0x502, %eax
movw handle, %di
Expand All @@ -275,17 +276,27 @@ plt_init:
movl $0, %ecx
movl %fs:STUBINFO_MEM_BASE, %edx
call ctrl
jc 2b
jmp 11b

ctrl:
pushal
movl %esp, %edx
movl __plt_handle, %eax
movl $AUX_CORE, %ebx
movl $0, %ebx
movb $AUX_CORE, %bl
movb $DL_API_VER, %bh
movl $DL_SET_SYMTAB, %ecx
movl %cs, %esi
lcalll *__plt_ctrl
testl %eax, %eax
jnz 1f
popal
clc
ret
1:
popal
stc
ret

.global plt_done
Expand Down
1 change: 1 addition & 0 deletions src/libc/dj64/plt.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#define DL_SET_SYMTAB 0
#define DL_API_VER 1
8 changes: 8 additions & 0 deletions src/libc/dj64/thunks.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,15 @@ static void do_early_init(int handle)
static int dj64_ctrl(int handle, int libid, int fn, unsigned esi, uint8_t *sp)
{
dpmi_regs *regs = (dpmi_regs *)sp;
int ver = libid >> 8;
assert(handle < MAX_HANDLES);
if (ver != DL_API_VER) {
djloudprintf("dj64: API version mismatch, got %i want %i\n",
ver, DL_API_VER);
if (ver == 0) // this doesn't even handle errors, so terminate
dj64api->exit(1);
return -1;
}
switch (fn) {
case DL_SET_SYMTAB: {
struct udisp *u = &udisps[handle];
Expand Down

0 comments on commit c95a82d

Please sign in to comment.