1 /* 2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <user_runtime.h> 8 #include <image.h> 9 10 #include "init_term_dyn.h" 11 12 13 // include the version glue -- it's separate for the kernel add-ons only 14 #include "haiku_version_glue.c" 15 16 17 /*! These functions are called from _init()/_fini() (in crti.S, crtn.S) 18 __haiku_{init,term}_before() is called before crtbegin/end code is 19 executed, __haiku_{init,term}_after() after this. crtbegin contains 20 code to initialize all global constructors and other GCC related things 21 (like exception frames). 22 */ 23 24 25 #define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function) 26 27 28 void 29 __haiku_init_before(image_id id) 30 { 31 void (*before)(image_id); 32 33 HIDDEN_FUNCTION(__haiku_init_before); 34 35 if (get_image_symbol(id, B_INIT_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, 36 (void**)&before) == B_OK) { 37 before(id); 38 } 39 } 40 41 42 void 43 __haiku_init_after(image_id id) 44 { 45 void (*after)(image_id); 46 47 HIDDEN_FUNCTION(__haiku_init_after); 48 49 if (get_image_symbol(id, B_INIT_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, 50 (void**)&after) == B_OK) { 51 after(id); 52 } 53 } 54 55 56 void 57 __haiku_term_before(image_id id) 58 { 59 void (*before)(image_id); 60 61 HIDDEN_FUNCTION(__haiku_term_before); 62 63 if (get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, 64 (void**)&before) == B_OK) { 65 before(id); 66 } 67 } 68 69 70 void 71 __haiku_term_after(image_id id) 72 { 73 void (*after)(image_id); 74 75 HIDDEN_FUNCTION(__haiku_term_after); 76 77 if (get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, 78 (void**)&after) == B_OK) { 79 after(id); 80 } 81 } 82