Changed our nice crt0.c to something more GCC compatible; we're not calling
the global constructors/desctructors ourselves anymore, but let GCC do that using crtbegin/end.o how it's thought to be done. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10946 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
34a71f30fe
commit
5af708a20c
@ -1,8 +1,8 @@
|
||||
SubDir OBOS_TOP src kernel glue ;
|
||||
|
||||
KernelObjects
|
||||
crt0.c
|
||||
init_term_dyn.c
|
||||
start_dyn.c
|
||||
;
|
||||
|
||||
SubInclude OBOS_TOP src kernel glue arch ;
|
||||
|
1
src/kernel/glue/arch/Jamfile
Normal file
1
src/kernel/glue/arch/Jamfile
Normal file
@ -0,0 +1 @@
|
||||
SubInclude OBOS_TOP src kernel glue arch $(OBOS_ARCH) ;
|
7
src/kernel/glue/arch/x86/Jamfile
Normal file
7
src/kernel/glue/arch/x86/Jamfile
Normal file
@ -0,0 +1,7 @@
|
||||
SubDir OBOS_TOP src kernel glue arch x86 ;
|
||||
|
||||
KernelObjects
|
||||
crti.S
|
||||
crtn.S
|
||||
;
|
||||
|
38
src/kernel/glue/arch/x86/crti.S
Normal file
38
src/kernel/glue/arch/x86/crti.S
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/** This file contains the first part of the ".init" and ".fini" sections in
|
||||
* the ELF executable.
|
||||
* The functions defined here will be called during initialization/termination
|
||||
* of the loaded executable/library. The ".init" and ".fini" sections are
|
||||
* stacked together like this:
|
||||
*
|
||||
* crti.S entry point
|
||||
* call to _init_before/_term_before
|
||||
* crtbegin.S GCC specific: constructors/destructors are called, ...
|
||||
* crtend.S
|
||||
* crtn.S call to _init_after/_term_after
|
||||
* exit
|
||||
*/
|
||||
|
||||
#define FUNCTION(x) .global x; .type x,@function; x
|
||||
|
||||
.section .init
|
||||
FUNCTION(_init):
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl 0xc(%ebp) // program args
|
||||
pushl 0x8(%ebp) // image ID
|
||||
call _init_before
|
||||
// crtbegin.o stuff comes here
|
||||
|
||||
.section .fini
|
||||
FUNCTION(_fini):
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl 0xc(%ebp) // program args
|
||||
pushl 0x8(%ebp) // image ID
|
||||
call _term_before
|
||||
// crtbegin.o stuff comes here
|
23
src/kernel/glue/arch/x86/crtn.S
Normal file
23
src/kernel/glue/arch/x86/crtn.S
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/** This file contains the final part of the ".init" and ".fini" sections in
|
||||
* the ELF executable. It is tightly connected to crti.S.
|
||||
* Have a look at crti.S to find a description of what happens here.
|
||||
*/
|
||||
|
||||
.section .init
|
||||
// the image ID and program args are still on the stack
|
||||
call _init_after
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
.section .fini
|
||||
// the image ID and program args are still on the stack
|
||||
call _term_after
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include "init_term_dyn.h"
|
||||
|
||||
|
||||
void _init(int id, void *args) __attribute__((section(".init")));
|
||||
void _fini(int id, void *args) __attribute__((section(".fini")));
|
||||
|
||||
// constructor/destructor lists as defined in the ld-script
|
||||
extern void (*__ctor_list)(void);
|
||||
extern void (*__ctor_end)(void);
|
||||
extern void (*__dtor_list)(void);
|
||||
extern void (*__dtor_end)(void);
|
||||
|
||||
|
||||
static void
|
||||
_call_ctors(void)
|
||||
{
|
||||
void (**f)(void);
|
||||
|
||||
for (f = &__ctor_list; f < &__ctor_end; f++) {
|
||||
(**f)();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_call_dtors(void)
|
||||
{
|
||||
void (**f)(void);
|
||||
|
||||
for (f = &__dtor_list; f < &__dtor_end; f++) {
|
||||
(**f)();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_init(int id, void *args)
|
||||
{
|
||||
_init_before(id, args);
|
||||
|
||||
_call_ctors();
|
||||
|
||||
_init_after(id, args);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_fini(int id, void *args)
|
||||
{
|
||||
_term_before(id, args);
|
||||
|
||||
_call_dtors();
|
||||
|
||||
_term_after(id, args);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <user_runtime.h>
|
||||
@ -10,11 +10,11 @@
|
||||
#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.
|
||||
/** These functions are called from _init()/_fini() (in crti.S, crtn.S)
|
||||
* _init/_term_before() is called before crtbegin/end code is executed,
|
||||
* _init/_term_after() after this.
|
||||
* crtbegin contains code to initialize all global constructors and
|
||||
* other GCC related things (like exception frames).
|
||||
*/
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user