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 sub $0x8, %rsp 34 35 call __haiku_init_before 36 // crtbegin.o stuff comes here 37 38.section .fini 39FUNCTION(_fini): 40 push %rbp 41 movq %rsp, %rbp 42 push %rdi 43 sub $0x8, %rsp 44 call __haiku_term_before 45 // crtend.o stuff comes here 46