[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v8 4/7] xen: use initcall_start_, ctors_start_, and more
Start making use of the following uintptr_t variables: initcall_start_, presmp_initcall_end_, initcall_end_, ctors_start_, ctors_end_, start_schedulers_array_, end_schedulers_array_, lock_profile_start_, lock_profile_end_, note_gnu_build_id_start_, note_gnu_build_id_end_ Replacing the corresponding linker symbols. It is done to avoid comparing and subtracting pointers pointing to different objects. The separation is a bit arbitrary, but all these symbols are used only within the C source file where they are declared. One meaningful change is in the calculation of NUM_SCHEDULERS. Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx> --- Changes in v8: - remove SYMBOL_HIDE - use new symbol names - changes are split differently across the patches --- xen/common/kernel.c | 11 +++++++---- xen/common/lib.c | 7 +++++-- xen/common/schedule.c | 7 ++++--- xen/common/spinlock.c | 8 +++++--- xen/common/version.c | 10 +++++----- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 5766a0f..7eea266 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -306,20 +306,23 @@ void add_taint(unsigned int flag) tainted |= flag; } -extern const initcall_t __initcall_start[], __presmp_initcall_end[], - __initcall_end[]; +extern uintptr_t initcall_start_, presmp_initcall_end_, initcall_end_; void __init do_presmp_initcalls(void) { const initcall_t *call; - for ( call = __initcall_start; call < __presmp_initcall_end; call++ ) + for ( call = (const initcall_t *)initcall_start_; + (uintptr_t)call < presmp_initcall_end_; + call++ ) (*call)(); } void __init do_initcalls(void) { const initcall_t *call; - for ( call = __presmp_initcall_end; call < __initcall_end; call++ ) + for ( call = (const initcall_t *)presmp_initcall_end_; + (uintptr_t)call < initcall_end_; + call++ ) (*call)(); } diff --git a/xen/common/lib.c b/xen/common/lib.c index 8ebec81..e228b18 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -492,12 +492,15 @@ unsigned long long parse_size_and_unit(const char *s, const char **ps) } typedef void (*ctor_func_t)(void); -extern const ctor_func_t __ctors_start[], __ctors_end[]; +extern uintptr_t ctors_start_, ctors_end_; void __init init_constructors(void) { const ctor_func_t *f; - for ( f = __ctors_start; f < __ctors_end; ++f ) + + for ( f = (const ctor_func_t *)ctors_start_; + (uintptr_t)f < ctors_end_; + ++f ) (*f)(); /* Putting this here seems as good (or bad) as any other place. */ diff --git a/xen/common/schedule.c b/xen/common/schedule.c index a957c5e..13b9558 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -67,9 +67,10 @@ DEFINE_PER_CPU(struct scheduler *, scheduler); /* Scratch space for cpumasks. */ DEFINE_PER_CPU(cpumask_t, cpumask_scratch); -extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; -#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array) -#define schedulers __start_schedulers_array +extern uintptr_t start_schedulers_array_, end_schedulers_array_; +#define NUM_SCHEDULERS ((end_schedulers_array_ - start_schedulers_array_) \ + / sizeof(const struct scheduler *)) +#define schedulers ((struct scheduler **)start_schedulers_array_) static struct scheduler __read_mostly ops; diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index 6bc52d7..766cdc1 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -318,8 +318,8 @@ struct lock_profile_anc { typedef void lock_profile_subfunc( struct lock_profile *, int32_t, int32_t, void *); -extern struct lock_profile *__lock_profile_start; -extern struct lock_profile *__lock_profile_end; +extern uintptr_t lock_profile_start_; +extern uintptr_t lock_profile_end_; static s_time_t lock_profile_start; static struct lock_profile_anc lock_profile_ancs[LOCKPROF_TYPE_N]; @@ -474,7 +474,9 @@ static int __init lock_prof_init(void) { struct lock_profile **q; - for ( q = &__lock_profile_start; q < &__lock_profile_end; q++ ) + for ( q = (struct lock_profile **)lock_profile_start_; + (uintptr_t)q < lock_profile_end_; + q++ ) { (*q)->next = lock_profile_glb_q.elem_q; lock_profile_glb_q.elem_q = *q; diff --git a/xen/common/version.c b/xen/common/version.c index 223cb52..246c96b 100644 --- a/xen/common/version.c +++ b/xen/common/version.c @@ -86,7 +86,7 @@ int xen_build_id(const void **p, unsigned int *len) #ifdef BUILD_ID /* Defined in linker script. */ -extern const Elf_Note __note_gnu_build_id_start[], __note_gnu_build_id_end[]; +extern uintptr_t note_gnu_build_id_start_, note_gnu_build_id_end_; int xen_build_id_check(const Elf_Note *n, unsigned int n_sz, const void **p, unsigned int *len) @@ -142,19 +142,19 @@ struct cv_info_pdb70 static int __init xen_build_init(void) { - const Elf_Note *n = __note_gnu_build_id_start; + const Elf_Note *n = (const Elf_Note *)note_gnu_build_id_start_; unsigned int sz; int rc; /* --build-id invoked with wrong parameters. */ - if ( __note_gnu_build_id_end <= &n[0] ) + if ( note_gnu_build_id_end_ <= (uintptr_t)&n[0] ) return -ENODATA; /* Check for full Note header. */ - if ( &n[1] >= __note_gnu_build_id_end ) + if ( (uintptr_t)&n[1] >= note_gnu_build_id_end_ ) return -ENODATA; - sz = (void *)__note_gnu_build_id_end - (void *)n; + sz = note_gnu_build_id_end_ - (uintptr_t)n; rc = xen_build_id_check(n, sz, &build_id_p, &build_id_len); -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |