This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Minor optimization of crt{begin,end}.o for ELF


Hi,
maybe you'd be interested in a small patch for egcs-1.1.2 that gets rid of
the
fini_dummy () and init_dumy () functions in crtbegin.o and crtend.o
generated
from crtstuff.c.
The idea: crtstuff.c contains 'asm volatile ("\n#if 0\n");' and
'asm volatile ("\n#endif");' around the code we don't want to have in the
.o
files. It is compiled with -S -o crt{begin,end}.S, which is then run trough
cpp,
which removes the code.
        Mirek
-------------------------------------------------------------------------------
diff -c /home/mirek/old_egcs/Makefile.in egcs-1.1.2/gcc/Makefile.in
*** /home/mirek/old_egcs/Makefile.in    Mon Mar  8 01:22:20 1999
--- egcs-1.1.2/gcc/Makefile.in  Sun Jul  4 00:11:53 1999
***************
*** 1215,1227 ****
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
          -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -c $(srcdir)/crtstuff.c -DCRT_BEGIN -o $(T)crtbegin$(objext)
  
  $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
          -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -c $(srcdir)/crtstuff.c -DCRT_END -o $(T)crtend$(objext)
  
  # On some systems we also want to install versions of these files
  # compiled using PIC for use in shared libraries.
--- 1215,1233 ----
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
          -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -S $(srcdir)/crtstuff.c -DCRT_BEGIN -o $(T)crtbegin.S
!       $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
!         -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -c $(T)crtbegin.S -DCRT_BEGIN -o $(T)crtbegin$(objext)
  
  $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
          -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -S $(srcdir)/crtstuff.c -DCRT_END -o $(T)crtend.S
!       $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0
\
!         -finhibit-size-directive -fno-inline-functions -fno-exceptions
$(CRTSTUFF_T_CFLAGS) \
!         -c $(T)crtend.S -DCRT_END -o $(T)crtend$(objext)
  
  # On some systems we also want to install versions of these files
  # compiled using PIC for use in shared libraries.
***************
*** 1231,1241 ****
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
          -DCRT_BEGIN -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -c $(srcdir)/crtstuff.c 
!       mv crtstuff$(objext) crtbeginS$(objext)
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
          -DCRT_END -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -c $(srcdir)/crtstuff.c -o crtendS$(objext)
        touch s-crtS
  
  # Compile the start modules crt0.o and mcrt0.o that are linked with every
program
--- 1237,1252 ----
    defaults.h frame.h gbl-ctors.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
          -DCRT_BEGIN -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -S $(srcdir)/crtstuff.c -o $(T)crtbeginS.S 
!       $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
!         -DCRT_BEGIN -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -c $(T)crtbeginS.S -o $(T)crtbeginS$(objext) 
!       $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
!         -DCRT_END -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -S $(srcdir)/crtstuff.c -o $(T)crtendS.S
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S)
\
          -DCRT_END -DCRTSTUFFS_O -finhibit-size-directive
-fno-inline-functions \
!         -fno-exceptions -g0 -c $(T)crtendS.S -o $(T)crtendS$(objext)
        touch s-crtS
  
  # Compile the start modules crt0.o and mcrt0.o that are linked with every
program
diff -c /home/mirek/old_egcs/crtstuff.c egcs-1.1.2/gcc/crtstuff.c
*** /home/mirek/old_egcs/crtstuff.c     Sat Feb 27 22:54:23 1999
--- egcs-1.1.2/gcc/crtstuff.c   Sun Jul  4 00:39:16 1999
***************
*** 189,205 ****
  
  
  /* Stick a call to __do_global_dtors_aux into the .fini section.  */
! 
  static void __attribute__ ((__unused__))
  fini_dummy ()
  {
    asm (FINI_SECTION_ASM_OP);
    __do_global_dtors_aux ();
  #ifdef FORCE_FINI_SECTION_ALIGN
    FORCE_FINI_SECTION_ALIGN;
  #endif
    asm (TEXT_SECTION_ASM_OP);
  }
  
  #ifdef EH_FRAME_SECTION_ASM_OP
  /* Stick a call to __register_frame_info into the .init section.  For
some
--- 189,208 ----
  
  
  /* Stick a call to __do_global_dtors_aux into the .fini section.  */
! asm ("\n#if 0\n");
  static void __attribute__ ((__unused__))
  fini_dummy ()
  {
+   asm volatile ("\n#endif\n");
    asm (FINI_SECTION_ASM_OP);
    __do_global_dtors_aux ();
  #ifdef FORCE_FINI_SECTION_ALIGN
    FORCE_FINI_SECTION_ALIGN;
  #endif
    asm (TEXT_SECTION_ASM_OP);
+   asm volatile ("\n#if 0\n");
  }
+ asm ("\n#endif\n");
  
  #ifdef EH_FRAME_SECTION_ASM_OP
  /* Stick a call to __register_frame_info into the .init section.  For
some
***************
*** 214,229 ****
--- 217,237 ----
      __register_frame_info (__EH_FRAME_BEGIN__, &object);
  }
  
+ asm ("\n#if 0\n");
  static void __attribute__ ((__unused__))
  init_dummy ()
  {
+   asm volatile ("\n#endif\n");
    asm (INIT_SECTION_ASM_OP);
    frame_dummy ();
  #ifdef FORCE_INIT_SECTION_ALIGN
    FORCE_INIT_SECTION_ALIGN;
  #endif
    asm (TEXT_SECTION_ASM_OP);
+   asm volatile ("\n#if 0\n");
  }
+ asm ("\n#endif\n");
+ 
  #endif /* EH_FRAME_SECTION_ASM_OP */
  
  #else  /* OBJECT_FORMAT_ELF */
***************
*** 378,386 ****
--- 386,396 ----
  
  /* Stick a call to __do_global_ctors_aux into the .init section.  */
  
+ asm ("\n#if 0\n");
  static void __attribute__ ((__unused__))
  init_dummy ()
  {
+   asm volatile ("\n#endif\n");
    asm (INIT_SECTION_ASM_OP);
    __do_global_ctors_aux ();
  #ifdef FORCE_INIT_SECTION_ALIGN
***************
*** 402,408 ****
--- 412,420 ----
      atexit ();
    }
  #endif
+   asm volatile ("\n#if 0\n");
  }
+ asm ("\n#endif\n");
  
  #else  /* OBJECT_FORMAT_ELF */
  
-------------------------------------------------------------------------------


--- CREATED BY ATC O..R..G..A..N..I..Z..E..R
--- http://email.cz <--- Get Your Free Email



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]