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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*--------------------------------------------------------------------*/
/*--- Darwin amd64 bootstrap. m_start-amd64-darwin.S ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2007 Apple Inc.
Greg Parker gparker@apple.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
The GNU General Public License is contained in the file COPYING.
*/
#include "pub_core_basics_asm.h"
.text
.align 3,0x90
Ldyld_stub_binding_helper:
pushq %r11
leaq ___dso_handle(%rip), %r11
pushq %r11
jmpq *Ldyld_lazy_symbol_binding_entry_point(%rip)
.dyld
.align 3
Ldyld_lazy_symbol_binding_entry_point:
.quad 0
.quad 0
.quad 0
.quad 0
.quad 0
.quad Ldyld_stub_binding_helper
.quad 0
// Memory layout established by kernel:
//
// 0
// executable_name
// 0
// envp[n]
// ...
// envp[0]
// 0
// argv[argc-1]
// ...
// sp+8-> argv[0]
// sp -> argc
.text
.align 3,0x90
.globl __start
__start:
movq %rsp, %rdi // save &argc
andq $-16, %rsp // align stack
pushq $0 // push NULL "return address" for backtraces
pushq $0 // push fake saved ebp and align stack
movq %rsp, %rbp // save frame pointer
call __start_in_C_darwin // __start_in_C_darwin(&argc)
// should not reach here
int $3
int $3
|