--- gcc/config/sparc/sysv4.h 2018/04/24 18:15:09 1.1.1.2 +++ gcc/config/sparc/sysv4.h 2018/04/24 18:28:55 1.1.1.4 @@ -1,7 +1,7 @@ /* Target definitions for GNU compiler for Sparc running System V.4 - Copyright (C) 1991, 1992 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. - Written by Ron Guilmette (rfg@ncd.com). + Written by Ron Guilmette (rfg@netcom.com). This file is part of GNU CC. @@ -17,15 +17,16 @@ GNU General Public License for more deta 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ #include "sparc/sparc.h" /* Undefine some symbols which are defined in "sparc.h" but which are appropriate only for SunOS 4.x, and not for svr4. */ -#undef DBX_DEBUGGING_INFO #undef WORD_SWITCH_TAKES_ARG +#undef ASM_OUTPUT_SOURCE_LINE #undef SELECT_SECTION #undef ASM_DECLARE_FUNCTION_NAME #undef TEXT_SECTION_ASM_OP @@ -37,9 +38,8 @@ the Free Software Foundation, 675 Mass A appropriate only for typical svr4 systems, but not for the specific case of svr4 running on a Sparc. */ -#undef CTORS_SECTION_ASM_OP -#undef DTORS_SECTION_ASM_OP #undef INIT_SECTION_ASM_OP +#undef FINI_SECTION_ASM_OP #undef CONST_SECTION_ASM_OP #undef TYPE_OPERAND_FMT #undef PUSHSECTION_FORMAT @@ -56,23 +56,26 @@ the Free Software Foundation, 675 Mass A -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) \ -D__GCC_NEW_VARARGS__" -/* The specialized code which needs to appear in the .init section prior - to the prologue code for `__do_global_ctors' (see crtstuff.c). - - On Sparcs running svr4, the /usr/ccs/lib/crti.o file (with gets linked - in prior to the crtbegin.o file) has a single `save' instruction in its - .init section. That `save' instruction tries to setup a stack frame for - the sake of any subsequent code in the .init section. Unfortunately, - the size it uses for the stack frame is only a guess, and is not really - adequate for our purposes. More importantly, we independently put our - own standard function prologue (for __do_global_ctors) into the .init - section and that function prologue includes its own `save' instruction! - Thus, unless we do something to correct the situation, we'll get *two* - stack frames allocated when crt0.o calls the code in the .init section, - and havoc will ensue. The following macro definition prevents such woes. -*/ - -#define INIT_SECTION_PREAMBLE asm ("restore") +/* The native assembler can't compute differences between symbols in different + sections when generating pic code, so we must put jump tables in the + text section. */ +#define JUMP_TABLES_IN_TEXT_SECTION 1 + +/* Pass -K to the assembler when PIC. */ +#undef ASM_SPEC +#define ASM_SPEC \ + "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ + %{fpic:-K PIC} %{fPIC:-K PIC}" + +/* Must use data section for relocatable constants when pic. */ +#undef SELECT_RTX_SECTION +#define SELECT_RTX_SECTION(MODE,RTX) \ +{ \ + if (flag_pic && symbolic_operand (RTX)) \ + data_section (); \ + else \ + const_section (); \ +} /* This is the string used to begin an assembly language comment for the Sparc/svr4 assembler. */ @@ -105,7 +108,7 @@ the Free Software Foundation, 675 Mass A #undef ASM_OUTPUT_CASE_LABEL #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \ -do { ASM_OUTPUT_ALIGN ((FILE), 2); \ +do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \ ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM); \ } while (0) @@ -150,13 +153,44 @@ do { ASM_OUTPUT_ALIGN ((FILE), 2); \ #define DATA_SECTION_ASM_OP ".section\t\".data\"" #define BSS_SECTION_ASM_OP ".section\t\".bss\"" #define CONST_SECTION_ASM_OP ".section\t\".rodata\"" -#define INIT_SECTION_ASM_OP ".section\t\".init\",#alloc" -#define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc" -#define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc" - -/* If the host and target formats match, output the floats as hex. */ -#if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT -#if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN +#define INIT_SECTION_ASM_OP ".section\t\".init\"" +#define FINI_SECTION_ASM_OP ".section\t\".fini\"" + +/* Define the pseudo-ops used to switch to the .ctors and .dtors sections. + + Note that we want to give these sections the SHF_WRITE attribute + because these sections will actually contain data (i.e. tables of + addresses of functions in the current root executable or shared library + file) and, in the case of a shared library, the relocatable addresses + will have to be properly resolved/relocated (and then written into) by + the dynamic linker when it actually attaches the given shared library + to the executing process. (Note that on SVR4, you may wish to use the + `-z text' option to the ELF linker, when building a shared library, as + an additional check that you are doing everything right. But if you do + use the `-z text' option when building a shared library, you will get + errors unless the .ctors and .dtors sections are marked as writable + via the SHF_WRITE attribute.) */ + +#undef CTORS_SECTION_ASM_OP +#define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc,#write" +#undef DTORS_SECTION_ASM_OP +#define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc,#write" + +/* A C statement to output something to the assembler file to switch to section + NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or + NULL_TREE. Some target formats do not support arbitrary sections. Do not + define this macro in such cases. */ + +#undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +do { \ + if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ + fprintf (FILE, ".section\t\"%s\",#alloc,#execinstr\n", (NAME)); \ + else if ((DECL) && TREE_READONLY (DECL)) \ + fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \ + else \ + fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \ +} while (0) /* This is how to output assembly code to define a `float' constant. We always have to use a .long pseudo-op to do this because the native @@ -183,9 +217,6 @@ do { long value[2]; \ fprintf((FILE), "\t.long\t0x%x\n", value[1]); \ } while (0) -#endif /* word order matches */ -#endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */ - /* This is how to output an assembler line defining a `long double' constant. */ @@ -198,3 +229,34 @@ do { long value[4]; \ fprintf((FILE), "\t.long\t0x%x\n", value[2]); \ fprintf((FILE), "\t.long\t0x%x\n", value[3]); \ } while (0) + +/* Output assembler code to FILE to initialize this source file's + basic block profiling info, if that has not already been done. */ + +#undef FUNCTION_BLOCK_PROFILER +#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \ + do { \ + if (TARGET_MEDANY) \ + fprintf (FILE, "\tsethi %%hi(.LLPBX0),%%o0\n\tor %%0,%%lo(.LLPBX0),%%o0\n\tld [%s+%%o0],%%o1\n\ttst %%o1\n\tbne .LLPY%d\n\tadd %%o0,%s,%%o0\n\tcall __bb_init_func\n\tnop\nLPY%d:\n", \ + MEDANY_BASE_REG, (LABELNO), MEDANY_BASE_REG, (LABELNO)); \ + else \ + fprintf (FILE, "\tsethi %%hi(.LLPBX0),%%o0\n\tld [%%lo(.LLPBX0)+%%o0],%%o1\n\ttst %%o1\n\tbne LPY%d\n\tadd %%o0,%%lo(.LLPBX0),%%o0\n\tcall __bb_init_func\n\tnop\nLPY%d:\n", \ + (LABELNO), (LABELNO)); \ + } while (0) + +/* Output assembler code to FILE to increment the entry-count for + the BLOCKNO'th basic block in this source file. */ + +#undef BLOCK_PROFILER +#define BLOCK_PROFILER(FILE, BLOCKNO) \ +{ \ + int blockn = (BLOCKNO); \ + if (TARGET_MEDANY) \ + fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tor %%g1,%%lo(.LLPBX2+%d),%%g1\n\tld [%%g1+%s],%%g2\n\tadd %%g2,1,%%g2\n\tst %%g2,[%%g1+%s]\n", \ + 4 * blockn, 4 * blockn, MEDANY_BASE_REG, MEDANY_BASE_REG); \ + else \ + fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tld [%%lo(.LLPBX2+%d)+%%g1],%%g2\n\ +\tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(.LLPBX2+%d)+%%g1]\n", \ + 4 * blockn, 4 * blockn, 4 * blockn); \ +} +