ia64/xen-unstable

changeset 17704:e7eb66a4c5f7

stubdom: support constructors and destructors

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 22 15:09:08 2008 +0100 (2008-05-22)
parents f472d708b9af
children 7325ea8445cb
files extras/mini-os/arch/ia64/minios-ia64.lds extras/mini-os/arch/x86/minios-x86_32.lds extras/mini-os/arch/x86/minios-x86_64.lds extras/mini-os/main.c
line diff
     1.1 --- a/extras/mini-os/arch/ia64/minios-ia64.lds	Thu May 22 15:08:48 2008 +0100
     1.2 +++ b/extras/mini-os/arch/ia64/minios-ia64.lds	Thu May 22 15:09:08 2008 +0100
     1.3 @@ -52,6 +52,23 @@ SECTIONS
     1.4    .fini_array     : { *(.fini_array) }
     1.5    PROVIDE (__fini_array_end = .);
     1.6  
     1.7 +  .ctors : {
     1.8 +        __CTOR_LIST__ = .;
     1.9 +        LONG((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
    1.10 +        *(SORT_BY_NAME(.ctors))
    1.11 +	SORT_BY_NAME(CONSTRUCTORS)
    1.12 +        LONG(0)
    1.13 +        __CTOR_END__ = .;
    1.14 +        }
    1.15 +
    1.16 +  .dtors : {
    1.17 +        __DTOR_LIST__ = .;
    1.18 +        LONG((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
    1.19 +        *(SORT_BY_NAME(.dtors))
    1.20 +        LONG(0)
    1.21 +        __DTOR_END__ = .;
    1.22 +        }
    1.23 +
    1.24    .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20)))
    1.25    { *(.IA_64.unwind_info) }
    1.26  
     2.1 --- a/extras/mini-os/arch/x86/minios-x86_32.lds	Thu May 22 15:08:48 2008 +0100
     2.2 +++ b/extras/mini-os/arch/x86/minios-x86_32.lds	Thu May 22 15:09:08 2008 +0100
     2.3 @@ -28,9 +28,25 @@ SECTIONS
     2.4    .fini_array     : { *(.fini_array) }
     2.5    PROVIDE (__fini_array_end = .);
     2.6  
     2.7 +  .ctors : {
     2.8 +        __CTOR_LIST__ = .;
     2.9 +        LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    2.10 +        *(SORT_BY_NAME(.ctors))
    2.11 +	SORT_BY_NAME(CONSTRUCTORS)
    2.12 +        LONG(0)
    2.13 +        __CTOR_END__ = .;
    2.14 +        }
    2.15 +
    2.16 +  .dtors : {
    2.17 +        __DTOR_LIST__ = .;
    2.18 +        LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    2.19 +        *(SORT_BY_NAME(.dtors))
    2.20 +        LONG(0)
    2.21 +        __DTOR_END__ = .;
    2.22 +        }
    2.23 +
    2.24    .data : {			/* Data */
    2.25  	*(.data)
    2.26 -	CONSTRUCTORS
    2.27  	}
    2.28  
    2.29    _edata = .;			/* End of data section */
     3.1 --- a/extras/mini-os/arch/x86/minios-x86_64.lds	Thu May 22 15:08:48 2008 +0100
     3.2 +++ b/extras/mini-os/arch/x86/minios-x86_64.lds	Thu May 22 15:09:08 2008 +0100
     3.3 @@ -28,9 +28,25 @@ SECTIONS
     3.4    .fini_array     : { *(.fini_array) }
     3.5    PROVIDE (__fini_array_end = .);
     3.6  
     3.7 +  .ctors : {
     3.8 +        __CTOR_LIST__ = .;
     3.9 +        LONG((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
    3.10 +        *(SORT_BY_NAME(.ctors))
    3.11 +	SORT_BY_NAME(CONSTRUCTORS)
    3.12 +        LONG(0)
    3.13 +        __CTOR_END__ = .;
    3.14 +        }
    3.15 +
    3.16 +  .dtors : {
    3.17 +        __DTOR_LIST__ = .;
    3.18 +        LONG((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
    3.19 +        *(SORT_BY_NAME(.dtors))
    3.20 +        LONG(0)
    3.21 +        __DTOR_END__ = .;
    3.22 +        }
    3.23 +
    3.24    .data : {			/* Data */
    3.25  	*(.data)
    3.26 -	CONSTRUCTORS
    3.27  	}
    3.28  
    3.29    _edata = .;			/* End of data section */
     4.1 --- a/extras/mini-os/main.c	Thu May 22 15:08:48 2008 +0100
     4.2 +++ b/extras/mini-os/main.c	Thu May 22 15:09:08 2008 +0100
     4.3 @@ -19,6 +19,8 @@
     4.4  extern int main(int argc, char *argv[], char *envp[]);
     4.5  extern void __libc_init_array(void);
     4.6  extern void __libc_fini_array(void);
     4.7 +extern unsigned long __CTOR_LIST__[];
     4.8 +extern unsigned long __DTOR_LIST__[];
     4.9  
    4.10  struct thread *main_thread;
    4.11  
    4.12 @@ -147,6 +149,8 @@ static void call_main(void *p)
    4.13  
    4.14      __libc_init_array();
    4.15      environ = envp;
    4.16 +    for (i = 1; i <= __CTOR_LIST__[0]; i++)
    4.17 +        ((void((*)(void)))__CTOR_LIST__[i]) ();
    4.18      tzset();
    4.19  
    4.20      exit(main(argc, argv, envp));
    4.21 @@ -154,6 +158,10 @@ static void call_main(void *p)
    4.22  
    4.23  void _exit(int ret)
    4.24  {
    4.25 +    int i;
    4.26 +
    4.27 +    for (i = 1; i <= __DTOR_LIST__[0]; i++)
    4.28 +        ((void((*)(void)))__DTOR_LIST__[i]) ();
    4.29      close_all_files();
    4.30      __libc_fini_array();
    4.31      printk("main returned %d\n", ret);