diff options
author | Tom Wood <wood@gnu.org> | 1992-03-19 20:41:45 +0000 |
---|---|---|
committer | Tom Wood <wood@gnu.org> | 1992-03-19 20:41:45 +0000 |
commit | b335c2ccab1de6da9e2a0a3b4253408036feec36 (patch) | |
tree | 835f283d52c10e4198adffd60d81eb776bc62c10 /gcc/config | |
parent | d742f26c5bb11a55364d269688ae8bb69f35c4c2 (diff) | |
download | gcc-b335c2ccab1de6da9e2a0a3b4253408036feec36.zip gcc-b335c2ccab1de6da9e2a0a3b4253408036feec36.tar.gz gcc-b335c2ccab1de6da9e2a0a3b4253408036feec36.tar.bz2 |
*** empty log message ***
From-SVN: r526
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/i386/sysv3.h | 25 | ||||
-rw-r--r-- | gcc/config/m88k/sysv3.h | 100 | ||||
-rw-r--r-- | gcc/config/svr3.h | 20 |
3 files changed, 90 insertions, 55 deletions
diff --git a/gcc/config/i386/sysv3.h b/gcc/config/i386/sysv3.h index 750e1f4..0aaa69ac 100644 --- a/gcc/config/i386/sysv3.h +++ b/gcc/config/i386/sysv3.h @@ -99,26 +99,23 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define FRAME_POINTER_REQUIRED \ (current_function_calls_setjmp || current_function_calls_longjmp) -/* Define a few machine-specific details - of the implementation of constructors. +/* Define a few machine-specific details of the implementation of + constructors. - CTORS_SECTION_ASM_OP should be defined to concatenate - the macro INIT_SECTION_ASM_OP, a newline, and a push instruction - to push a word containing 0 (or some equivalent of that). + The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN + and CTOR_LIST_END to contribute to the .init section an instruction to + push a word containing 0 (or some equivalent of that). - ASM_OUTPUT_CONSTRUCTOR should be defined - to push the address of the constructor. */ + ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the + constructor. */ #undef INIT_SECTION_ASM_OP #define INIT_SECTION_ASM_OP ".section .init,\"x\"" -#define CTORS_SECTION_ASM_OP \ - INIT_SECTION_ASM_OP "\n" \ - "\tpushl $0\n\t" \ - DATA_SECTION_ASM_OP -/* The reason we end with DATA_SECTION_ASM_OP is to prevent the - initial and final table elements (see crtstuff.c) from getting into - the .init section and causing a crash. */ +#define CTOR_LIST_BEGIN \ + asm (INIT_SECTION_ASM_OP); \ + asm ("pushl $0") +#define CTOR_LIST_END CTOR_LIST_BEGIN #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ do { \ diff --git a/gcc/config/m88k/sysv3.h b/gcc/config/m88k/sysv3.h index f0a4ecc..0662aaa 100644 --- a/gcc/config/m88k/sysv3.h +++ b/gcc/config/m88k/sysv3.h @@ -59,15 +59,38 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #undef USE_LIBG #define USE_LIBG -/* Define a few machine-specific details - of the implementation of constructors. - - CTORS_SECTION_ASM_OP should be defined to concatenate - the macro INIT_SECTION_ASM_OP, a newline, and a push instruction - to push a word containing 0 (or some equivalent of that). - - ASM_OUTPUT_CONSTRUCTOR should be defined - to push the address of the constructor. */ +/* Define a few machine-specific details of the implementation of + constructors. */ + +/* Although the .init section is used, it is not automatically invoked. */ +#define INVOKE__main + +/* State that atexit exists so __do_global_ctors will register + __do_global_dtors. */ +#define HAVE_ATEXIT + +#if (STACK_BOUNDARY / BITS_PER_UNIT) == 16 && REG_PARM_STACK_SPACE (0) == 32 +#define CTOR_LIST_BEGIN \ + asm (INIT_SECTION_ASM_OP); \ + asm ("\tsubu\t r31,r31,16"); \ + asm ("\tst\t r0,r31,32"); +#define CTOR_LIST_END +#endif + +/* ASM_OUTPUT_CONSTRUCTOR outputs code into the .init section to push the + address of the constructor. This becomes the body of __do_global_ctors + in crtstuff.c. r13 is a temporary register. */ +#undef ASM_OUTPUT_CONSTRUCTOR +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + init_section (); \ + fprintf (FILE, "\tor.u\t r13,r0,hi16("); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, ")\n\tor\t r13,r13,lo16("); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, ")\n\tsubu\t r31,r31,%d\n\tst\t r13,r31,%d\n", \ + STACK_BOUNDARY / BITS_PER_UNIT, REG_PARM_STACK_SPACE (0)); \ + } while (0) #undef DO_GLOBAL_CTORS_BODY #define DO_GLOBAL_CTORS_BODY \ @@ -77,26 +100,41 @@ do { \ (*p) (); \ } while (0) -#undef CTORS_SECTION_ASM_OP -#define CTORS_SECTION_ASM_OP \ - INIT_SECTION_ASM_OP "\n" \ - "subu\t r31,r31,16\n\tst\t r0,r31,32\n\t" \ - DATA_SECTION_ASM_OP - -/* The reason we end with DATA_SECTION_ASM_OP is to prevent the - initial and final table elements (see crtstuff.c) from getting into - the .init section and causing a crash. */ - -#undef ASM_OUTPUT_CONSTRUCTOR -#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ +#define DTOR_LIST_BEGIN \ + asm (FINI_SECTION_ASM_OP); \ + func_ptr __DTOR_LIST__[4] = { (func_ptr) (-1), (func_ptr) (-1), \ + (func_ptr) (-1), (func_ptr) (-1) } +#define DTOR_LIST_END \ + asm (FINI_SECTION_ASM_OP); \ + func_ptr __DTOR_END__[4] = { (func_ptr) 0, (func_ptr) 0, \ + (func_ptr) 0, (func_ptr) 0 } + +/* A C statement (sans semicolon) to output an element in the table of + global destructors. The table is constructed in the .fini section + so that an explicit linker script is not required. The complication + is that this section is padded with NOP instructions and to either + 8 or 16 byte alignment depending on the specific system. A clever + way to avoid trouble is to output a block of 16 bytes where the + extra words are known values (-1). */ +#undef ASM_OUTPUT_DESTRUCTOR +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ do { \ - init_section (); \ - fprintf (FILE, "\tor.u r13,r0,hi16("); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, ")\nor\t r13,r13,lo16("); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, ")\n\tsubu r31,r31,16\nst\t r13,r31,32\n"); \ - } while (0) - -#undef DTORS_SECTION_ASM_OP -#define DTORS_SECTION_ASM_OP FINI_SECTION_ASM_OP + register int i; \ + fini_section (); \ + fprintf (FILE, "\t%s\t ", ASM_LONG); \ + assemble_name (FILE,NAME); \ + fprintf (FILE, "\n"); \ + for (i = 1; i < 4; i++) \ + fprintf (FILE, "\t%s\t -1\n", ASM_LONG); \ + } while (0) + +/* Walk the list looking for the terminating zero and ignoring all values of + -1. */ +#undef DO_GLOBAL_DTORS_BODY +#define DO_GLOBAL_DTORS_BODY \ + do { \ + int i; \ + for (i = 0; __DTOR_LIST__[i] != 0; i++) \ + if (((int *)__DTOR_LIST__)[i] != -1) \ + __DTOR_LIST__[i] (); \ + } while (0) diff --git a/gcc/config/svr3.h b/gcc/config/svr3.h index 112f8c2..9e87153 100644 --- a/gcc/config/svr3.h +++ b/gcc/config/svr3.h @@ -172,25 +172,25 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. unless the specific tm.h file turns it on by defining USE_CONST_SECTION as 1. */ -/* The support for constructors and destructors depends on two - machine-specific macros that the individual tm.h file has to define: +/* Define a few machine-specific details of the implementation of + constructors. - CTORS_SECTION_ASM_OP should be defined to concatenate - the macro INIT_SECTION_ASM_OP, a newline, and a push instruction - to push a word containing 0 (or some equivalent of that). + The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN + and CTOR_LIST_END to contribute to the .init section an instruction to + push a word containing 0 (or some equivalent of that). - ASM_OUTPUT_CONSTRUCTOR should be defined - to push the address of the constructor. */ + Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */ #define USE_CONST_SECTION 0 #define INIT_SECTION_ASM_OP ".section\t.init" #define FINI_SECTION_ASM_OP ".section .fini,\"x\"" #define CONST_SECTION_ASM_OP ".section\t.rodata, \"x\"" - +#define CTORS_SECTION_ASM_OP INIT_SECTION_ASM_OP #define DTORS_SECTION_ASM_OP FINI_SECTION_ASM_OP -/* CTORS_SECTION_ASM_OP is machine-dependent - because it pushes on the stack. */ + +/* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent + because they push on the stack. */ #define DO_GLOBAL_CTORS_BODY \ do { \ |