--- gcc/config/svr3.h 2018/04/24 17:51:36 1.1.1.1 +++ gcc/config/svr3.h 2018/04/24 18:05:42 1.1.1.4 @@ -39,6 +39,9 @@ the Free Software Foundation, 675 Mass A appropriate define for the type of hardware that you are targeting. */ +/* Define a symbol indicating that we are using svr3.h. */ +#define USING_SVR3_H + /* Define a symbol so that libgcc* can know what sort of operating environment and assembler syntax we are targeting for. */ #define SVR3_target @@ -161,6 +164,32 @@ the Free Software Foundation, 675 Mass A #undef ASM_OUTPUT_LABELREF #define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "_%s", NAME) +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + + For most svr3 systems, the convention is that any symbol which begins + with a period is not put into the linker symbol table by the assembler. */ + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM) + +/* This is how to store into the string LABEL + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. + + For most svr3 systems, the convention is that any symbol which begins + with a period is not put into the linker symbol table by the assembler. */ + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ + sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM) + +/* We want local labels to start with period if made with asm_fprintf. */ +#undef LOCAL_LABEL_PREFIX +#define LOCAL_LABEL_PREFIX "." + /* Support const sections and the ctors and dtors sections for g++. Note that there appears to be two different ways to support const sections at the moment. You can either #define the symbol @@ -172,33 +201,51 @@ the Free Software Foundation, 675 Mass A 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 "\t.section\t.init" +#define INIT_SECTION_ASM_OP ".section\t.init" #define FINI_SECTION_ASM_OP ".section .fini,\"x\"" -#define CONST_SECTION_ASM_OP "\t.section\t.rodata, \"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. */ -#define DO_GLOBAL_CTORS_BODY \ -do { \ - func_ptr *__CTOR_LIST__ = __builtin_alloca (0), *p; \ - for (p = __CTOR_LIST__; *p; ) \ - (*p++) (); \ +/* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent + because they push on the stack. */ + +#ifdef STACK_GROWS_DOWNWARD + +/* Constructor list on stack is in reverse order. Go to the end of the + list and go backwards to call constructors in the right order. */ +#define DO_GLOBAL_CTORS_BODY \ +do { \ + func_ptr *p, *beg = alloca (0); \ + for (p = beg; *p; p++) \ + ; \ + while (p != beg) \ + (*--p) (); \ +} while (0) + +#else + +/* Constructor list on stack is in correct order. Just call them. */ +#define DO_GLOBAL_CTORS_BODY \ +do { \ + func_ptr *p, *beg = alloca (0); \ + for (p = beg; *p; ) \ + (*p++) (); \ } while (0) +#endif /* STACK_GROWS_DOWNWARD */ + /* Add extra sections .init and .fini, in addition to .bss from att386.h. */ #undef EXTRA_SECTIONS @@ -211,9 +258,20 @@ do { \ INIT_SECTION_FUNCTION \ FINI_SECTION_FUNCTION +#define BSS_SECTION_FUNCTION \ +void \ +bss_section () \ +{ \ + if (in_section != in_bss) \ + { \ + fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP); \ + in_section = in_bss; \ + } \ +} + #define INIT_SECTION_FUNCTION \ void \ -init_section () \ +init_section () \ { \ if (in_section != in_init) \ { \ @@ -249,7 +307,9 @@ const_section () \ } \ } -#if 0 +/* The ctors and dtors sections are not normally put into use + by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h, + but it can't hurt to define these macros for whatever systems use them. */ #define CTORS_SECTION_FUNCTION \ void \ ctors_section () \ @@ -271,7 +331,6 @@ dtors_section () \ in_section = in_dtors; \ } \ } -#endif /* This is machine-dependent because it needs to push something on the stack. */