#define DL_DATA_SIZE (16*4)
#include <sys/syscall.h>
#include <machine/asm.h>
.text
.align 16,0xcc
.globl _dl_start
.type _dl_start,@function
_dl_start:
movl %esp,%eax # save stack pointer for _rtld
subl $DL_DATA_SIZE,%esp # allocate dl_data
call 1f # push &_DYNAMIC...
1: addl $(_DYNAMIC-1b),(%esp) # ...for dl_boot_bind
movl %esp,%ebx
movl %ebx,%edi # save dl_data arg for dl_boot
pushl %ebx # push dl_data for dl_boot_bind
mov %eax, %esi # save stack for dl_boot
pushl %eax # load saved SP for dl_boot_bind
call _dl_boot_bind@PLT # _dl_boot_bind(sp,dl_data)
pushl %edi # push saved dl_data
movl %edi,%ebp
movl (7*4)(%ebp),%eax
pushl %eax # push loff from dl_data
movl %esi,%ebp
movl $4,%eax
imull 0(%ebp),%eax
addl $8,%eax
addl %ebp,%eax
push %eax # push envp
leal 4(%ebp),%eax
push %eax # push argv
call _dl_boot@PLT # _dl_boot(argv,envp,loff,dl_data)
addl $7*4,%esp # pop args
addl $DL_DATA_SIZE,%esp # return dl_data
call 1f # %edx = cleanup
1: popl %ebx
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
leal _dl_dtors@GOTOFF(%ebx), %edx
jmp *%eax
.align 16,0xcc
.global _dl_bind_start
.type _dl_bind_start,@function
_dl_bind_start:
pushf # save registers
pushl %eax
pushl %ecx
pushl %edx
pushl %ebx
pushl %ebp
pushl %esi
pushl %edi
pushl %ds
pushl %es
pushl 44(%esp) # Copy of reloff
pushl 44(%esp) # Copy of obj
call _dl_bind@PLT # Call the binder
addl $8,%esp # pop binder args
movl %eax,44(%esp) # Store function to be called in obj
popl %es # restore registers
popl %ds
popl %edi
popl %esi
popl %ebp
popl %ebx
popl %edx
popl %ecx
popl %eax
popf
leal 4(%esp),%esp # Discard reloff, do not change eflags
ret