diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/csu/arm/md_init.h | 24 | ||||
-rw-r--r-- | lib/csu/crtbegin.c | 15 | ||||
-rw-r--r-- | lib/csu/crtbeginS.c | 12 | ||||
-rw-r--r-- | lib/csu/crtend.c | 16 | ||||
-rw-r--r-- | lib/csu/crtendS.c | 12 | ||||
-rw-r--r-- | lib/csu/extern.h | 32 | ||||
-rw-r--r-- | lib/csu/hppa/md_init.h | 23 |
7 files changed, 95 insertions, 39 deletions
diff --git a/lib/csu/arm/md_init.h b/lib/csu/arm/md_init.h index 9e9aaa1fa60..30e7c991473 100644 --- a/lib/csu/arm/md_init.h +++ b/lib/csu/arm/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.9 2016/10/03 22:13:30 kettenis Exp $ */ +/* $OpenBSD: md_init.h,v 1.10 2017/01/21 00:45:13 guenther Exp $ */ /*- * Copyright (c) 2001 Ross Harvey @@ -33,6 +33,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * arm overrides these because it uses %progbits instead of @progbits + */ +#define MD_DATA_SECTION_FLAGS_SYMBOL(section, flags, type, symbol) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\""flags"\",%progbits \n" \ + " .balign 4 \n" \ + #symbol": \n" \ + " .previous") +#define MD_DATA_SECTION_SYMBOL_VALUE(section, type, symbol, value) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\"aw\",%progbits \n" \ + " .balign 4 \n" \ + #symbol": \n" \ + " .int "#value" \n" \ + " .previous") +#define MD_DATA_SECTION_FLAGS_VALUE(section, flags, value) \ + __asm(" .section "section",\""flags"\",%progbits \n" \ + " .balign 4 \n" \ + " .int "#value" \n" \ + " .previous") + #ifdef __PIC__ /* This nastyness derived from gcc3 output */ #define MD_SECT_CALL_FUNC(section, func) \ diff --git a/lib/csu/crtbegin.c b/lib/csu/crtbegin.c index 534f4dfb4a1..3d359e62e59 100644 --- a/lib/csu/crtbegin.c +++ b/lib/csu/crtbegin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbegin.c,v 1.21 2016/12/22 09:32:04 kettenis Exp $ */ +/* $OpenBSD: crtbegin.c,v 1.22 2017/01/21 00:45:13 guenther Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -56,15 +56,13 @@ void __register_frame_info(const void *begin, struct dwarf2_eh_object *ob) { } -static const char __EH_FRAME_BEGIN__[] - __attribute__((section(".eh_frame"), aligned(4))) = { }; +MD_DATA_SECTION_FLAGS_SYMBOL(".eh_frame", "a", const void *, __EH_FRAME_BEGIN__); /* * java class registration hooks */ -static void *__JCR_LIST__[] - __attribute__((section(".jcr"), aligned(sizeof(void*)))) = { }; +MD_DATA_SECTION_FLAGS_SYMBOL(".jcr", "aw", void *, __JCR_LIST__); extern void _Jv_RegisterClasses (void *) __attribute__((weak)); @@ -83,11 +81,8 @@ __asm(".hidden __dso_handle"); long __guard_local __dso_hidden __attribute__((section(".openbsd.randomdata"))); - -static init_f __CTOR_LIST__[1] - __attribute__((section(".ctors"))) = { (void *)-1 }; /* XXX */ -static init_f __DTOR_LIST__[1] - __attribute__((section(".dtors"))) = { (void *)-1 }; /* XXX */ +MD_DATA_SECTION_SYMBOL_VALUE(".ctors", init_f, __CTOR_LIST__, -1); +MD_DATA_SECTION_SYMBOL_VALUE(".dtors", init_f, __DTOR_LIST__, -1); static void __dtors(void) __used; static void __ctors(void) __used; diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c index f97d30f22b0..7cc8252e58c 100644 --- a/lib/csu/crtbeginS.c +++ b/lib/csu/crtbeginS.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbeginS.c,v 1.16 2015/04/07 01:27:06 guenther Exp $ */ +/* $OpenBSD: crtbeginS.c,v 1.17 2017/01/21 00:45:13 guenther Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -50,8 +50,7 @@ * java class registration hooks */ -static void *__JCR_LIST__[] - __attribute__((section(".jcr"), aligned(sizeof(void*)))) = { }; +MD_DATA_SECTION_FLAGS_SYMBOL(".jcr", "aw", void *, __JCR_LIST__); extern void _Jv_RegisterClasses (void *) __attribute__((weak)); @@ -94,11 +93,8 @@ pthread_atfork(void (*prep)(void), void (*parent)(void), void (*child)(void)) /* hppa doesn't permit directives in first column, so space after newline */ asm(".hidden pthread_atfork\n .weak pthread_atfork"); - -static init_f __CTOR_LIST__[1] - __attribute__((section(".ctors"))) = { (void *)-1 }; /* XXX */ -static init_f __DTOR_LIST__[1] - __attribute__((section(".dtors"))) = { (void *)-1 }; /* XXX */ +MD_DATA_SECTION_SYMBOL_VALUE(".ctors", init_f, __CTOR_LIST__, -1); +MD_DATA_SECTION_SYMBOL_VALUE(".dtors", init_f, __DTOR_LIST__, -1); static void __dtors(void) __used; static void __ctors(void) __used; diff --git a/lib/csu/crtend.c b/lib/csu/crtend.c index 6d2ea472a74..566fa0652d6 100644 --- a/lib/csu/crtend.c +++ b/lib/csu/crtend.c @@ -1,20 +1,14 @@ -/* $OpenBSD: crtend.c,v 1.11 2015/04/04 18:05:05 guenther Exp $ */ +/* $OpenBSD: crtend.c,v 1.12 2017/01/21 00:45:13 guenther Exp $ */ /* $NetBSD: crtend.c,v 1.1 1996/09/12 16:59:04 cgd Exp $ */ #include <sys/types.h> #include "md_init.h" #include "extern.h" -static init_f __CTOR_LIST__[1] - __used __attribute__((section(".ctors"))) = { (void *)0 }; /* XXX */ -static init_f __DTOR_LIST__[1] - __used __attribute__((section(".dtors"))) = { (void *)0 }; /* XXX */ - -static const int __EH_FRAME_END__[] - __used __attribute__((section(".eh_frame"), aligned(4))) = { 0 }; - -static void * __JCR_END__[] - __used __attribute__((section(".jcr"), aligned(sizeof(void*)))) = { 0 }; +MD_DATA_SECTION_FLAGS_VALUE(".ctors", "aw", 0); +MD_DATA_SECTION_FLAGS_VALUE(".dtors", "aw", 0); +MD_DATA_SECTION_FLAGS_VALUE(".eh_frame", "a", 0); +MD_DATA_SECTION_FLAGS_VALUE(".jcr", "aw", 0); MD_SECTION_EPILOGUE(".init"); MD_SECTION_EPILOGUE(".fini"); diff --git a/lib/csu/crtendS.c b/lib/csu/crtendS.c index d83e6160232..a58b304587a 100644 --- a/lib/csu/crtendS.c +++ b/lib/csu/crtendS.c @@ -1,17 +1,13 @@ -/* $OpenBSD: crtendS.c,v 1.9 2015/04/04 18:05:05 guenther Exp $ */ +/* $OpenBSD: crtendS.c,v 1.10 2017/01/21 00:45:13 guenther Exp $ */ /* $NetBSD: crtend.c,v 1.1 1997/04/16 19:38:24 thorpej Exp $ */ #include <sys/types.h> #include "md_init.h" #include "extern.h" -static init_f __CTOR_LIST__[1] - __used __attribute__((section(".ctors"))) = { (void *)0 }; /* XXX */ -static init_f __DTOR_LIST__[1] - __used __attribute__((section(".dtors"))) = { (void *)0 }; /* XXX */ - -static void * __JCR_END__[] - __used __attribute__((section(".jcr"), aligned(sizeof(void*)))) = { 0 }; +MD_DATA_SECTION_FLAGS_VALUE(".ctors", "aw", 0); +MD_DATA_SECTION_FLAGS_VALUE(".dtors", "aw", 0); +MD_DATA_SECTION_FLAGS_VALUE(".jcr", "aw", 0); MD_SECTION_EPILOGUE(".init"); MD_SECTION_EPILOGUE(".fini"); diff --git a/lib/csu/extern.h b/lib/csu/extern.h index 53d49a36788..775438fde0c 100644 --- a/lib/csu/extern.h +++ b/lib/csu/extern.h @@ -21,3 +21,35 @@ extern void __init(void); extern int main(int argc, char *argv[], char *envp[]); typedef void (*init_f)(void); + +/* + * Provide default implementations of these. Only archs with weird + * ASM stuff (hppa, arm) need to override them + */ +#ifndef MD_DATA_SECTION_FLAGS_SYMBOL +# ifdef __LP64__ +# define VALUE_ALIGN ".balign 8" +# define VALUE_DIRECTIVE ".quad" +# else +# define VALUE_ALIGN ".balign 4" +# define VALUE_DIRECTIVE ".int" +# endif +# define MD_DATA_SECTION_FLAGS_SYMBOL(section, flags, type, symbol) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\""flags"\",@progbits \n" \ + " "VALUE_ALIGN" \n" \ + #symbol": \n" \ + " .previous") +# define MD_DATA_SECTION_SYMBOL_VALUE(section, type, symbol, value) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\"aw\",@progbits \n" \ + " "VALUE_ALIGN" \n" \ + #symbol": \n" \ + " "VALUE_DIRECTIVE" "#value" \n" \ + " .previous") +# define MD_DATA_SECTION_FLAGS_VALUE(section, flags, value) \ + __asm(" .section "section",\""flags"\",@progbits \n" \ + " "VALUE_ALIGN" \n" \ + " "VALUE_DIRECTIVE" "#value" \n" \ + " .previous") +#endif diff --git a/lib/csu/hppa/md_init.h b/lib/csu/hppa/md_init.h index 92ccd465850..f916a6a913d 100644 --- a/lib/csu/hppa/md_init.h +++ b/lib/csu/hppa/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.9 2016/03/20 02:32:39 guenther Exp $ */ +/* $OpenBSD: md_init.h,v 1.10 2017/01/21 00:45:13 guenther Exp $ */ /* * Copyright (c) 2003 Dale Rahn. All rights reserved. @@ -24,6 +24,27 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* + * hppa overrides these because it has different label syntax + */ +#define MD_DATA_SECTION_FLAGS_SYMBOL(section, flags, type, symbol) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\""flags"\",@progbits \n" \ + " .balign 4 \n" \ + #symbol" \n" \ + " .previous") +#define MD_DATA_SECTION_SYMBOL_VALUE(section, type, symbol, value) \ + extern __dso_hidden type symbol[]; \ + __asm(" .section "section",\"aw\",@progbits \n" \ + " .balign 4 \n" \ + #symbol" \n" \ + " .int "#value" \n" \ + " .previous") +#define MD_DATA_SECTION_FLAGS_VALUE(section, flags, value) \ + __asm(" .section "section",\""flags"\",@progbits \n" \ + " .balign 4 \n" \ + " .int "#value" \n" \ + " .previous") #ifdef __PIC__ #define MD_SECT_CALL_FUNC(section, func) \ |