1/*
2 * Copyright 2005-2006, Axel D��rfler, axeld@pinc-software.de.
3 * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
4 * Distributed under the terms of the MIT License.
5 */
6
7
8#include <asm_defs.h>
9
10
11/**	This file contains the first part of the ".init" and ".fini" sections in
12 *	the ELF executable.
13 *	The functions defined here will be called during initialization/termination
14 *	of the loaded executable/library. The ".init" and ".fini" sections are
15 *	stacked together like this:
16 *
17 *	crti.S		entry point
18 *				call to _init_before/_term_before
19 *	crtbegin.S	GCC specific: constructors/destructors are called, ...
20 *	crtend.S
21 *	crtn.S		call to _init_after/_term_after
22 *				exit
23 */
24
25
26.section .init
27FUNCTION(_init):
28	push	%rbp
29	movq	%rsp, %rbp
30
31	// Preserve image ID for call to __haiku_init_after.
32	push	%rdi
33
34	call	__haiku_init_before
35	// crtbegin.o stuff comes here
36
37.section .fini
38FUNCTION(_fini):
39	push	%rbp
40	movq	%rsp, %rbp
41	push	%rdi
42	call	__haiku_term_before
43	// crtend.o stuff comes here
44