Commit 8c5ca3b9 by Doug Evans

Initial revision

From-SVN: r13761
parent 92ad8473
/* .init/.fini section handling + C++ global constructor/destructor handling.
This file is based on crtstuff.c, sol2-crti.asm, sol2-crtn.asm.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC 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.
GNU CC 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 GNU CC; 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 file 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. */
/* Declare a pointer to void function type. */
typedef void (*func_ptr) (void);
#ifdef CRT_INIT
/* NOTE: In order to be able to support SVR4 shared libraries, we arrange
to have one set of symbols { __CTOR_LIST__, __DTOR_LIST__, __CTOR_END__,
__DTOR_END__ } per root executable and also one set of these symbols
per shared library. So in any given whole process image, we may have
multiple definitions of each of these symbols. In order to prevent
these definitions from conflicting with one another, and in order to
ensure that the proper lists are used for the initialization/finalization
of each individual shared library (respectively), we give these symbols
only internal (i.e. `static') linkage, and we also make it a point to
refer to only the __CTOR_END__ symbol in crtfini.o and the __DTOR_LIST__
symbol in crtinit.o, where they are defined. */
static func_ptr __CTOR_LIST__[1]
__attribute__ ((section (".ctors")))
= { (func_ptr) (-1) };
static func_ptr __DTOR_LIST__[1]
__attribute__ ((section (".dtors")))
= { (func_ptr) (-1) };
/* Run all the global destructors on exit from the program. */
/* Some systems place the number of pointers in the first word of the
table. On SVR4 however, that word is -1. In all cases, the table is
null-terminated. On SVR4, we start from the beginning of the list and
invoke each per-compilation-unit destructor routine in order
until we find that null.
Note that this function MUST be static. There will be one of these
functions in each root executable and one in each shared library, but
although they all have the same code, each one is unique in that it
refers to one particular associated `__DTOR_LIST__' which belongs to the
same particular root executable or shared library file. */
static void __do_global_dtors ()
asm ("__do_global_dtors") __attribute__ ((section (".text")));
static void
__do_global_dtors ()
{
func_ptr *p;
for (p = __DTOR_LIST__ + 1; *p; p++)
(*p) ();
}
/* .init section start.
This must appear at the start of the .init section. */
asm ("
.section .init,\"ax\",@progbits
.balign 4
.global __init
__init:
push fp
push lr
mv fp,sp
ld24 r0,#__fini
bl atexit
.fillinsn
");
/* .fini section start.
This must appear at the start of the .init section. */
asm ("
.section .fini,\"ax\",@progbits
.balign 4
.global __fini
__fini:
push fp
push lr
mv fp,sp
bl __do_global_dtors
.fillinsn
");
#endif /* CRT_INIT */
#ifdef CRT_FINI
/* Put a word containing zero at the end of each of our two lists of function
addresses. Note that the words defined here go into the .ctors and .dtors
sections of the crtend.o file, and since that file is always linked in
last, these words naturally end up at the very ends of the two lists
contained in these two sections. */
static func_ptr __CTOR_END__[1]
__attribute__ ((section (".ctors")))
= { (func_ptr) 0 };
static func_ptr __DTOR_END__[1]
__attribute__ ((section (".dtors")))
= { (func_ptr) 0 };
/* Run all global constructors for the program.
Note that they are run in reverse order. */
static void __do_global_ctors ()
asm ("__do_global_ctors") __attribute__ ((section (".text")));
static void
__do_global_ctors ()
{
func_ptr *p;
for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
(*p) ();
}
/* .init section end.
This must live at the end of the .init section. */
asm ("
.section .init,\"ax\",@progbits
bl __do_global_ctors
mv sp,fp
pop lr
pop fp
jmp lr
.fillinsn
");
/* .fini section end.
This must live at the end of the .fini section. */
asm ("
.section .fini,\"ax\",@progbits
mv sp,fp
pop lr
pop fp
jmp lr
.fillinsn
");
#endif /* CRT_FINI */
# lib1funcs.asm is currently empty.
CROSS_LIBGCC1 =
# These are really part of libgcc1, but this will cause them to be
# built correctly, so...
LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
# Turn off the SDA while compiling libgcc2. There are no headers for it
# and we want maximal upward compatibility here.
TARGET_LIBGCC2_CFLAGS = -G 0
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
dp-bit.c: $(srcdir)/config/fp-bit.c
cat $(srcdir)/config/fp-bit.c > dp-bit.c
# We need to use -fpic when we are using gcc to compile the routines in
# initfini.c. This is only really needed when we are going to use gcc/g++
# to produce a shared library, but since we don't know ahead of time when
# we will be doing that, we just always use -fpic when compiling the
# routines in initfini.c.
# -fpic currently isn't supported for the m32r.
CRTSTUFF_T_CFLAGS =
# .init/.fini section routines
crtinit.o: $(srcdir)/config/m32r/initfini.c $(GCC_PASSES) $(CONFIG_H)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS) \
-DCRT_INIT -finhibit-size-directive -fno-inline-functions \
-g0 -c $(srcdir)/config/m32r/initfini.c -o crtinit.o
crtfini.o: $(srcdir)/config/m32r/initfini.c $(GCC_PASSES) $(CONFIG_H)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS) \
-DCRT_FINI -finhibit-size-directive -fno-inline-functions \
-g0 -c $(srcdir)/config/m32r/initfini.c -o crtfini.o
# -mmodel={small,medium} requires separate libraries.
# We don't build libraries for the large model, instead we use the medium
# libraries. The only difference is that the large model can handle jumps
# more than 26 signed bits away.
MULTILIB_OPTIONS = mmodel=small/mmodel=medium
MULTILIB_DIRNAMES = small medium
MULTILIB_MATCHES = mmodel?medium=mmodel?large
# Set MULTILIB_EXTRA_OPTS so shipped libraries have small data in .sdata and
# SHN_M32R_SCOMMON.
# This is important for objects referenced in system header files.
MULTILIB_EXTRA_OPTS = msdata=sdata
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
/* Configuration for GNU C-compiler for the M32R processor.
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC 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.
GNU CC 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 GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* #defines that need visibility everywhere. */
#define FALSE 0
#define TRUE 1
/* This describes the machine the compiler is hosted on. */
#define HOST_BITS_PER_CHAR 8
#define HOST_BITS_PER_SHORT 16
#define HOST_BITS_PER_INT 32
#define HOST_BITS_PER_LONG 32
#define HOST_BITS_PER_LONGLONG 64
/* Doubles are stored in memory with the high order word first. This
matters when cross-compiling. */
#define HOST_WORDS_BIG_ENDIAN 1
/* target machine dependencies.
tm.h is a symbolic link to the actual target specific file. */
#include "tm.h"
/* Arguments to use with `exit'. */
#define SUCCESS_EXIT_CODE 0
#define FATAL_EXIT_CODE 33
/* If compiled with Sun CC, the use of alloca requires this #include. */
#ifndef __GNUC__
#include "alloca.h"
#endif
/* GNU C stdarg/varargs support for the M32R */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef void *__gnuc_va_list;
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
/* Common code for va_start for both varargs and stdarg. */
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#ifdef _STDARG_H /* stdarg.h support */
/* Calling __builtin_next_arg gives the proper error message if LASTARG is
not indeed the last argument. */
#define va_start(AP, LASTARG) \
(AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
#else /* varargs.h support */
#define va_alist __builtin_va_alist
/* The ... causes current_function_varargs to be set in cc1. */
#define va_dcl int __builtin_va_alist; ...
#define va_start(AP) AP=(char *) &__builtin_va_alist
#endif /* _STDARG_H */
/* Nothing needs to be done to end varargs/stdarg processing */
#define va_end(AP) ((void) 0)
/* Values returned by __builtin_classify_type. */
enum __type_class
{
__no_type_class = -1,
__void_type_class,
__integer_type_class,
__char_type_class,
__enumeral_type_class,
__boolean_type_class,
__pointer_type_class,
__reference_type_class,
__offset_type_class,
__real_type_class,
__complex_type_class,
__function_type_class,
__method_type_class,
__record_type_class,
__union_type_class,
__array_type_class,
__string_type_class,
__set_type_class,
__file_type_class,
__lang_type_class
};
/* Return whether a type is passed by reference. */
#define __va_by_reference_p(TYPE) (sizeof (TYPE) > 8)
#define va_arg(AP,TYPE) \
__extension__ (*({ \
register TYPE *__ptr; \
\
if (__va_by_reference_p (TYPE)) \
{ \
__ptr = *(TYPE **)(void *) (AP); \
(AP) = (__gnuc_va_list) ((char *) (AP) + sizeof (void *)); \
} \
else \
{ \
__ptr = (TYPE *)(void *) \
((char *) (AP) + (sizeof (TYPE) < __va_rounded_size (char) \
? __va_rounded_size (TYPE) - sizeof (TYPE) \
: 0)); \
(AP) = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)); \
} \
\
__ptr; \
}))
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment