[go: up one dir, main page]

File: plthook.S

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (65 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (3)
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)