blob: 69d8df66c076f7dd5223d134860100afed32b31c [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 first run when
34# any static executable runs. A static executable is one
35# that is started directly by the Linux kernel, not from
36# the dynamic linker, it thus cannot depend on any shared
37# library.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080038#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020039# It's purpose is to call __libc_init as defined in
40# bionic/libc_init_static.c with appropriate
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041# arguments, which are:
42#
43# - the address of the raw data block setup by the Linux
44# kernel ELF loader
45#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020046# - address of an "onexit" function (not used on any
47# platform supported by Bionic).
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080048#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020049# - address of the "main" function of the program.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080050#
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020051# - address of the constructors table, i.e. a table
52# that points to various initialization and
53# finalization sections for the program.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080054#
55_start:
56 mov r0, sp
57 mov r1, #0
58 adr r2, 0f
59 adr r3, 1f
60 b __libc_init
61
620: b main
63
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020064# The "C++ ABI for ARM" document that static C++ constructors
65# shall only be called from the .init_array section.
66#
67# Do we really need a .ctors section on ARM platforms ?
68# It looks like it will always be empty.
69#
70
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800711: .long __PREINIT_ARRAY__
72 .long __INIT_ARRAY__
73 .long __FINI_ARRAY__
74 .long __CTOR_LIST__
David 'Digit' Turner03eabfe2009-05-28 15:54:03 +020075
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080076# the .ctors section contains a list of pointers to "constructor"
77# functions that need to be called in order during C library initialization,
78# just before the program is being run. This is a C++ requirement
79#
80# the last entry shall be 0, and is defined in crtend.S
81#
82 .section .preinit_array, "aw"
83 .globl __PREINIT_ARRAY__
84__PREINIT_ARRAY__:
85 .long -1
86
87 .section .init_array, "aw"
88 .globl __INIT_ARRAY__
89__INIT_ARRAY__:
90 .long -1
91
92 .section .fini_array, "aw"
93 .globl __FINI_ARRAY__
94__FINI_ARRAY__:
95 .long -1
96
97 .section .ctors, "aw"
98 .globl __CTOR_LIST__
99__CTOR_LIST__:
100 .long -1
101