aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-05-22 15:09:08 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-05-22 15:09:08 +0100
commitcf6e75bd080e50f674954e7dbfd4d4e0c33416ec (patch)
tree03ac4a9d20d25a0806335d8b4c96352d4ff79e78 /extras
parent178dcab5201309e3a8f15ecc543aeb80cea0ea96 (diff)
downloadxen-cf6e75bd080e50f674954e7dbfd4d4e0c33416ec.tar.gz
xen-cf6e75bd080e50f674954e7dbfd4d4e0c33416ec.tar.bz2
xen-cf6e75bd080e50f674954e7dbfd4d4e0c33416ec.zip
stubdom: support constructors and destructors
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/mini-os/arch/ia64/minios-ia64.lds17
-rw-r--r--extras/mini-os/arch/x86/minios-x86_32.lds18
-rw-r--r--extras/mini-os/arch/x86/minios-x86_64.lds18
-rw-r--r--extras/mini-os/main.c8
4 files changed, 59 insertions, 2 deletions
diff --git a/extras/mini-os/arch/ia64/minios-ia64.lds b/extras/mini-os/arch/ia64/minios-ia64.lds
index 0b38a34e8e..3122648969 100644
--- a/extras/mini-os/arch/ia64/minios-ia64.lds
+++ b/extras/mini-os/arch/ia64/minios-ia64.lds
@@ -52,6 +52,23 @@ SECTIONS
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
+ .ctors : {
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
+ *(SORT_BY_NAME(.ctors))
+ SORT_BY_NAME(CONSTRUCTORS)
+ LONG(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
+ *(SORT_BY_NAME(.dtors))
+ LONG(0)
+ __DTOR_END__ = .;
+ }
+
.IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20)))
{ *(.IA_64.unwind_info) }
diff --git a/extras/mini-os/arch/x86/minios-x86_32.lds b/extras/mini-os/arch/x86/minios-x86_32.lds
index 9bd0b77691..40a92ee4e6 100644
--- a/extras/mini-os/arch/x86/minios-x86_32.lds
+++ b/extras/mini-os/arch/x86/minios-x86_32.lds
@@ -28,9 +28,25 @@ SECTIONS
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
+ .ctors : {
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
+ *(SORT_BY_NAME(.ctors))
+ SORT_BY_NAME(CONSTRUCTORS)
+ LONG(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
+ *(SORT_BY_NAME(.dtors))
+ LONG(0)
+ __DTOR_END__ = .;
+ }
+
.data : { /* Data */
*(.data)
- CONSTRUCTORS
}
_edata = .; /* End of data section */
diff --git a/extras/mini-os/arch/x86/minios-x86_64.lds b/extras/mini-os/arch/x86/minios-x86_64.lds
index 361b264c5e..d53d639f2f 100644
--- a/extras/mini-os/arch/x86/minios-x86_64.lds
+++ b/extras/mini-os/arch/x86/minios-x86_64.lds
@@ -28,9 +28,25 @@ SECTIONS
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
+ .ctors : {
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
+ *(SORT_BY_NAME(.ctors))
+ SORT_BY_NAME(CONSTRUCTORS)
+ LONG(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
+ *(SORT_BY_NAME(.dtors))
+ LONG(0)
+ __DTOR_END__ = .;
+ }
+
.data : { /* Data */
*(.data)
- CONSTRUCTORS
}
_edata = .; /* End of data section */
diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c
index 6e67b01138..1851469c3e 100644
--- a/extras/mini-os/main.c
+++ b/extras/mini-os/main.c
@@ -19,6 +19,8 @@
extern int main(int argc, char *argv[], char *envp[]);
extern void __libc_init_array(void);
extern void __libc_fini_array(void);
+extern unsigned long __CTOR_LIST__[];
+extern unsigned long __DTOR_LIST__[];
struct thread *main_thread;
@@ -147,6 +149,8 @@ static void call_main(void *p)
__libc_init_array();
environ = envp;
+ for (i = 1; i <= __CTOR_LIST__[0]; i++)
+ ((void((*)(void)))__CTOR_LIST__[i]) ();
tzset();
exit(main(argc, argv, envp));
@@ -154,6 +158,10 @@ static void call_main(void *p)
void _exit(int ret)
{
+ int i;
+
+ for (i = 1; i <= __DTOR_LIST__[0]; i++)
+ ((void((*)(void)))__DTOR_LIST__[i]) ();
close_all_files();
__libc_fini_array();
printk("main returned %d\n", ret);