From: Frediano Ziglio <frediano.ziglio@citrix.com>
To: Konrad Rzeszutek Wilk <konrad@kernel.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Frediano Ziglio <frediano.ziglio@citrix.com>, xen-devel@lists.xen.org
Subject: [PATCH v10 1/5] gcov: Call constructors during initialization
Date: Thu, 21 Feb 2013 16:13:41 +0000 [thread overview]
Message-ID: <1361463225-21750-2-git-send-email-frediano.ziglio@citrix.com> (raw)
In-Reply-To: <1361463225-21750-1-git-send-email-frediano.ziglio@citrix.com>
This allow modules to set initializer functions.
This is used by Gcc instrumentation code for profiling arcs and test
coverage.
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
---
xen/arch/arm/setup.c | 2 ++
xen/arch/arm/xen.lds.S | 7 +++++++
xen/arch/x86/setup.c | 2 ++
xen/arch/x86/xen.lds.S | 7 +++++++
xen/common/lib.c | 14 ++++++++++++++
xen/include/xen/lib.h | 2 ++
6 files changed, 34 insertions(+)
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 5a86f90..a21ae41 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 410d7db..50e0c4b 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 83335ad..a13b681 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 d324afd..5570389 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 03c8b8b..1344038 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 31e1117..74b34eb 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__ */
--
1.7.9.5
next prev parent reply other threads:[~2013-02-21 16:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-21 16:13 [PATCH v10 0/5] gcov: Coverage support Frediano Ziglio
2013-02-21 16:13 ` Frediano Ziglio [this message]
2013-02-22 8:50 ` [PATCH v10 1/5] gcov: Call constructors during initialization Ian Campbell
2013-02-22 9:40 ` Frediano Ziglio
2013-02-22 9:45 ` Ian Campbell
2013-02-21 16:13 ` [PATCH v10 2/5] gcov: Adding support for coverage information Frediano Ziglio
2013-02-21 16:13 ` [PATCH v10 3/5] gcov: Implement code to read coverage informations Frediano Ziglio
2013-02-21 16:13 ` [PATCH v10 4/5] gcov: Add small utility to deal with test coverage information from Xen Frediano Ziglio
2013-02-21 16:13 ` [PATCH v10 5/5] gcov: Add documentation for coverage Frediano Ziglio
2013-02-22 14:20 ` [PATCH v10 0/5] gcov: Coverage support George Dunlap
2013-02-22 14:35 ` Ian Campbell
2013-02-22 14:35 ` Frediano Ziglio
2013-02-22 14:39 ` Jan Beulich
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=1361463225-21750-2-git-send-email-frediano.ziglio@citrix.com \
--to=frediano.ziglio@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=konrad@kernel.org \
--cc=xen-devel@lists.xen.org \
/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.