From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: Xen-devel@lists.xensource.com
Subject: [PATCH] stubdom: support constructors and destructors
Date: Thu, 22 May 2008 12:44:07 +0100 [thread overview]
Message-ID: <20080522114407.GA4845@implementation.uk.xensource.com> (raw)
stubdom: support constructors and destructors
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
diff -r 9c41853c71a1 extras/mini-os/arch/ia64/minios-ia64.lds
--- a/extras/mini-os/arch/ia64/minios-ia64.lds Fri May 09 16:14:27 2008 +0100
+++ b/extras/mini-os/arch/ia64/minios-ia64.lds Thu May 22 11:25:43 2008 +0100
@@ -52,6 +52,23 @@
.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 -r 9c41853c71a1 extras/mini-os/arch/x86/minios-x86_32.lds
--- a/extras/mini-os/arch/x86/minios-x86_32.lds Fri May 09 16:14:27 2008 +0100
+++ b/extras/mini-os/arch/x86/minios-x86_32.lds Thu May 22 11:25:43 2008 +0100
@@ -28,9 +28,25 @@
.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 -r 9c41853c71a1 extras/mini-os/arch/x86/minios-x86_64.lds
--- a/extras/mini-os/arch/x86/minios-x86_64.lds Fri May 09 16:14:27 2008 +0100
+++ b/extras/mini-os/arch/x86/minios-x86_64.lds Thu May 22 11:25:43 2008 +0100
@@ -28,9 +28,25 @@
.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 -r 9c41853c71a1 extras/mini-os/main.c
--- a/extras/mini-os/main.c Fri May 09 16:14:27 2008 +0100
+++ b/extras/mini-os/main.c Thu May 22 11:25:44 2008 +0100
@@ -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 @@
__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 @@
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);
reply other threads:[~2008-05-22 11:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080522114407.GA4845@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=Xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.