1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include "utils/asm.h"
.hidden plthook_resolver_addr
ENTRY(plt_hooker)
sub $32, %esp
/* save registers */
movl %edx, 24(%esp)
movl %ecx, 20(%esp)
/* this is for ARG1 that using in jmp */
movl 44(%esp), %eax
movl %eax, 16(%esp)
/* stack address contain parent location */
leal 40(%esp), %eax
movl %eax, 0(%esp)
/* child_idx */
movl 36(%esp), %eax
movl %eax, 4(%esp)
/* module_id */
movl 32(%esp), %eax
movl %eax, 8(%esp)
/* mcount_args */
leal 16(%esp), %eax
movl %eax, 12(%esp)
call plthook_entry
/* restore registers */
movl 20(%esp), %ecx
movl 24(%esp), %edx
add $32, %esp
cmpl $0, %eax
jnz 1f
/* get address of plthook_resolver_addr */
call get_pc_thunk
addl $_GLOBAL_OFFSET_TABLE_, %eax
leal plthook_resolver_addr@GOTOFF(%eax), %eax
movl (%eax), %eax
jmp *%eax
1:
add $8, %esp
jmp *%eax
END(plt_hooker)
ENTRY(plthook_return)
sub $16, %esp
movl %edx, 8(%esp)
movl %eax, 4(%esp)
leal 4(%esp), %eax
movl %eax, 0(%esp)
call plthook_exit
movl %eax, 12(%esp)
movl 4(%esp), %eax
movl 8(%esp), %edx
add $12, %esp
ret
END(plthook_return)
|