/*
 *  Stub Loader
 *
 *  Copywrite (C) 1993  Hamish Coleman (hamish@zot.apana.org.au)
 */

.data
.globl	__NEEDS_SHRLIB_libc_4
.globl	__NEEDS_SHRLIB_libvdos
.globl	___SHARED_LIBRARIES__
.globl	__SHARABLE_CONFLICTS_

libc_name:	.asciz	"libc.so.4"
libc_desc:	.asciz	"Jump 4"
LIBNAME:	.asciz	"libemu.2d"
LIBDESC:	.asciz	"virt DOS" 

__dummy_VERSION:
		.long	0x00010000
__dummy_feebled:
		.long	0xfeeb1ed3
__dummy_null:
		.long	0x0
__null = 0x0

__NEEDS_SHRLIB_libc_4:
		.long	libc_name
		.long	libc_desc
		.long	0x60000000
		.long	0x00040000

__NEEDS_SHRLIB_libvdos:
		.long	LIBNAME
		.long	LIBDESC
		.long	__dummy_VERSION
		.long	0x00010000

.stabs	"___SHARED_LIBRARIES__",24,0,0,__null
.stabs	"___SHARED_LIBRARIES__",24,0,0,__NEEDS_SHRLIB_libvdos
.stabs	"___SHARED_LIBRARIES__",24,0,0,__NEEDS_SHRLIB_libc_4

.stabs	"__SHARABLE_CONFLICTS_",23,0,0,__dummy_feebled
.stabs	"__SHARABLE_CONFLICTS_",23,0,0,__dummy_null
.stabs	"__SHARABLE_CONFLICTS_",23,0,0,__dummy_null

.comm	_dummy, 1024 * 1088

ldso_image:	.asciz	"/lib/ld.so"
error:		.asciz	"Cannot load ld.so"

mapinfo1:	.long	0
mapinfo2:	.long	0

.text

__entry:
	movl	$0x56,%eax
	movl	$ldso_image,%ebx
	int	$0x80
	testl	%eax,%eax
	jnl	loaded
	movl	$0x4,%eax
	movl	$0x2,%ebx
	movl	$error,%ecx
	movl	$0x17,%edx
	int	$0x80
l1:
	movl	$0x1,%eax
	movl	$0x80,%ebx
	int	$0x80
	jmp	l1
	
loaded:
	movl	%esp,%ebp
	pushl	$__SHARABLE_CONFLICTS_
	pushl	$___SHARED_LIBRARIES__
	movl	0x8(%ebp,1),%edx
	pushl	%edx
	movl	0x4(%ebp,1),%ebx
	movl	(%ebx),%ebx
	pushl	%ebx
	pushl	$mapinfo1
	movl	$0x2,%eax
	movl	0x0(%ebp,1),%ebx
	testl	%ebx,%ebx
	jg	ov1
	movl	$0x1,%eax
ov1:
	pushl	%eax
	movl	$0x62f00000,%eax
	call	*%eax
	movl	(mapinfo1),%ebx
	movl	(mapinfo2),%ecx
	movl	$0x5b,%eax
	int	$0x80
	
	movl	0x0(%ebp,1),%ebx
	testl	%ebx,%ebx
	jg	ov2
	jmp	l1
ov2:
	jmp	*$0x400000
