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 * crtbegin.S GCC specific: constructors/destructors are called, ... 19 * crtend.S 20 * crtn.S call to _init_after/_term_after 21 * exit 22 */ 23 24 25.section .init 26FUNCTION(_init): 27 push %rbp 28 movq %rsp, %rbp 29 30 // Preserve image ID. 31 push %rdi 32 sub $0x8, %rsp 33 34 // crtbegin.o stuff comes here 35 36.section .fini 37FUNCTION(_fini): 38 push %rbp 39 movq %rsp, %rbp 40 41 push %rdi 42 sub $0x8, %rsp 43 44 // crtend.o stuff comes here 45