Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/csu/common Fun fact of the weak: a weak reference doesn'...



details:   https://anonhg.NetBSD.org/src/rev/9f1e79220e54
branches:  trunk
changeset: 815900:9f1e79220e54
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Jun 07 12:07:35 2016 +0000

description:
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.

diffstat:

 lib/csu/common/crt0-common.c |  28 +++++++++++-----------------
 lib/csu/common/crtbegin.c    |  10 +++-------
 2 files changed, 14 insertions(+), 24 deletions(-)

diffs (115 lines):

diff -r 0be5619a15cc -r 9f1e79220e54 lib/csu/common/crt0-common.c
--- a/lib/csu/common/crt0-common.c      Tue Jun 07 11:20:45 2016 +0000
+++ b/lib/csu/common/crt0-common.c      Tue Jun 07 12:07:35 2016 +0000
@@ -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 @@
  * 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 @@
 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 @@
 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)();
        }
 }
diff -r 0be5619a15cc -r 9f1e79220e54 lib/csu/common/crtbegin.c
--- a/lib/csu/common/crtbegin.c Tue Jun 07 11:20:45 2016 +0000
+++ b/lib/csu/common/crtbegin.c Tue Jun 07 12:07:35 2016 +0000
@@ -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 @@
 #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 @@
                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 @@
 #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 @@
 #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



Home | Main Index | Thread Index | Old Index