Module Name: src
Committed By: joerg
Date: Tue Jun 7 12:07:35 UTC 2016
Modified Files:
src/lib/csu/common: crt0-common.c crtbegin.c
Log Message:
Fun fact of the weak: a weak reference doesn't have visibility attached.
As such, reorganize the start/end references to use a weak reference
only, if we use it to remove size knowledge. Otherwise use weak
external declarations.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/csu/common/crt0-common.c
cvs rdiff -u -r1.11 -r1.12 src/lib/csu/common/crtbegin.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/csu/common/crt0-common.c
diff -u src/lib/csu/common/crt0-common.c:1.13 src/lib/csu/common/crt0-common.c:1.14
--- src/lib/csu/common/crt0-common.c:1.13 Thu Jan 31 22:24:25 2013
+++ src/lib/csu/common/crt0-common.c Tue Jun 7 12:07:35 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $ */
+/* $NetBSD: crt0-common.c,v 1.14 2016/06/07 12:07:35 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.14 2016/06/07 12:07:35 joerg Exp $");
#include <sys/types.h>
#include <sys/exec.h>
@@ -95,23 +95,17 @@ do { \
* Since we don't need .init or .fini sections, just code them in C
* to make life easier.
*/
-__weakref_visible const fptr_t preinit_array_start[1]
- __weak_reference(__preinit_array_start);
-__weakref_visible const fptr_t preinit_array_end[1]
- __weak_reference(__preinit_array_end);
-__weakref_visible const fptr_t init_array_start[1]
- __weak_reference(__init_array_start);
-__weakref_visible const fptr_t init_array_end[1]
- __weak_reference(__init_array_end);
-__weakref_visible const fptr_t fini_array_start[1]
- __weak_reference(__fini_array_start);
-__weakref_visible const fptr_t fini_array_end[1]
- __weak_reference(__fini_array_end);
+extern const fptr_t __preinit_array_start[] __dso_hidden;
+extern const fptr_t __preinit_array_end[] __dso_hidden __weak;
+extern const fptr_t __init_array_start[] __dso_hidden;
+extern const fptr_t __init_array_end[] __dso_hidden __weak;
+extern const fptr_t __fini_array_start[] __dso_hidden;
+extern const fptr_t __fini_array_end[] __dso_hidden __weak;
static inline void
_preinit(void)
{
- for (const fptr_t *f = preinit_array_start; f < preinit_array_end; f++) {
+ for (const fptr_t *f = __preinit_array_start; f < __preinit_array_end; f++) {
(*f)();
}
}
@@ -119,7 +113,7 @@ _preinit(void)
static inline void
_init(void)
{
- for (const fptr_t *f = init_array_start; f < init_array_end; f++) {
+ for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) {
(*f)();
}
}
@@ -127,7 +121,7 @@ _init(void)
static void
_fini(void)
{
- for (const fptr_t *f = fini_array_start; f < fini_array_end; f++) {
+ for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) {
(*f)();
}
}
Index: src/lib/csu/common/crtbegin.c
diff -u src/lib/csu/common/crtbegin.c:1.11 src/lib/csu/common/crtbegin.c:1.12
--- src/lib/csu/common/crtbegin.c:1.11 Sun Jun 5 00:43:39 2016
+++ src/lib/csu/common/crtbegin.c Tue Jun 7 12:07:35 2016
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: crtbegin.c,v 1.11 2016/06/05 00:43:39 joerg Exp $");
+__RCSID("$NetBSD: crtbegin.c,v 1.12 2016/06/07 12:07:35 joerg Exp $");
#include "crtbegin.h"
@@ -41,8 +41,6 @@ __weakref_visible void Jv_RegisterClasse
#if !defined(HAVE_INITFINI_ARRAY)
__weakref_visible const fptr_t __CTOR_LIST__start
__weak_reference(__CTOR_LIST__);
-__weakref_visible const fptr_t __CTOR_LIST__end
- __weak_reference(__CTOR_LIST_END__);
__dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = {
(fptr_t) -1,
@@ -95,7 +93,7 @@ __do_global_ctors_aux(void)
Jv_RegisterClasses(__JCR_LIST__);
#if !defined(HAVE_INITFINI_ARRAY)
- for (const fptr_t *p = &__CTOR_LIST__end; p > &__CTOR_LIST__start + 1; ) {
+ for (const fptr_t *p = __CTOR_LIST_END__; p > &__CTOR_LIST__start + 1; ) {
(*(*--p))();
}
#endif
@@ -105,8 +103,6 @@ __do_global_ctors_aux(void)
#if !defined(HAVE_INITFINI_ARRAY)
__weakref_visible const fptr_t __DTOR_LIST__start
__weak_reference(__DTOR_LIST__);
-__weakref_visible const fptr_t __DTOR_LIST__end
- __weak_reference(__DTOR_LIST_END__);
__dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = {
(fptr_t) -1,
@@ -132,7 +128,7 @@ __do_global_dtors_aux(void)
#endif
#if !defined(HAVE_INITFINI_ARRAY)
- for (const fptr_t *p = &__DTOR_LIST__start + 1; p < &__DTOR_LIST__end; ) {
+ for (const fptr_t *p = &__DTOR_LIST__start + 1; p < __DTOR_LIST_END__; ) {
(*(*p++))();
}
#endif