Files
haiku-beta6/src/kernel/glue/init_term_dyn.c
T
Axel Dörfler b8000952ca Implemented BeOS compatible startup code.
This has almost the same layout as in BeOS - the only difference is crt0.o which
is what is usually provided by crti.o/crtbegin.o/crtend.o/crtn.o. When we want to
move to GCC's crtbegin/end code, we have to introduce crti.o and crtn.o. This is
required because the crtbegin/end stuff assumes to be inserted between a function
start (crti.o) and a function end (crtn.o) - which can only be achieved with assembly,
and is therefore platform dependent.
start_dyn.c is used for executables and calls main() (among other).
init_term_dyn.c functions are called from the .init/.fini sections and search
for B_INIT/TERM_BEFORE/AFTER_FUNCTION_NAME, and execute them if they are present.
Both use BeOS compatible call scheme but add parameters to the end.
lib0.c is no longer needed, because init_term.c/crt0.c replace its functionality.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-01-13 11:18:01 +00:00

60 lines
1.5 KiB
C

/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include <user_runtime.h>
#include <image.h>
#include "init_term_dyn.h"
/* These functions are called from _init()/_fini() (in crti.S, crtn.S)
* _init/fini_before() is called before crtbegin/end code is executed,
* _init/fini_after() after this.
* crtbegin contains code to initialize all global constructors and
* probably other GCC related things.
*/
void
_init_before(image_id id, struct uspace_program_args *args)
{
void (*before)(image_id, struct uspace_program_args *);
if (args->rld_export->get_image_symbol(id, B_INIT_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
before(id, args);
}
void
_init_after(image_id id, struct uspace_program_args *args)
{
void (*after)(image_id, struct uspace_program_args *);
if (args->rld_export->get_image_symbol(id, B_INIT_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
after(id, args);
}
void
_term_before(image_id id, struct uspace_program_args *args)
{
void (*before)(image_id, struct uspace_program_args *);
if (args->rld_export->get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
before(id, args);
}
void
_term_after(image_id id, struct uspace_program_args *args)
{
void (*after)(image_id, struct uspace_program_args *);
if (args->rld_export->get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
after(id, args);
}