From: John David Anglin Date: Wed, 19 Oct 2016 22:52:21 +0000 (+0000) Subject: pa64-hpux-lib.h: New file. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4c6d7494fca8ecc6cfb1b7b64f94b87cd954880f;p=gcc.git pa64-hpux-lib.h: New file. libgcc/ * config/pa/pa64-hpux-lib.h: New file. (EH_FRAME_SECTION_NAME): Rename to __LIBGCC_EH_FRAME_SECTION_NAME__. (DTORS_SECTION_ASM_OP): Rename to __LIBGCC_DTORS_SECTION_ASM_OP__. * config.host (tm_file): Add pa/pa64-hpux-lib.h to tm_file on hppa*64*-*-hpux11*. gcc/ * config/pa/pa64-hpux.h (PA_INIT_FRAME_DUMMY_ASM_OP): Move to config/pa/pa64-hpux-lib.h. (PA_CRTBEGIN_HACK): Likewise. (DTOR_LIST_BEGIN): Likewise. From-SVN: r241356 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e4840df2b51..2b26a38ba9e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-10-19 John David Anglin + + * config/pa/pa64-hpux.h (PA_INIT_FRAME_DUMMY_ASM_OP): Move to + config/pa/pa64-hpux-lib.h. + (PA_CRTBEGIN_HACK): Likewise. + (DTOR_LIST_BEGIN): Likewise. + 2016-10-19 Bernd Edlinger * config/arm/arm.c (arm_emit_coreregs_64bit_shift): Clear the result diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h index 88ec4909ee9..c6cbc5f582c 100644 --- a/gcc/config/pa/pa64-hpux.h +++ b/gcc/config/pa/pa64-hpux.h @@ -350,89 +350,6 @@ do { \ #undef SUPPORTS_INIT_PRIORITY #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0) -/* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use - the init and fini array sections with both the HP and GNU linkers. - The linkers setup the required dynamic entries in the dynamic segment - and the dynamic linker does the calls. This approach avoids using - collect2. - - The first hack is to implement __do_global_ctors_aux in crtbegin as - it needs to be the first entry in the init array so that it is called - last. HP got the order of the init array backwards. The DT_INIT_ARRAY - is supposed to be executed in the same order as the addresses appear in - the array. DT_FINI_ARRAY is supposed to be executed in the opposite - order. - - The second hack is a set of plabels to implement the effect of - CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and - DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than - in .init_array and .fini_array. The standard defines for .init and - .fini have the execute flag set. So, the assembler has to be hacked - to munge the standard flags for these sections to make them agree - with what the HP linker expects. With the GNU linker, we need to - used the .init_array and .fini_array sections. So, we set up for - both just in case. Once we have built the table, the linker does - the rest of the work. - - The order is significant. Placing __do_global_ctors_aux first in - the list, results in it being called last. User specified initializers, - either using the linker +init command or a plabel, run before the - initializers specified here. */ - -/* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME - is defined. */ -#if defined(EH_FRAME_SECTION_NAME) -#define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy" -#else -#define PA_INIT_FRAME_DUMMY_ASM_OP "" -#endif - -/* The following hack sets up the .init, .init_array, .fini and - .fini_array sections. */ -#define PA_CRTBEGIN_HACK \ -asm (TEXT_SECTION_ASM_OP); \ -static void __attribute__((used)) \ -__do_global_ctors_aux (void) \ -{ \ - func_ptr *p = __CTOR_LIST__; \ - while (*(p + 1)) \ - p++; \ - for (; *p != (func_ptr) -1; p--) \ - (*p) (); \ -} \ - \ -asm (HP_INIT_ARRAY_SECTION_ASM_OP); \ -asm (".align 8"); \ -asm (".dword P%__do_global_ctors_aux"); \ -asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ -asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \ -asm (".align 8"); \ -asm (".dword P%__do_global_ctors_aux"); \ -asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ -asm (HP_FINI_ARRAY_SECTION_ASM_OP); \ -asm (".align 8"); \ -asm (".dword P%__do_global_dtors_aux"); \ -asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \ -asm (".align 8"); \ -asm (".dword P%__do_global_dtors_aux") - -/* The following two variants of DTOR_LIST_BEGIN are identical to those - in crtstuff.c except for the addition of the above crtbegin hack. */ -#ifdef DTORS_SECTION_ASM_OP -#define DTOR_LIST_BEGIN \ -asm (DTORS_SECTION_ASM_OP); \ -STATIC func_ptr __DTOR_LIST__[1] \ - __attribute__ ((aligned(sizeof(func_ptr)))) \ - = { (func_ptr) (-1) }; \ -PA_CRTBEGIN_HACK -#else -#define DTOR_LIST_BEGIN \ -STATIC func_ptr __DTOR_LIST__[1] \ - __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \ - = { (func_ptr) (-1) }; \ -PA_CRTBEGIN_HACK -#endif - /* If using HP ld do not call pxdb. Use size as a program that does nothing and returns 0. /bin/true cannot be used because it is a script without an interpreter. */ @@ -442,11 +359,11 @@ PA_CRTBEGIN_HACK not use them in gthr-posix.h. */ #define GTHREAD_USE_WEAK 0 -/* We don't want undefined weak references to __register_frame_info, - __deregister_frame_info, _Jv_RegisterClasses and __cxa_finalize - introduced by crtbegin.o. The GNU linker only resolves weak - references if they appear in a shared library. Thus, it would be - impossible to create a static executable if the symbols were weak. - So, the best solution seems to be to make the symbols strong and - provide an archive library of empty stub functions. */ +/* Support attribute weak. However, the GNU linker only resolves weak + references if they appear in a shared library. Thus, it is impossible + to create a static executable containing weak symbols. This is a problem + for the various crt files in libgcc. We don't want undefined weak + references to __register_frame_info, __deregister_frame_info and + __cxa_finalize introduced by crtbegin.o. So, we provide an archive + library of empty stub functions to resolve these symbols. */ #define TARGET_ATTRIBUTE_WEAK diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index baad2c1213c..4010e972308 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2016-10-19 John David Anglin + + * config/pa/pa64-hpux-lib.h: New file. + (EH_FRAME_SECTION_NAME): Rename to __LIBGCC_EH_FRAME_SECTION_NAME__. + (DTORS_SECTION_ASM_OP): Rename to __LIBGCC_DTORS_SECTION_ASM_OP__. + * config.host (tm_file): Add pa/pa64-hpux-lib.h to tm_file on + hppa*64*-*-hpux11*. + 2016-10-18 Max Filippov * config/xtensa/t-elf (LIB2ADDEH_XTENSA_UNWIND_DW2_FDE): New diff --git a/libgcc/config.host b/libgcc/config.host index ab61d634209..4291cfef5b4 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -543,6 +543,7 @@ hppa*64*-*-hpux11*) tmake_file="$tmake_file pa/t-slibgcc-dwarf-ver" fi tmake_file="$tmake_file pa/t-slibgcc-hpux t-slibgcc-hpux" + tm_file="$tm_file pa/pa64-hpux-lib.h" extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o \ libgcc_stub.a" md_unwind_header=pa/hpux-unwind.h diff --git a/libgcc/config/pa/pa64-hpux-lib.h b/libgcc/config/pa/pa64-hpux-lib.h new file mode 100644 index 00000000000..01ad35f3db1 --- /dev/null +++ b/libgcc/config/pa/pa64-hpux-lib.h @@ -0,0 +1,101 @@ +/* Definitions of target machine for GNU compiler, for HPs running + HP-UX using the 64bit runtime model. + Copyright (C) 1999-2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +/* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use + the init and fini array sections with both the HP and GNU linkers. + The linkers setup the required dynamic entries in the dynamic segment + and the dynamic linker does the calls. This approach avoids using + collect2. + + The first hack is to implement __do_global_ctors_aux in crtbegin as + it needs to be the first entry in the init array so that it is called + last. HP got the order of the init array backwards. The DT_INIT_ARRAY + is supposed to be executed in the same order as the addresses appear in + the array. DT_FINI_ARRAY is supposed to be executed in the opposite + order. + + The second hack is a set of plabels to implement the effect of + CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and + DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than + in .init_array and .fini_array. The standard defines for .init and + .fini have the execute flag set. So, the assembler has to be hacked + to munge the standard flags for these sections to make them agree + with what the HP linker expects. With the GNU linker, we need to + used the .init_array and .fini_array sections. So, we set up for + both just in case. Once we have built the table, the linker does + the rest of the work. + The order is significant. Placing __do_global_ctors_aux first in + the list, results in it being called last. User specified initializers, + either using the linker +init command or a plabel, run before the + initializers specified here. */ + +/* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME + is defined. */ +#if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) +#define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy" +#else +#define PA_INIT_FRAME_DUMMY_ASM_OP "" +#endif + +/* The following hack sets up the .init, .init_array, .fini and + .fini_array sections. */ +#define PA_CRTBEGIN_HACK \ +asm (TEXT_SECTION_ASM_OP); \ +static void __attribute__((used)) \ +__do_global_ctors_aux (void) \ +{ \ + func_ptr *p = __CTOR_LIST__; \ + while (*(p + 1)) \ + p++; \ + for (; *p != (func_ptr) -1; p--) \ + (*p) (); \ +} \ + \ +asm (HP_INIT_ARRAY_SECTION_ASM_OP); \ +asm (".align 8"); \ +asm (".dword P%__do_global_ctors_aux"); \ +asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ +asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \ +asm (".align 8"); \ +asm (".dword P%__do_global_ctors_aux"); \ +asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ +asm (HP_FINI_ARRAY_SECTION_ASM_OP); \ +asm (".align 8"); \ +asm (".dword P%__do_global_dtors_aux"); \ +asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \ +asm (".align 8"); \ +asm (".dword P%__do_global_dtors_aux") + +/* The following two variants of DTOR_LIST_BEGIN are identical to those + in crtstuff.c except for the addition of the above crtbegin hack. */ +#ifdef __LIBGCC_DTORS_SECTION_ASM_OP__ +#define DTOR_LIST_BEGIN \ +asm (DTORS_SECTION_ASM_OP); \ +STATIC func_ptr __DTOR_LIST__[1] \ + __attribute__ ((aligned(sizeof(func_ptr)))) \ + = { (func_ptr) (-1) }; \ +PA_CRTBEGIN_HACK +#else +#define DTOR_LIST_BEGIN \ +STATIC func_ptr __DTOR_LIST__[1] \ + __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \ + = { (func_ptr) (-1) }; \ +PA_CRTBEGIN_HACK +#endif