diff options
-rw-r--r-- | xen/arch/arm/setup.c | 2 | ||||
-rw-r--r-- | xen/arch/arm/xen.lds.S | 7 | ||||
-rw-r--r-- | xen/arch/x86/setup.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/xen.lds.S | 7 | ||||
-rw-r--r-- | xen/common/lib.c | 14 | ||||
-rw-r--r-- | xen/include/xen/lib.h | 2 |
6 files changed, 34 insertions, 0 deletions
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 43a69eb72a..e07c1cb532 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -442,6 +442,8 @@ void __init start_xen(unsigned long boot_phys_offset, scrub_heap_pages(); */ + init_constructors(); + console_endboot(); /* Hide UART from DOM0 if we're using it */ diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 410d7dbcf3..50e0c4b2c8 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -84,6 +84,13 @@ SECTIONS *(.init.data) *(.init.data.rel) *(.init.data.rel.*) + + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 55666c7627..43301a5360 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1378,6 +1378,8 @@ void __init __start_xen(unsigned long mbi_p) init_trace_bufs(); + init_constructors(); + console_endboot(); /* Hide UART from DOM0 if we're using it */ diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index d324afdd67..55703896e3 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -108,6 +108,13 @@ SECTIONS __trampoline_seg_start = .; *(.trampoline_seg) __trampoline_seg_stop = .; + + . = ALIGN(8); + __CTOR_LIST__ = .; + QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) + *(.ctors) + QUAD(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : { diff --git a/xen/common/lib.c b/xen/common/lib.c index 018345ebbd..e0c65cfec3 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -2,6 +2,7 @@ #include <xen/ctype.h> #include <xen/lib.h> #include <xen/types.h> +#include <xen/init.h> #include <asm/byteorder.h> /* for ctype.h */ @@ -478,6 +479,19 @@ unsigned long long parse_size_and_unit(const char *s, const char **ps) return ret; } +extern const struct +{ + unsigned long count; + void (*funcs[1])(void); +} __CTOR_LIST__; + +void __init init_constructors(void) +{ + unsigned long n; + for ( n = 0; n < __CTOR_LIST__.count; ++n ) + __CTOR_LIST__.funcs[n](); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 31e1117446..74b34eb932 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -127,4 +127,6 @@ extern void add_taint(unsigned); struct cpu_user_regs; void dump_execstate(struct cpu_user_regs *); +void init_constructors(void); + #endif /* __LIB_H__ */ |