blob: 624d611fb2446b1ec6935ec54aa9e91322295339 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28 .text
29 .align 4
30 .type _start,#function
31 .globl _start
32
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020033# This is the small startup code that is called from
34# the dynamic linker to execute an executable once all
35# dependent shared libraries have been loaded and
36# initialized.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080037#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020038# It's purpose is to call __libc_init as defined in
39# bionic/libc_init_dynamic.c with appropriate
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080040# arguments, which are:
41#
42# - the address of the raw data block setup by the Linux
43# kernel ELF loader
44#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020045# - address of an "onexit" function (not used on any
46# platform supported by Bionic)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080047#
48# - address of the "main" function of the program. We
49# can't hard-code it in the adr pseudo instruction
50# so we use a tiny trampoline that will get relocated
51# by the dynamic linker before this code runs
52#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020053# - address of the constructors table, i.e. a table
54# that points to various initialization and
55# finalization sections for the program.
56#
57# NOTE: This code is currently placed in shared libraries
58# by the build system, but will be ignored.
59#
60# On the other hand, the arrays defined below are
61# required and will be parsed by the dynamic linker.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080062#
63_start:
64 mov r0, sp
65 mov r1, #0
66 adr r2, 0f
67 adr r3, 1f
68 b __libc_init
69
700: b main
71
721: .long __PREINIT_ARRAY__
73 .long __INIT_ARRAY__
74 .long __FINI_ARRAY__
75 .long __CTOR_LIST__
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020076
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080077# the .ctors section contains a list of pointers to "constructor"
78# functions that need to be called in order during C library initialization,
79# just before the program is being run. This is a C++ requirement
80#
81# the last entry shall be 0, and is defined in crtend.S
82#
83 .section .preinit_array, "aw"
84 .globl __PREINIT_ARRAY__
85__PREINIT_ARRAY__:
86 .long -1
87
88 .section .init_array, "aw"
89 .globl __INIT_ARRAY__
90__INIT_ARRAY__:
91 .long -1
92
93 .section .fini_array, "aw"
94 .globl __FINI_ARRAY__
95__FINI_ARRAY__:
96 .long -1
97
98 .section .ctors, "aw"
99 .globl __CTOR_LIST__
100__CTOR_LIST__:
101 .long -1
102