blob: 3b47b18eff00853509fac805019e47e0e59fb3f1 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001# bionic/arch-x86/bionic/crtbegin_dynamic.S
2#
3# Copyright 2006, The Android Open Source Project
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the
11# documentation and/or other materials provided with the distribution.
12# * Neither the name of Google Inc. nor the names of its contributors may
13# be used to endorse or promote products derived from this software
14# without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR
17# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19# EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 .text
28 .align 4
29 .type _start, @function
30 .globl _start
31
32# this is the small startup code that is first run when
33# any executable that is statically-linked with Bionic
34# runs.
35#
36# it's purpose is to call __libc_init with appropriate
37# arguments, which are:
38#
39# - the address of the raw data block setup by the Linux
40# kernel ELF loader
41#
42# - address of an "onexit" function, not used on any
43# platform supported by Bionic
44#
45# - address of the "main" function of the program. We
46# can't hard-code it in the adr pseudo instruction
47# so we use a tiny trampoline that will get relocated
48# by the dynamic linker before this code runs
49#
50# - address of the constructor list
51#
52_start:
53 mov %esp, %eax
54 mov $1f, %edx
55 pushl %edx
56 mov $0f, %edx
57 pushl %edx
58 mov $0, %edx
59 pushl %edx
60 pushl %eax
61 call __libc_init
62
630:
64 jmp main
65
661: .long __PREINIT_ARRAY__
67 .long __INIT_ARRAY__
68 .long __FINI_ARRAY__
69 .long __CTOR_LIST__
70
71# the .ctors section contains a list of pointers to "constructor"
72# functions that need to be called in order during C library initialization,
73# just before the program is being run. This is a C++ requirement
74#
75# the last entry shall be 0, and is defined in crtend.S
76#
77 .section .preinit_array, "aw"
78 .globl __PREINIT_ARRAY__
79__PREINIT_ARRAY__:
80 .long -1
81
82 .section .init_array, "aw"
83 .globl __INIT_ARRAY__
84__INIT_ARRAY__:
85 .long -1
86
87 .section .fini_array, "aw"
88 .globl __FINI_ARRAY__
89__FINI_ARRAY__:
90 .long -1
91
92 .section .ctors, "aw"
93 .globl __CTOR_LIST__
94__CTOR_LIST__:
95 .long -1
96