From e1ff7102031f1660a3c4fb71136eb8f7aa7380a5 Mon Sep 17 00:00:00 2001 From: rth Date: Sun, 27 Jan 2002 04:18:12 +0000 Subject: [PATCH] * Makefile.in (CRTSTUFF_CFLAGS): New. (crtbegin.o, crtend.o, crtbeginS.o, crtendS.o, crtbeginT.o): Use it. * config.gcc (alpha-linux, alpha-freebsd, alpha-netbsd): Use plain crtstuff.c instead of alpha assembly version. * crtstuff.c (CRT_CALL_STATIC_FUNCTION): Rewrite to assume the entire dummy function sequence. Use FORCE_CODE_SECTION_ALIGN not FORCE_{INIT,FINI}_SECTION_ALIGN. (__do_global_dtors_aux): Mark used. (frame_dummy, __do_global_ctors_aux): Mark used. (fini_dummy, init_dummy): Remove. * config/alpha/crtbegin.asm: Remove file. * config/alpha/crtend.asm: Remove file. * config/alpha/t-crtbe: Remove file. * config/alpha/elf.h (CRT_CALL_STATIC_FUNCTION): New. (LINK_EH_SPEC): New. * config/cris/cris.h (CRT_CALL_STATIC_FUNCTION): Rewrite old FORCE_INIT_SECTION_ALIGN hack. Register __fini_start before calling constructors. * config/cris/linux.h (CRT_CALL_STATIC_FUNCTION): Undef. * config/i386/i386.h (CRT_CALL_STATIC_FUNCTION): New. * config/i386/linux.h (CRT_CALL_STATIC_FUNCTION): Replace old CRT_END_INIT_DUMMY hack. * config/i386/sol2.h (FORCE_CODE_SECTION_ALIGN): Replace FORCE_{INIT,FINI}_SECTION_ALIGN. * config/mcore/mcore-elf.h (FORCE_CODE_SECTION_ALIGN): Replace FORCE_{INIT,FINI}_SECTION_ALIGN. * config/s390/s390.h (CRT_CALL_STATIC_FUNCTION): Update for new invocation sequence. * config/sh/sh.h (CRT_CALL_STATIC_FUNCTION): Likewise. * doc/tm.texi (CRT_CALL_STATIC_FUNCTION): Update. (FORCE_CODE_SECTION_ALIGN): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49261 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 40 ++++++++ gcc/Makefile.in | 36 +++---- gcc/config.gcc | 12 ++- gcc/config/alpha/crtbegin.asm | 228 ------------------------------------------ gcc/config/alpha/crtend.asm | 113 --------------------- gcc/config/alpha/elf.h | 24 ++++- gcc/config/alpha/t-crtbe | 14 --- gcc/config/cris/cris.h | 22 ++-- gcc/config/cris/linux.h | 4 +- gcc/config/i386/i386.h | 8 ++ gcc/config/i386/linux.h | 31 +++--- gcc/config/i386/sol2.h | 6 +- gcc/config/mcore/mcore-elf.h | 6 +- gcc/config/s390/s390.h | 14 ++- gcc/config/sh/sh.h | 16 +-- gcc/crtstuff.c | 76 +++++--------- gcc/doc/tm.texi | 20 ++-- 17 files changed, 180 insertions(+), 490 deletions(-) delete mode 100644 gcc/config/alpha/crtbegin.asm delete mode 100644 gcc/config/alpha/crtend.asm delete mode 100644 gcc/config/alpha/t-crtbe diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57fd4b96403..f2a2e5db67c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,45 @@ 2002-01-26 Richard Henderson + * Makefile.in (CRTSTUFF_CFLAGS): New. + (crtbegin.o, crtend.o, crtbeginS.o, crtendS.o, crtbeginT.o): Use it. + * config.gcc (alpha-linux, alpha-freebsd, alpha-netbsd): Use plain + crtstuff.c instead of alpha assembly version. + * crtstuff.c (CRT_CALL_STATIC_FUNCTION): Rewrite to assume the + entire dummy function sequence. Use FORCE_CODE_SECTION_ALIGN + not FORCE_{INIT,FINI}_SECTION_ALIGN. + (__do_global_dtors_aux): Mark used. + (frame_dummy, __do_global_ctors_aux): Mark used. + (fini_dummy, init_dummy): Remove. + + * config/alpha/crtbegin.asm: Remove file. + * config/alpha/crtend.asm: Remove file. + * config/alpha/t-crtbe: Remove file. + * config/alpha/elf.h (CRT_CALL_STATIC_FUNCTION): New. + (LINK_EH_SPEC): New. + + * config/cris/cris.h (CRT_CALL_STATIC_FUNCTION): Rewrite old + FORCE_INIT_SECTION_ALIGN hack. Register __fini_start before + calling constructors. + * config/cris/linux.h (CRT_CALL_STATIC_FUNCTION): Undef. + + * config/i386/i386.h (CRT_CALL_STATIC_FUNCTION): New. + * config/i386/linux.h (CRT_CALL_STATIC_FUNCTION): Replace old + CRT_END_INIT_DUMMY hack. + * config/i386/sol2.h (FORCE_CODE_SECTION_ALIGN): Replace + FORCE_{INIT,FINI}_SECTION_ALIGN. + + * config/mcore/mcore-elf.h (FORCE_CODE_SECTION_ALIGN): Replace + FORCE_{INIT,FINI}_SECTION_ALIGN. + + * config/s390/s390.h (CRT_CALL_STATIC_FUNCTION): Update for new + invocation sequence. + * config/sh/sh.h (CRT_CALL_STATIC_FUNCTION): Likewise. + + * doc/tm.texi (CRT_CALL_STATIC_FUNCTION): Update. + (FORCE_CODE_SECTION_ALIGN): New. + +2002-01-26 Richard Henderson + * config/cris/cris.c (cris_print_operand): Handle 64-bit CONST_INT. 2002-01-26 Richard Henderson diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0d4bdd4ef88..835bebc6655 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -370,6 +370,10 @@ LIBGCC2_INCLUDES = # Additional target-dependent options for compiling libgcc2.a. TARGET_LIBGCC2_CFLAGS = +# Options to use when compiling crtbegin/end. +CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ + -finhibit-size-directive -fno-inline-functions -fno-exceptions + # Additional sources to handle exceptions; overridden on ia64. LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \ $(srcdir)/unwind-sjlj.c @@ -1067,42 +1071,34 @@ stmp-multilib: $(LIBGCC_DEPS) # constructors. $(T)crtbegin.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ - -finhibit-size-directive -fno-inline-functions \ - -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \ - -c $(srcdir)/crtstuff.c -DCRT_BEGIN -o $(T)crtbegin$(objext) + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ + @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN \ + -o $(T)crtbegin$(objext) $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ - -finhibit-size-directive -fno-inline-functions \ - -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \ - -c $(srcdir)/crtstuff.c -DCRT_END -o $(T)crtend$(objext) + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ + @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_END \ + -o $(T)crtend$(objext) # These are versions of crtbegin and crtend for shared libraries. $(T)crtbeginS.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ - -finhibit-size-directive -fno-inline-functions \ - -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) @inhibit_libc@ \ - -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O \ + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS_S) \ + @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O \ -o $(T)crtbeginS$(objext) $(T)crtendS.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ - -finhibit-size-directive -fno-inline-functions \ - -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) @inhibit_libc@ \ - -c $(srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O \ + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS_S) \ + @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O \ -o $(T)crtendS$(objext) # This is a version of crtbegin for -static links. $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ - -finhibit-size-directive -fno-inline-functions \ - -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \ - -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ + @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ -o $(T)crtbeginT$(objext) # Compile the start modules crt0.o and mcrt0.o that are linked with diff --git a/gcc/config.gcc b/gcc/config.gcc index 10d6e1fd732..63cef2b6c82 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -461,7 +461,8 @@ alpha*-*-linux*ecoff*) alpha*-*-linux*libc1*) tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h" target_cpu_default="MASK_GAS" - tmake_file="t-slibgcc-elf-ver t-linux t-linux-gnulibc1 alpha/t-alpha alpha/t-crtbe alpha/t-crtfm alpha/t-ieee" + tmake_file="t-slibgcc-elf-ver t-linux t-linux-gnulibc1 alpha/t-alpha alpha/t-crtfm alpha/t-ieee" + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o" gas=yes gnu_ld=yes if test x$enable_threads = xyes; then thread_file='posix' @@ -470,7 +471,8 @@ alpha*-*-linux*libc1*) alpha*-*-linux*) tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h" target_cpu_default="MASK_GAS" - tmake_file="t-slibgcc-elf-ver t-linux alpha/t-crtbe alpha/t-crtfm alpha/t-alpha alpha/t-ieee" + tmake_file="t-slibgcc-elf-ver t-linux alpha/t-crtfm alpha/t-alpha alpha/t-ieee" + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o" gas=yes gnu_ld=yes if test x$enable_threads = xyes; then thread_file='posix' @@ -479,12 +481,14 @@ alpha*-*-linux*) alpha*-*-freebsd*) tm_file="${tm_file} ${fbsd_tm_file} alpha/elf.h alpha/freebsd.h" target_cpu_default="MASK_GAS" - tmake_file="${tmake_file} alpha/t-crtbe alpha/t-crtfm alpha/t-alpha alpha/t-ieee" + tmake_file="${tmake_file} alpha/t-crtfm alpha/t-alpha alpha/t-ieee" + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o" ;; alpha*-*-netbsd*) tm_file="${tm_file} netbsd.h alpha/elf.h netbsd-elf.h alpha/netbsd.h" target_cpu_default="MASK_GAS" - tmake_file="${tmake_file} alpha/t-alpha alpha/t-crtbe alpha/t-ieee" + tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee" + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o" ;; alpha*-*-openbsd*) diff --git a/gcc/config/alpha/crtbegin.asm b/gcc/config/alpha/crtbegin.asm deleted file mode 100644 index 96725b003b5..00000000000 --- a/gcc/config/alpha/crtbegin.asm +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc. - * Contributed by Richard Henderson (rth@tamu.edu) - * - * This file 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 2, or (at your option) any - * later version. - * - * In addition to the permissions in the GNU General Public License, the - * Free Software Foundation gives you unlimited permission to link the - * compiled version of this file with other programs, and to distribute - * those programs without any restriction coming from the use of this - * file. (The General Public License restrictions do apply in other - * respects; for example, they cover modification of the file, and - * distribution when not linked into another program.) - * - * This file 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 this program; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * As a special exception, if you link this library with files - * compiled with GCC to produce an executable, this does not cause - * the resulting executable to be covered by the GNU General Public License. - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - */ - -#include "auto-host.h" - - -/* - * Heads of the constructor/destructor lists. - */ - -/* The __*TOR_LIST__ symbols are not global because when this file is used - in a shared library, we do not want the symbol to fall over to the - application's lists. */ - -.section .ctors,"aw" - .align 3 -__CTOR_LIST__: - .quad -1 - -.section .dtors,"aw" - .align 3 -__DTOR_LIST__: - .quad -1 - -.section .jcr,"aw" - .align 3 -__JCR_LIST__: - -.section .eh_frame,"aw" -__EH_FRAME_BEGIN__: - -/* - * Fragment of the ELF _fini routine that invokes our dtor cleanup. - */ - -.section .fini,"ax" - - /* Since the bits of the _fini function are spread across many - object files, each potentially with its own GP, we must - assume we need to load ours. Further, our .fini section - can easily be more than 4MB away from our .text bits so we - can't use bsr. */ - - br $29,1f -1: ldgp $29,0($29) - jsr $26,__do_global_dtors_aux - - /* Must match the alignment we got from crti.o else we get - zero-filled holes in our _fini function and then SIGILL. */ - .align 3 - -/* - * Fragment of the ELF _init routine that sets up the frame info. - */ - -.section .init,"ax" - br $29,1f -1: ldgp $29,0($29) - jsr $26,__do_frame_setup - .align 3 - -/* - * Invoke our destructors in order. - */ - -.section .sdata - -/* Support recursive calls to exit. */ - .type dtor_ptr,@object - .size dtor_ptr,4 -dtor_ptr: - .gprel32 __DTOR_LIST__ + 8 - -/* A globally unique widget for c++ local destructors to hang off. - - This has a unique value in every dso; in the main program its - value is zero. The object should be protected. This means the - instance in any dso or the main program is not used in any other - dso. The dynamic linker takes care of this. */ - - .global __dso_handle - .type __dso_handle,@object - .size __dso_handle,8 -#ifdef SHARED -.section .data - .align 3 -__dso_handle: - .quad __dso_handle -#else -.section .bss - .align 3 -__dso_handle: - .zero 8 -#endif -#ifdef HAVE_GAS_HIDDEN - .hidden __dso_handle -#endif - -.text - - .align 3 - .ent __do_global_dtors_aux - -__do_global_dtors_aux: - ldgp $29,0($27) - lda $30,-16($30) - .frame $30,16,$26,0 - stq $9,8($30) - stq $26,0($30) - .mask 0x4000200,-16 - .prologue 1 - -#ifdef SHARED - /* Do c++ local destructors. */ - lda $1,__cxa_finalize - beq $1,0f - lda $16,__dso_handle - jsr $26,__cxa_finalize - ldgp $29,0($26) -#endif - -0: lda $9,dtor_ptr - br 2f -1: stl $1,0($9) - jsr $26,($27) - ldgp $29,0($26) -2: ldl $1,0($9) - addq $1,$29,$2 - ldq $27,0($2) - addl $1,8,$1 - bne $27,1b - - /* Remove our frame info. */ - lda $1,__deregister_frame_info - beq $1,3f - lda $16,__EH_FRAME_BEGIN__ - jsr $26,__deregister_frame_info - ldgp $29,0($26) - -3: ldq $26,0($30) - ldq $9,8($30) - lda $30,16($30) - ret - - .end __do_global_dtors_aux - -/* - * Install our frame info; register java classes, if any. - */ - -.section .bss - .type frame_object,@object - .size frame_object, 48 - .align 3 -frame_object: - .zero 48 - -.text - - .align 3 - .ent __do_frame_setup - -__do_frame_setup: - ldgp $29,0($27) - lda $30,-16($30) - .frame $30,16,$26,0 - stq $26,0($30) - .mask 0x4000000,-16 - .prologue 1 - - lda $1,__register_frame_info - beq $1,0f - lda $16,__EH_FRAME_BEGIN__ - lda $17,frame_object - jsr $26,__register_frame_info - ldgp $29,0($26) - -0: lda $1,_Jv_RegisterClasses - lda $16,__JCR_LIST__ - beq $1,0f - ldq $2,8($16) - beq $2,0f - jsr $26,_Jv_RegisterClasses - ldgp $29,0($26) - -0: ldq $26,0($30) - lda $30,16($30) - ret - - .end __do_frame_setup - -.weak __register_frame_info -.weak __deregister_frame_info -#ifdef SHARED -.weak __cxa_finalize -#endif -.weak _Jv_RegisterClasses diff --git a/gcc/config/alpha/crtend.asm b/gcc/config/alpha/crtend.asm deleted file mode 100644 index 1ffd808bf60..00000000000 --- a/gcc/config/alpha/crtend.asm +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 1996, 2000 Free Software Foundation, Inc. - * Contributed by Richard Henderson (rth@tamu.edu) - * - * This file 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 2, or (at your option) any - * later version. - * - * In addition to the permissions in the GNU General Public License, the - * Free Software Foundation gives you unlimited permission to link the - * compiled version of this file with other programs, and to distribute - * those programs without any restriction coming from the use of this - * file. (The General Public License restrictions do apply in other - * respects; for example, they cover modification of the file, and - * distribution when not linked into another program.) - * - * This file 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 this program; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * As a special exception, if you link this library with files - * compiled with GCC to produce an executable, this does not cause - * the resulting executable to be covered by the GNU General Public License. - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - */ - -/* - * Tails of the constructor/destructor lists. - */ - -/* The __*TOR_END__ symbols are not global because when this file is used - in a shared library, we do not want the symbol to fall over to the - application's lists. */ - -.section .ctors,"aw" - .align 3 -__CTOR_END__: - .quad 0 - -.section .dtors,"aw" - .align 3 -__DTOR_END__: - .quad 0 - -.section .jcr,"aw" - .align 3 -__JCR_END__: - .quad 0 - -.section .eh_frame,"aw" -__FRAME_END__: - .quad 0 - -/* - * Fragment of the ELF _init routine that invokes our ctor startup - */ - -.section .init,"ax" - - /* Since the bits of the _init function are spread across many - object files, each potentially with its own GP, we must - assume we need to load ours. Further, our .init section - can easily be more than 4MB away from our .text bits so we - can't use bsr. */ - - br $29,1f -1: ldgp $29,0($29) - jsr $26,__do_global_ctors_aux - - /* Must match the alignment we got from crti.o else we get - zero-filled holes in our _init function and thense SIGILL. */ - .align 3 - -/* - * Invoke our constructors in order. - */ - -.text - - .align 3 - .ent __do_global_ctors_aux - -__do_global_ctors_aux: - ldgp $29,0($27) - lda $30,-16($30) - .frame $30,16,$26,0 - stq $9,8($30) - stq $26,0($30) - .mask 0x4000200,-16 - .prologue 1 - - lda $9,__CTOR_END__-8 - br 1f -0: jsr $26,($27) -1: ldq $27,0($9) - subq $9,8,$9 - not $27,$0 - bne $0,0b - - ldq $26,0($30) - ldq $9,8($30) - lda $30,16($30) - ret - - .end __do_global_ctors_aux diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index 7e9b4d84b4b..b4ed0d023bf 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Richard Henderson (rth@tamu.edu). @@ -642,3 +642,25 @@ do { \ alpha_this_gpdisp_sequence_number = 0) extern int alpha_this_literal_sequence_number; extern int alpha_this_gpdisp_sequence_number; + +/* Since the bits of the _init and _fini function is spread across + many object files, each potentially with its own GP, we must assume + we need to load our GP. Further, the .init/.fini section can + easily be more than 4MB away from the function to call so we can't + use bsr. */ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n" \ +" br $29,1f\n" \ +"1: ldgp $29,0($29)\n" \ +" unop\n" \ +" jsr $26," USER_LABEL_PREFIX #FUNC "\n" \ +" .align 3\n" \ +" .previous"); + +/* If we have the capability create headers for efficient EH lookup. + As of Jan 2002, only glibc 2.2.4 can actually make use of this, but + I imagine that other systems will catch up. In the meantime, it + doesn't harm to make sure that the data exists to be used later. */ +#if defined(HAVE_LD_EH_FRAME_HDR) +#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +#endif diff --git a/gcc/config/alpha/t-crtbe b/gcc/config/alpha/t-crtbe deleted file mode 100644 index 384237b1c9c..00000000000 --- a/gcc/config/alpha/t-crtbe +++ /dev/null @@ -1,14 +0,0 @@ -# Effectively disable the crtbegin/end rules using crtstuff.c -T = disable - -EXTRA_PARTS += crtbegin.o crtend.o crtbeginS.o crtendS.o - -# Assemble startup files. -crtbegin.o: $(srcdir)/config/alpha/crtbegin.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -c -o crtbegin.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm -crtend.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -c -o crtend.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtend.asm -crtbeginS.o: $(srcdir)/config/alpha/crtbegin.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -DSHARED -c -o crtbeginS.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm -crtendS.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -DSHARED -c -o crtendS.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtend.asm diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 5999bfbbf5b..f92a3b3971b 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -1451,14 +1451,20 @@ struct cum_args {int regs;}; /* We pull a little trick to register the _fini function with atexit, after (presumably) registering the eh frame info, since we don't handle _fini (a.k.a. ___fini_start) in crt0 or have a crti for "pure" ELF. */ -#ifdef CRT_BEGIN -#define FORCE_INIT_SECTION_ALIGN \ - do \ - { \ - extern void __fini__start (void); \ - atexit (__fini__start); \ - } \ - while (0) +#ifdef CRT_END +# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ +static void __attribute__((__used__)) \ +call_ ## FUNC (void) \ +{ \ + asm (SECTION_OP); \ + if (__builtin_strcmp (#FUNC, "__do_global_ctors_aux") == 0) \ + { \ + extern void __fini__start (void); \ + atexit (__fini__start); \ + } \ + FUNC (); \ + asm (TEXT_SECTION_ASM_OP); \ +} #endif /* Node: PIC */ diff --git a/gcc/config/cris/linux.h b/gcc/config/cris/linux.h index 54a1808920a..5949937ef71 100644 --- a/gcc/config/cris/linux.h +++ b/gcc/config/cris/linux.h @@ -102,8 +102,8 @@ Boston, MA 02111-1307, USA. */ /* Node: Sections */ /* GNU/Linux has crti and crtn and does not need the - FORCE_INIT_SECTION_ALIGN trick in cris.h. */ -#undef FORCE_INIT_SECTION_ALIGN + CRT_CALL_STATIC_FUNCTION trick in cris.h. */ +#undef CRT_CALL_STATIC_FUNCTION /* * Local variables: diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 4f2b9038ded..25705e6420c 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2911,6 +2911,14 @@ extern int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER]; #define ASM_SIMPLIFY_DWARF_ADDR(X) \ i386_simplify_dwarf_addr (X) + +/* Switch to init or fini section via SECTION_OP, emit a call to FUNC, + and switch back. For x86 we do this only to save a few bytes that + would otherwise be unused in the text section. */ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n\t" \ + "call " USER_LABEL_PREFIX #FUNC "\n" \ + TEXT_SECTION_ASM_OP); /* Print operand X (an rtx) in assembler syntax to file FILE. CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 63006b37186..de634d3a4e7 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -1,5 +1,6 @@ /* Definitions for Intel 386 running Linux-based GNU systems with ELF format. - Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002 + Free Software Foundation, Inc. Contributed by Eric Youngdale. Modified for stabs-in-ELF by H.J. Lu. @@ -167,20 +168,20 @@ Boston, MA 02111-1307, USA. */ #if defined(__PIC__) && defined (USE_GNULIBC_1) /* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr, - __environ and atexit (). We have to make sure they are in the .dynsym - section. We accomplish it by making a dummy call here. This - code is never reached. */ - -#define CRT_END_INIT_DUMMY \ - do \ - { \ - extern void *___brk_addr; \ - extern char **__environ; \ - \ - ___brk_addr = __environ; \ - atexit (0); \ - } \ - while (0) + __environ and atexit. We have to make sure they are in the .dynsym + section. We do this by forcing the assembler to create undefined + references to these symbols in the object file. */ +#undef CRT_CALL_STATIC_FUNCTION +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n\t" \ + "call " USER_LABEL_PREFIX #FUNC "\n" \ + TEXT_SECTION_ASM_OP "\n\t" \ + ".extern ___brk_addr\n\t" \ + ".type ___brk_addr,@object\n\t" \ + ".extern __environ\n\t" \ + ".type __environ,@object\n\t" \ + ".extern atexit\n\t" \ + ".type atexit,@function"); #endif /* Handle special EH pointer encodings. Absolute, pc-relative, and diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h index ff1585e05d8..fb9d74530bd 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -1,5 +1,5 @@ /* Target definitions for GNU compiler for Intel 80386 running Solaris 2 - Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Fred Fish (fnf@cygnus.com). @@ -56,9 +56,7 @@ Boston, MA 02111-1307, USA. */ two 0x00000090 ints, which generates a segmentation violation when executed. This macro forces the assembler to do the padding, since it knows what it is doing. */ - -#define FORCE_INIT_SECTION_ALIGN asm (ALIGN_ASM_OP ## "16") -#define FORCE_FINI_SECTION_ALIGN FORCE_INIT_SECTION_ALIGN +#define FORCE_CODE_SECTION_ALIGN asm(ALIGN_ASM_OP "16"); /* Select a format to encode pointers in exception handling data. CODE is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is diff --git a/gcc/config/mcore/mcore-elf.h b/gcc/config/mcore/mcore-elf.h index 45cb3e86df1..8cb8d1b337a 100644 --- a/gcc/config/mcore/mcore-elf.h +++ b/gcc/config/mcore/mcore-elf.h @@ -1,5 +1,5 @@ /* Definitions of MCore target. - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Cygnus Solutions. This file is part of GNU CC. @@ -158,11 +158,9 @@ exports_section () \ #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!mno-lsim:-lsim} crtend.o%s crtn.o%s" - /* The subroutine calls in the .init and .fini sections create literal pools which must be jumped around... */ -#define FORCE_INIT_SECTION_ALIGN asm ("br 1f ; .literals ; 1:") -#define FORCE_FINI_SECTION_ALIGN asm ("br 1f ; .literals ; 1:") +#define FORCE_CODE_SECTION_ALIGN asm ("br 1f ; .literals ; 1:"); #undef CTORS_SECTION_ASM_OP #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\"" diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 57e39aa5f86..99e1ef98530 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -1299,15 +1299,13 @@ extern struct rtx_def *s390_compare_op0, *s390_compare_op1; /* S/390 constant pool breaks the devices in crtstuff.c to control section in where code resides. We have to write it as asm code. */ #ifndef __s390x__ -#define CRT_CALL_STATIC_FUNCTION(func) \ - if (0) \ - func (); /* ... to avoid warnings. */ \ - else \ - asm \ - ("bras\t%%r2,1f\n\ -0: .long\t" #func " - 0b\n\ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n\ + bras\t%%r2,1f\n\ +0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\ 1: l\t%%r3,0(%%r2)\n\ - bas\t%%r14,0(%%r3,%%r2)" : : : "2", "3", "cc", "memory"); + bas\t%%r14,0(%%r3,%%r2)\n\ + .previous"); #endif /* Constant Pool for all symbols operands which are changed with diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 98939decb50..0985a372bb8 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -2301,21 +2301,15 @@ extern struct rtx_def *fpscr_rtx; /* SH constant pool breaks the devices in crtstuff.c to control section in where code resides. We have to write it as asm code. */ -#define CRT_CALL_STATIC_FUNCTION(func) \ - if (0) \ - /* This avoids warnings about the static function being unused. */ \ - func (); \ - else \ - /* We should be passing FUNC to the asm statement as an asm input \ - operand, but this breaks with -fPIC. FIXME. */ \ - asm \ - ("mov.l 1f,r1\n\ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n\ + mov.l 1f,r1\n\ mova 2f,r0\n\ braf r1\n\ lds r0,pr\n\ 0: .p2align 2\n\ -1: .long " USER_LABEL_PREFIX #func " - 0b\n\ -2:") +1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\ +2:\n" TEXT_SECTION_ASM_OP); #define ALLOCATE_INITIAL_VALUE(hard_reg) \ (REGNO (hard_reg) == PR_REG \ diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c index 4c6fc58c0e6..e3b2607ea5d 100644 --- a/gcc/crtstuff.c +++ b/gcc/crtstuff.c @@ -1,7 +1,7 @@ /* Specialized bits of code needed to support construction and destruction of file-scope objects in C++ code. Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Ron Guilmette (rfg@monkeys.com). This file is part of GCC. @@ -62,8 +62,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "tsystem.h" #include "unwind-dw2-fde.h" +#ifndef FORCE_CODE_SECTION_ALIGN +# define FORCE_CODE_SECTION_ALIGN +#endif + #ifndef CRT_CALL_STATIC_FUNCTION -# define CRT_CALL_STATIC_FUNCTION(func) func () +# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ +static void __attribute__((__used__)) \ +call_ ## FUNC (void) \ +{ \ + asm (SECTION_OP); \ + FUNC (); \ + FORCE_CODE_SECTION_ALIGN \ + asm (TEXT_SECTION_ASM_OP); \ +} #endif #if defined(OBJECT_FORMAT_ELF) && defined(HAVE_LD_EH_FRAME_HDR) \ @@ -237,11 +249,11 @@ extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK; the list we left off processing, and we resume at that point, should we be re-invoked. */ -static void +static void __attribute__((used)) __do_global_dtors_aux (void) { static func_ptr *p = __DTOR_LIST__ + 1; - static int completed; + static _Bool completed; func_ptr f; if (__builtin_expect (completed, 0)) @@ -273,26 +285,15 @@ __do_global_dtors_aux (void) completed = 1; } - /* Stick a call to __do_global_dtors_aux into the .fini section. */ - -static void __attribute__ ((__unused__)) -fini_dummy (void) -{ - asm (FINI_SECTION_ASM_OP); - CRT_CALL_STATIC_FUNCTION (__do_global_dtors_aux); -#ifdef FORCE_FINI_SECTION_ALIGN - FORCE_FINI_SECTION_ALIGN; -#endif - asm (TEXT_SECTION_ASM_OP); -} +CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux) #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME) /* Stick a call to __register_frame_info into the .init section. For some reason calls with no arguments work more reliably in .init, so stick the call in another function. */ -static void +static void __attribute__((used)) frame_dummy (void) { #ifdef USE_EH_FRAME_REGISTRY @@ -322,16 +323,7 @@ frame_dummy (void) #endif /* JCR_SECTION_NAME */ } -static void __attribute__ ((__unused__)) -init_dummy (void) -{ - asm (INIT_SECTION_ASM_OP); - CRT_CALL_STATIC_FUNCTION (frame_dummy); -#ifdef FORCE_INIT_SECTION_ALIGN - FORCE_INIT_SECTION_ALIGN; -#endif - asm (TEXT_SECTION_ASM_OP); -} +CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy) #endif /* EH_FRAME_SECTION_NAME || JCR_SECTION_NAME */ #else /* OBJECT_FORMAT_ELF */ @@ -373,12 +365,10 @@ asm (INIT_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */ such a thing) so that we can properly perform the construction of file-scope static-storage C++ objects within shared libraries. */ -static void +static void __attribute__((used)) __do_global_ctors_aux (void) /* prologue goes in .init section */ { -#ifdef FORCE_INIT_SECTION_ALIGN - FORCE_INIT_SECTION_ALIGN; /* Explicit align before switch to .text */ -#endif + FORCE_CODE_SECTION_ALIGN /* explicit align before switch to .text */ asm (TEXT_SECTION_ASM_OP); /* don't put epilogue and body in .init */ DO_GLOBAL_CTORS_BODY; atexit (__do_global_dtors); @@ -486,8 +476,7 @@ STATIC void *__JCR_END__[1] #ifdef INIT_SECTION_ASM_OP #ifdef OBJECT_FORMAT_ELF - -static void +static void __attribute__((used)) __do_global_ctors_aux (void) { func_ptr *p; @@ -496,21 +485,7 @@ __do_global_ctors_aux (void) } /* Stick a call to __do_global_ctors_aux into the .init section. */ - -static void __attribute__ ((__unused__)) -init_dummy (void) -{ - asm (INIT_SECTION_ASM_OP); - CRT_CALL_STATIC_FUNCTION (__do_global_ctors_aux); -#ifdef FORCE_INIT_SECTION_ALIGN - FORCE_INIT_SECTION_ALIGN; -#endif - asm (TEXT_SECTION_ASM_OP); -#ifdef CRT_END_INIT_DUMMY - CRT_END_INIT_DUMMY; -#endif -} - +CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_ctors_aux) #else /* OBJECT_FORMAT_ELF */ /* Stick the real initialization code, followed by a normal sort of @@ -542,10 +517,7 @@ __do_global_ctors_aux (void) /* prologue goes in .text section */ atexit (__do_global_dtors); } /* epilogue and body go in .init section */ -#ifdef FORCE_INIT_SECTION_ALIGN -FORCE_INIT_SECTION_ALIGN; -#endif - +FORCE_CODE_SECTION_ALIGN asm (TEXT_SECTION_ASM_OP); #endif /* OBJECT_FORMAT_ELF */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 706cca47b4c..a7a7c5b73f9 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5458,16 +5458,24 @@ finalization code. If not defined, GCC will assume such a section does not exist. @findex CRT_CALL_STATIC_FUNCTION -@item CRT_CALL_STATIC_FUNCTION -If defined, a C statement that calls the function named as the sole -argument of this macro. This is used in @file{crtstuff.c} if -@code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls to -initialization and finalization functions from the init and fini -sections. By default, this macro is a simple function call. Some +@item CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function}) +If defined, an ASM statement that switches to a different section +via @var{section_op}, calls @var{function}, and switches back to +the text section. This is used in @file{crtstuff.c} if +@code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls +to initialization and finalization functions from the init and fini +sections. By default, this macro uses a simple function call. Some ports need hand-crafted assembly code to avoid dependencies on registers initialized in the function prologue or to ensure that constant pools don't end up too far way in the text section. +@findex FORCE_CODE_SECTION_ALIGN +@item FORCE_CODE_SECTION_ALIGN +If defined, an ASM statement that aligns a code section to some +arbitrary boundary. This is used to force all fragments of the +@code{.init} and @code{.fini} sections to have to same alignment +and thus prevent the linker from having to add any padding. + @findex EXTRA_SECTIONS @findex in_text @findex in_data -- 2.11.4.GIT