login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
May
»
6
Re: [RFC PATCH 1/6] kernel: call constructors
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Andrew Morton
Subject:
Re: [RFC PATCH 1/6] kernel: call constructors
Date: Monday, May 5, 2008 - 9:19 pm
On Mon, 05 May 2008 17:24:04 +0200 Peter Oberparleiter <peter.oberparleiter@de.ibm.com> wrote:
quoted text
> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com> > > Call constructors during kernel init and module load. Required by the > gcov profiling infrastructure: gcc's profiling code uses constructors > to register profiling data structures. >
Looks sane.
quoted text
> --- > arch/powerpc/kernel/vmlinux.lds.S | 3 +++ > include/asm-generic/sections.h | 1 + > include/asm-generic/vmlinux.lds.h | 8 ++++++++ > include/linux/module.h | 5 +++++ > init/main.c | 10 ++++++++++ > kernel/module.c | 13 +++++++++++++ > 6 files changed, 40 insertions(+) > > Index: linux-2.6.26-rc1/include/asm-generic/vmlinux.lds.h > =================================================================== > --- linux-2.6.26-rc1.orig/include/asm-generic/vmlinux.lds.h > +++ linux-2.6.26-rc1/include/asm-generic/vmlinux.lds.h > @@ -352,3 +352,11 @@ > *(.data.percpu.shared_aligned) \ > } \ > __per_cpu_end = .; > + > +#define CONSTRUCTORS \ > + __CTOR_LIST__ = .; \ > + *(.ctors) \ > + __CTOR_END__ = .; \ > + __DTOR_LIST__ = .; \ > + *(.dtors) \ > + __DTOR_END__ = .; > Index: linux-2.6.26-rc1/arch/powerpc/kernel/vmlinux.lds.S > =================================================================== > --- linux-2.6.26-rc1.orig/arch/powerpc/kernel/vmlinux.lds.S > +++ linux-2.6.26-rc1/arch/powerpc/kernel/vmlinux.lds.S > @@ -193,6 +193,9 @@ SECTIONS > *(.toc) > } > #endif > + .data.gcov : { > + CONSTRUCTORS > + }
Why did powerpc (and only powerpc) need this touchup? It already includes asm-generic/vmlinux.lds.h?
quoted text
> . = ALIGN(PAGE_SIZE); > _edata = .; > Index: linux-2.6.26-rc1/include/asm-generic/sections.h > =================================================================== > --- linux-2.6.26-rc1.orig/include/asm-generic/sections.h > +++ linux-2.6.26-rc1/include/asm-generic/sections.h > @@ -13,5 +13,6 @@ extern char __per_cpu_start[], __per_cpu > extern char __kprobes_text_start[], __kprobes_text_end[]; > extern char __initdata_begin[], __initdata_end[]; > extern char __start_rodata[], __end_rodata[]; > +extern char __CTOR_LIST__[], __CTOR_END__[]; > > #endif /* _ASM_GENERIC_SECTIONS_H_ */ > Index: linux-2.6.26-rc1/include/linux/module.h > =================================================================== > --- linux-2.6.26-rc1.orig/include/linux/module.h > +++ linux-2.6.26-rc1/include/linux/module.h > @@ -229,6 +229,8 @@ enum module_state > MODULE_STATE_GOING, > }; > > +typedef void (*ctorcall_t)(void); > + > struct module > { > enum module_state state; > @@ -342,6 +344,9 @@ struct module > struct marker *markers; > unsigned int num_markers; > #endif > + /* Constructor calls. */ > + ctorcall_t *ctors; > + unsigned long num_ctors; > }; > #ifndef MODULE_ARCH_INIT > #define MODULE_ARCH_INIT {} > Index: linux-2.6.26-rc1/kernel/module.c > =================================================================== > --- linux-2.6.26-rc1.orig/kernel/module.c > +++ linux-2.6.26-rc1/kernel/module.c > @@ -1736,6 +1736,7 @@ static struct module *load_module(void _ > unsigned int unusedgplcrcindex; > unsigned int markersindex; > unsigned int markersstringsindex; > + unsigned int ctorsindex; > struct module *mod; > long err = 0; > void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ > @@ -1832,6 +1833,7 @@ static struct module *load_module(void _ > #ifdef ARCH_UNWIND_SECTION_NAME > unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME); > #endif > + ctorsindex = find_sec(hdr, sechdrs, secstrings, ".ctors"); > > /* Don't keep modinfo and version sections. */ > sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC; > @@ -2041,6 +2043,8 @@ static struct module *load_module(void _ > mod->num_markers = > sechdrs[markersindex].sh_size / sizeof(*mod->markers); > #endif > + mod->ctors = (void *) sechdrs[ctorsindex].sh_addr; > + mod->num_ctors = sechdrs[ctorsindex].sh_size / sizeof(*mod->ctors); > > /* Find duplicate symbols */ > err = verify_export_symbols(mod); > @@ -2153,6 +2157,14 @@ static struct module *load_module(void _ > goto free_hdr; > } > > +static void do_mod_ctors(struct module *mod) > +{ > + unsigned long i; > + > + for (i = 0; i < mod->num_ctors; i++) > + mod->ctors[i](); > +} > + > /* This is where the real work happens */ > asmlinkage long > sys_init_module(void __user *umod, > @@ -2183,6 +2195,7 @@ sys_init_module(void __user *umod, > blocking_notifier_call_chain(&module_notify_list, > MODULE_STATE_COMING, mod); > > + do_mod_ctors(mod); > /* Start the module */ > if (mod->init != NULL) > ret = mod->init(); > Index: linux-2.6.26-rc1/init/main.c > =================================================================== > --- linux-2.6.26-rc1.orig/init/main.c > +++ linux-2.6.26-rc1/init/main.c > @@ -683,6 +683,15 @@ asmlinkage void __init start_kernel(void > rest_init(); > } > > +static void __init do_ctors(void) > +{ > + ctorcall_t *call; > + > + for (call = (ctorcall_t *) __CTOR_LIST__; > + call < (ctorcall_t *) __CTOR_END__; call++) > + (*call)(); > +} > + > static int __initdata initcall_debug; > > static int __init initcall_debug_setup(char *str) > @@ -760,6 +769,7 @@ static void __init do_basic_setup(void) > usermodehelper_init(); > driver_init(); > init_irq_proc(); > + do_ctors(); > do_initcalls(); > } > >
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[RFC PATCH 1/6] kernel: call constructors
, Peter Oberparleiter
, (Mon May 5, 8:24 am)
Re: [RFC PATCH 1/6] kernel: call constructors
, Sam Ravnborg
, (Mon May 5, 12:53 pm)
Re: [RFC PATCH 1/6] kernel: call constructors
, Andrew Morton
, (Mon May 5, 9:19 pm)
Re: [RFC PATCH 1/6] kernel: call constructors
, Peter Oberparleiter
, (Tue May 6, 4:50 am)
Re: [RFC PATCH 1/6] kernel: call constructors
, Peter Oberparleiter
, (Tue May 6, 4:56 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Stefan Richter
Re: sata & scsi suggestion for make menuconfig
Greg Kroah-Hartman
[PATCH 20/36] Driver core: Call device_pm_add() after bus_add_device() in device_a...
Rafael J. Wysocki
[Bug #11409] build issue #564 for v2.6.27-rc4 : undefined reference to `NS8390p_in...
Andrew Morton
2.6.23-rc6-mm1
Paul E. McKenney
Re: [PATCH, RFC, tip/core/rcu] scalable classic RCU implementation
git
:
Christian Stimming
git-gui: Fix broken revert confirmation.
Junio C Hamano
Re: git-svnimport
Anuj Gakhar
Git Architecture Question
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
linux-netdev
:
Gerrit Renker
v2 [PATCH 1/4] dccp: Limit feature negotiation to connection setup phase
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Ingo Molnar
Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference
Gerrit Renker
[PATCH 37/37] dccp: Debugging functions for feature negotiation
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
[ARM] dma: use new dmabounce_sync_for_xxx() for dma_sync_single_xxx()
Linux Kernel Mailing List
MIPS: Cavium: Remove unused watchdog code.
Linux Kernel Mailing List
V4L/DVB (8976): af9015: Add USB ID for AVerMedia A309
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
openbsd-misc
:
Christophe Rioux
Implementation example of snmp
Jason Dixon
Re: any web management gui for pf ?
Nick Holland
Re: booting openbsd on eee without cd-rom
Bryan Irvine
Re: OpenBSD 4.7 Released, May 19 2010
Marco Peereboom
Re: Singularity OS
Colocation donated by:
Syndicate