svr4.h revision 18334
118334Speter/* Operating system specific defines to be used when targeting GCC for some 218334Speter generic System V Release 4 system. 318334Speter Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc. 418334Speter Contributed by Ron Guilmette (rfg@segfault.us.com). 518334Speter 618334SpeterThis file is part of GNU CC. 718334Speter 818334SpeterGNU CC is free software; you can redistribute it and/or modify 918334Speterit under the terms of the GNU General Public License as published by 1018334Speterthe Free Software Foundation; either version 2, or (at your option) 1118334Speterany later version. 1218334Speter 1318334SpeterGNU CC is distributed in the hope that it will be useful, 1418334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of 1518334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1618334SpeterGNU General Public License for more details. 1718334Speter 1818334SpeterYou should have received a copy of the GNU General Public License 1918334Speteralong with GNU CC; see the file COPYING. If not, write to 2018334Speterthe Free Software Foundation, 59 Temple Place - Suite 330, 2118334SpeterBoston, MA 02111-1307, USA. 2218334Speter 2318334Speter To use this file, make up a file with a name like: 2418334Speter 2518334Speter ?????svr4.h 2618334Speter 2718334Speter where ????? is replaced by the name of the basic hardware that you 2818334Speter are targeting for. Then, in the file ?????svr4.h, put something 2918334Speter like: 3018334Speter 3118334Speter #include "?????.h" 3218334Speter #include "svr4.h" 3318334Speter 3418334Speter followed by any really system-specific defines (or overrides of 3518334Speter defines) which you find that you need. For example, CPP_PREDEFINES 3618334Speter is defined here with only the defined -Dunix and -DSVR4. You should 3718334Speter probably override that in your target-specific ?????svr4.h file 3818334Speter with a set of defines that includes these, but also contains an 3918334Speter appropriate define for the type of hardware that you are targeting. 4018334Speter*/ 4118334Speter 4218334Speter/* Define a symbol indicating that we are using svr4.h. */ 4318334Speter#define USING_SVR4_H 4418334Speter 4518334Speter/* For the sake of libgcc2.c, indicate target supports atexit. */ 4618334Speter#define HAVE_ATEXIT 4718334Speter 4818334Speter/* Cpp, assembler, linker, library, and startfile spec's. */ 4918334Speter 5018334Speter/* This defines which switch letters take arguments. On svr4, most of 5118334Speter the normal cases (defined in gcc.c) apply, and we also have -h* and 5218334Speter -z* options (for the linker). Note however that there is no such 5318334Speter thing as a -T option for svr4. */ 5418334Speter 5518334Speter#define SWITCH_TAKES_ARG(CHAR) \ 5618334Speter ( (CHAR) == 'D' \ 5718334Speter || (CHAR) == 'U' \ 5818334Speter || (CHAR) == 'o' \ 5918334Speter || (CHAR) == 'e' \ 6018334Speter || (CHAR) == 'u' \ 6118334Speter || (CHAR) == 'I' \ 6218334Speter || (CHAR) == 'm' \ 6318334Speter || (CHAR) == 'L' \ 6418334Speter || (CHAR) == 'A' \ 6518334Speter || (CHAR) == 'h' \ 6618334Speter || (CHAR) == 'z') 6718334Speter 6818334Speter/* This defines which multi-letter switches take arguments. On svr4, 6918334Speter there are no such switches except those implemented by GCC itself. */ 7018334Speter 7118334Speter#define WORD_SWITCH_TAKES_ARG(STR) \ 7218334Speter (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \ 7318334Speter && strcmp (STR, "Tdata") && strcmp (STR, "Ttext") \ 7418334Speter && strcmp (STR, "Tbss")) 7518334Speter 7618334Speter/* You should redefine CPP_PREDEFINES in any file which includes this one. 7718334Speter The definition should be appropriate for the type of target system 7818334Speter involved, and it should include any -A (assertion) options which are 7918334Speter appropriate for the given target system. */ 8018334Speter#undef CPP_PREDEFINES 8118334Speter 8218334Speter/* Provide an ASM_SPEC appropriate for svr4. Here we try to support as 8318334Speter many of the specialized svr4 assembler options as seems reasonable, 8418334Speter given that there are certain options which we can't (or shouldn't) 8518334Speter support directly due to the fact that they conflict with other options 8618334Speter for other svr4 tools (e.g. ld) or with other options for GCC itself. 8718334Speter For example, we don't support the -o (output file) or -R (remove 8818334Speter input file) options because GCC already handles these things. We 8918334Speter also don't support the -m (run m4) option for the assembler because 9018334Speter that conflicts with the -m (produce load map) option of the svr4 9118334Speter linker. We do however allow passing arbitrary options to the svr4 9218334Speter assembler via the -Wa, option. 9318334Speter 9418334Speter Note that gcc doesn't allow a space to follow -Y in a -Ym,* or -Yd,* 9518334Speter option. 9618334Speter*/ 9718334Speter 9818334Speter#undef ASM_SPEC 9918334Speter#define ASM_SPEC \ 10018334Speter "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}" 10118334Speter 10218334Speter/* svr4 assemblers need the `-' (indicating input from stdin) to come after 10318334Speter the -o option (and its argument) for some reason. If we try to put it 10418334Speter before the -o option, the assembler will try to read the file named as 10518334Speter the output file in the -o option as an input file (after it has already 10618334Speter written some stuff to it) and the binary stuff contained therein will 10718334Speter cause totally confuse the assembler, resulting in many spurious error 10818334Speter messages. */ 10918334Speter 11018334Speter#undef ASM_FINAL_SPEC 11118334Speter#define ASM_FINAL_SPEC "%{pipe:-}" 11218334Speter 11318334Speter/* Under svr4, the normal location of the `ld' and `as' programs is the 11418334Speter /usr/ccs/bin directory. */ 11518334Speter 11618334Speter#undef MD_EXEC_PREFIX 11718334Speter#define MD_EXEC_PREFIX "/usr/ccs/bin/" 11818334Speter 11918334Speter/* Under svr4, the normal location of the various *crt*.o files is the 12018334Speter /usr/ccs/lib directory. */ 12118334Speter 12218334Speter#undef MD_STARTFILE_PREFIX 12318334Speter#define MD_STARTFILE_PREFIX "/usr/ccs/lib/" 12418334Speter 12518334Speter/* Provide a LIB_SPEC appropriate for svr4. Here we tack on the default 12618334Speter standard C library (unless we are building a shared library). */ 12718334Speter 12818334Speter#undef LIB_SPEC 12918334Speter#define LIB_SPEC "%{!shared:%{!symbolic:-lc}}" 13018334Speter 13118334Speter/* Provide a LIBGCC_SPEC appropriate for svr4. We also want to exclude 13218334Speter libgcc when -symbolic. */ 13318334Speter 13418334Speter#undef LIBGCC_SPEC 13518334Speter#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}" 13618334Speter 13718334Speter/* Provide an ENDFILE_SPEC appropriate for svr4. Here we tack on our own 13818334Speter magical crtend.o file (see crtstuff.c) which provides part of the 13918334Speter support for getting C++ file-scope static object constructed before 14018334Speter entering `main', followed by the normal svr3/svr4 "finalizer" file, 14118334Speter which is either `gcrtn.o' or `crtn.o'. */ 14218334Speter 14318334Speter#undef ENDFILE_SPEC 14418334Speter#define ENDFILE_SPEC "crtend.o%s %{pg:gcrtn.o}%{!pg:crtn.o%s}" 14518334Speter 14618334Speter/* Provide a LINK_SPEC appropriate for svr4. Here we provide support 14718334Speter for the special GCC options -static, -shared, and -symbolic which 14818334Speter allow us to link things in one of these three modes by applying the 14918334Speter appropriate combinations of options at link-time. We also provide 15018334Speter support here for as many of the other svr4 linker options as seems 15118334Speter reasonable, given that some of them conflict with options for other 15218334Speter svr4 tools (e.g. the assembler). In particular, we do support the 15318334Speter -h*, -z*, -V, -b, -t, -Qy, -Qn, and -YP* options here, and the -e*, 15418334Speter -l*, -o*, -r, -s, -u*, and -L* options are directly supported 15518334Speter by gcc.c itself. We don't directly support the -m (generate load 15618334Speter map) option because that conflicts with the -m (run m4) option of 15718334Speter the svr4 assembler. We also don't directly support the svr4 linker's 15818334Speter -I* or -M* options because these conflict with existing GCC options. 15918334Speter We do however allow passing arbitrary options to the svr4 linker 16018334Speter via the -Wl, option. We don't support the svr4 linker's -a option 16118334Speter at all because it is totally useless and because it conflicts with 16218334Speter GCC's own -a option. 16318334Speter 16418334Speter Note that gcc doesn't allow a space to follow -Y in a -YP,* option. 16518334Speter 16618334Speter When the -G link option is used (-shared and -symbolic) a final link is 16718334Speter not being done. */ 16818334Speter 16918334Speter#undef LINK_SPEC 17018334Speter#define LINK_SPEC "%{h*} %{V} %{v:%{!V:-V}} \ 17118334Speter %{b} %{Wl,*:%*} \ 17218334Speter %{static:-dn -Bstatic} \ 17318334Speter %{shared:-G -dy -z text %{!h*:%{o*:-h %*}}} \ 17418334Speter %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}}} \ 17518334Speter %{G:-G} \ 17618334Speter %{YP,*} \ 17718334Speter %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ 17818334Speter %{!p:-Y P,/usr/ccs/lib:/usr/lib}} \ 17918334Speter %{Qy:} %{!Qn:-Qy}" 18018334Speter 18118334Speter/* Gcc automatically adds in one of the files /usr/ccs/lib/values-Xc.o, 18218334Speter /usr/ccs/lib/values-Xa.o, or /usr/ccs/lib/values-Xt.o for each final 18318334Speter link step (depending upon the other gcc options selected, such as 18418334Speter -traditional and -ansi). These files each contain one (initialized) 18518334Speter copy of a special variable called `_lib_version'. Each one of these 18618334Speter files has `_lib_version' initialized to a different (enum) value. 18718334Speter The SVR4 library routines query the value of `_lib_version' at run 18818334Speter to decide how they should behave. Specifically, they decide (based 18918334Speter upon the value of `_lib_version') if they will act in a strictly ANSI 19018334Speter conforming manner or not. 19118334Speter*/ 19218334Speter 19318334Speter#undef STARTFILE_SPEC 19418334Speter#define STARTFILE_SPEC "%{!shared: \ 19518334Speter %{!symbolic: \ 19618334Speter %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}\ 19718334Speter %{pg:gcrti.o%s}%{!pg:crti.o%s} \ 19818334Speter %{ansi:values-Xc.o%s} \ 19918334Speter %{!ansi: \ 20018334Speter %{traditional:values-Xt.o%s} \ 20118334Speter %{!traditional:values-Xa.o%s}} \ 20218334Speter crtbegin.o%s" 20318334Speter 20418334Speter/* Attach a special .ident directive to the end of the file to identify 20518334Speter the version of GCC which compiled this code. The format of the 20618334Speter .ident string is patterned after the ones produced by native svr4 20718334Speter C compilers. */ 20818334Speter 20918334Speter#define IDENT_ASM_OP ".ident" 21018334Speter 21118334Speter#define ASM_FILE_END(FILE) \ 21218334Speterdo { \ 21318334Speter fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \ 21418334Speter IDENT_ASM_OP, version_string); \ 21518334Speter } while (0) 21618334Speter 21718334Speter/* Allow #sccs in preprocessor. */ 21818334Speter 21918334Speter#define SCCS_DIRECTIVE 22018334Speter 22118334Speter/* Output #ident as a .ident. */ 22218334Speter 22318334Speter#define ASM_OUTPUT_IDENT(FILE, NAME) \ 22418334Speter fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME); 22518334Speter 22618334Speter/* Use periods rather than dollar signs in special g++ assembler names. */ 22718334Speter 22818334Speter#define NO_DOLLAR_IN_LABEL 22918334Speter 23018334Speter/* Writing `int' for a bitfield forces int alignment for the structure. */ 23118334Speter 23218334Speter#define PCC_BITFIELD_TYPE_MATTERS 1 23318334Speter 23418334Speter/* Implicit library calls should use memcpy, not bcopy, etc. */ 23518334Speter 23618334Speter#define TARGET_MEM_FUNCTIONS 23718334Speter 23818334Speter/* Handle #pragma weak and #pragma pack. */ 23918334Speter 24018334Speter#define HANDLE_SYSV_PRAGMA 24118334Speter 24218334Speter/* System V Release 4 uses DWARF debugging info. */ 24318334Speter 24418334Speter#define DWARF_DEBUGGING_INFO 24518334Speter 24618334Speter/* The numbers used to denote specific machine registers in the System V 24718334Speter Release 4 DWARF debugging information are quite likely to be totally 24818334Speter different from the numbers used in BSD stabs debugging information 24918334Speter for the same kind of target machine. Thus, we undefine the macro 25018334Speter DBX_REGISTER_NUMBER here as an extra inducement to get people to 25118334Speter provide proper machine-specific definitions of DBX_REGISTER_NUMBER 25218334Speter (which is also used to provide DWARF registers numbers in dwarfout.c) 25318334Speter in their tm.h files which include this file. */ 25418334Speter 25518334Speter#undef DBX_REGISTER_NUMBER 25618334Speter 25718334Speter/* gas on SVR4 supports the use of .stabs. Permit -gstabs to be used 25818334Speter in general, although it will only work when using gas. */ 25918334Speter 26018334Speter#define DBX_DEBUGGING_INFO 26118334Speter 26218334Speter/* Use DWARF debugging info by default. */ 26318334Speter 26418334Speter#ifndef PREFERRED_DEBUGGING_TYPE 26518334Speter#define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG 26618334Speter#endif 26718334Speter 26818334Speter/* Make LBRAC and RBRAC addresses relative to the start of the 26918334Speter function. The native Solaris stabs debugging format works this 27018334Speter way, gdb expects it, and it reduces the number of relocation 27118334Speter entries. */ 27218334Speter 27318334Speter#define DBX_BLOCKS_FUNCTION_RELATIVE 1 27418334Speter 27518334Speter/* When using stabs, gcc2_compiled must be a stabs entry, not an 27618334Speter ordinary symbol, or gdb won't see it. The stabs entry must be 27718334Speter before the N_SO in order for gdb to find it. */ 27818334Speter 27918334Speter#define ASM_IDENTIFY_GCC(FILE) \ 28018334Speterdo \ 28118334Speter { \ 28218334Speter if (write_symbols != DBX_DEBUG) \ 28318334Speter fputs ("gcc2_compiled.:\n", FILE); \ 28418334Speter else \ 28518334Speter fputs ("\t.stabs\t\"gcc2_compiled.\", 0x3c, 0, 0, 0\n", FILE); \ 28618334Speter } \ 28718334Speterwhile (0) 28818334Speter 28918334Speter/* Like block addresses, stabs line numbers are relative to the 29018334Speter current function. */ 29118334Speter 29218334Speter#define ASM_OUTPUT_SOURCE_LINE(file, line) \ 29318334Speterdo \ 29418334Speter { \ 29518334Speter static int sym_lineno = 1; \ 29618334Speter fprintf (file, ".stabn 68,0,%d,.LM%d-", \ 29718334Speter line, sym_lineno); \ 29818334Speter assemble_name (file, \ 29918334Speter XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\ 30018334Speter fprintf (file, "\n.LM%d:\n", sym_lineno); \ 30118334Speter sym_lineno += 1; \ 30218334Speter } \ 30318334Speterwhile (0) 30418334Speter 30518334Speter/* In order for relative line numbers to work, we must output the 30618334Speter stabs entry for the function name first. */ 30718334Speter 30818334Speter#define DBX_FUNCTION_FIRST 30918334Speter 31018334Speter/* Generate a blank trailing N_SO to mark the end of the .o file, since 31118334Speter we can't depend upon the linker to mark .o file boundaries with 31218334Speter embedded stabs. */ 31318334Speter 31418334Speter#define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \ 31518334Speter fprintf (FILE, \ 31618334Speter "\t.text\n\t.stabs \"\",%d,0,0,.Letext\n.Letext:\n", N_SO) 31718334Speter 31818334Speter/* Define the actual types of some ANSI-mandated types. (These 31918334Speter definitions should work for most SVR4 systems). */ 32018334Speter 32118334Speter#undef SIZE_TYPE 32218334Speter#define SIZE_TYPE "unsigned int" 32318334Speter 32418334Speter#undef PTRDIFF_TYPE 32518334Speter#define PTRDIFF_TYPE "int" 32618334Speter 32718334Speter#undef WCHAR_TYPE 32818334Speter#define WCHAR_TYPE "long int" 32918334Speter 33018334Speter#undef WCHAR_TYPE_SIZE 33118334Speter#define WCHAR_TYPE_SIZE BITS_PER_WORD 33218334Speter 33318334Speter/* This causes trouble, because it requires the host machine 33418334Speter to support ANSI C. */ 33518334Speter/* #define MULTIBYTE_CHARS */ 33618334Speter 33718334Speter#undef ASM_BYTE_OP 33818334Speter#define ASM_BYTE_OP ".byte" 33918334Speter 34018334Speter#undef SET_ASM_OP 34118334Speter#define SET_ASM_OP ".set" 34218334Speter 34318334Speter/* This is how to begin an assembly language file. Most svr4 assemblers want 34418334Speter at least a .file directive to come first, and some want to see a .version 34518334Speter directive come right after that. Here we just establish a default 34618334Speter which generates only the .file directive. If you need a .version 34718334Speter directive for any specific target, you should override this definition 34818334Speter in the target-specific file which includes this one. */ 34918334Speter 35018334Speter#undef ASM_FILE_START 35118334Speter#define ASM_FILE_START(FILE) \ 35218334Speter output_file_directive ((FILE), main_input_filename) 35318334Speter 35418334Speter/* This is how to allocate empty space in some section. The .zero 35518334Speter pseudo-op is used for this on most svr4 assemblers. */ 35618334Speter 35718334Speter#define SKIP_ASM_OP ".zero" 35818334Speter 35918334Speter#undef ASM_OUTPUT_SKIP 36018334Speter#define ASM_OUTPUT_SKIP(FILE,SIZE) \ 36118334Speter fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE)) 36218334Speter 36318334Speter/* This is how to output a reference to a user-level label named NAME. 36418334Speter `assemble_name' uses this. 36518334Speter 36618334Speter For System V Release 4 the convention is *not* to prepend a leading 36718334Speter underscore onto user-level symbol names. */ 36818334Speter 36918334Speter#undef ASM_OUTPUT_LABELREF 37018334Speter#define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "%s", NAME) 37118334Speter 37218334Speter/* This is how to output an internal numbered label where 37318334Speter PREFIX is the class of label and NUM is the number within the class. 37418334Speter 37518334Speter For most svr4 systems, the convention is that any symbol which begins 37618334Speter with a period is not put into the linker symbol table by the assembler. */ 37718334Speter 37818334Speter#undef ASM_OUTPUT_INTERNAL_LABEL 37918334Speter#define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \ 38018334Speterdo { \ 38118334Speter fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \ 38218334Speter} while (0) 38318334Speter 38418334Speter/* This is how to store into the string LABEL 38518334Speter the symbol_ref name of an internal numbered label where 38618334Speter PREFIX is the class of label and NUM is the number within the class. 38718334Speter This is suitable for output with `assemble_name'. 38818334Speter 38918334Speter For most svr4 systems, the convention is that any symbol which begins 39018334Speter with a period is not put into the linker symbol table by the assembler. */ 39118334Speter 39218334Speter#undef ASM_GENERATE_INTERNAL_LABEL 39318334Speter#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ 39418334Speterdo { \ 39518334Speter sprintf (LABEL, "*.%s%d", PREFIX, NUM); \ 39618334Speter} while (0) 39718334Speter 39818334Speter/* Output the label which precedes a jumptable. Note that for all svr4 39918334Speter systems where we actually generate jumptables (which is to say every 40018334Speter svr4 target except i386, where we use casesi instead) we put the jump- 40118334Speter tables into the .rodata section and since other stuff could have been 40218334Speter put into the .rodata section prior to any given jumptable, we have to 40318334Speter make sure that the location counter for the .rodata section gets pro- 40418334Speter perly re-aligned prior to the actual beginning of the jump table. */ 40518334Speter 40618334Speter#define ALIGN_ASM_OP ".align" 40718334Speter 40818334Speter#ifndef ASM_OUTPUT_BEFORE_CASE_LABEL 40918334Speter#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \ 41018334Speter ASM_OUTPUT_ALIGN ((FILE), 2); 41118334Speter#endif 41218334Speter 41318334Speter#undef ASM_OUTPUT_CASE_LABEL 41418334Speter#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \ 41518334Speter do { \ 41618334Speter ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \ 41718334Speter ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \ 41818334Speter } while (0) 41918334Speter 42018334Speter/* The standard SVR4 assembler seems to require that certain builtin 42118334Speter library routines (e.g. .udiv) be explicitly declared as .globl 42218334Speter in each assembly file where they are referenced. */ 42318334Speter 42418334Speter#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ 42518334Speter ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0)) 42618334Speter 42718334Speter/* This says how to output assembler code to declare an 42818334Speter uninitialized external linkage data object. Under SVR4, 42918334Speter the linker seems to want the alignment of data objects 43018334Speter to depend on their types. We do exactly that here. */ 43118334Speter 43218334Speter#define COMMON_ASM_OP ".comm" 43318334Speter 43418334Speter#undef ASM_OUTPUT_ALIGNED_COMMON 43518334Speter#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ 43618334Speterdo { \ 43718334Speter fprintf ((FILE), "\t%s\t", COMMON_ASM_OP); \ 43818334Speter assemble_name ((FILE), (NAME)); \ 43918334Speter fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \ 44018334Speter} while (0) 44118334Speter 44218334Speter/* This says how to output assembler code to declare an 44318334Speter uninitialized internal linkage data object. Under SVR4, 44418334Speter the linker seems to want the alignment of data objects 44518334Speter to depend on their types. We do exactly that here. */ 44618334Speter 44718334Speter#define LOCAL_ASM_OP ".local" 44818334Speter 44918334Speter#undef ASM_OUTPUT_ALIGNED_LOCAL 45018334Speter#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ 45118334Speterdo { \ 45218334Speter fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP); \ 45318334Speter assemble_name ((FILE), (NAME)); \ 45418334Speter fprintf ((FILE), "\n"); \ 45518334Speter ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \ 45618334Speter} while (0) 45718334Speter 45818334Speter/* This is the pseudo-op used to generate a 32-bit word of data with a 45918334Speter specific value in some section. This is the same for all known svr4 46018334Speter assemblers. */ 46118334Speter 46218334Speter#define INT_ASM_OP ".long" 46318334Speter 46418334Speter/* This is the pseudo-op used to generate a contiguous sequence of byte 46518334Speter values from a double-quoted string WITHOUT HAVING A TERMINATING NUL 46618334Speter AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */ 46718334Speter 46818334Speter#undef ASCII_DATA_ASM_OP 46918334Speter#define ASCII_DATA_ASM_OP ".ascii" 47018334Speter 47118334Speter/* Support const sections and the ctors and dtors sections for g++. 47218334Speter Note that there appears to be two different ways to support const 47318334Speter sections at the moment. You can either #define the symbol 47418334Speter READONLY_DATA_SECTION (giving it some code which switches to the 47518334Speter readonly data section) or else you can #define the symbols 47618334Speter EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and 47718334Speter SELECT_RTX_SECTION. We do both here just to be on the safe side. */ 47818334Speter 47918334Speter#define USE_CONST_SECTION 1 48018334Speter 48118334Speter#define CONST_SECTION_ASM_OP ".section\t.rodata" 48218334Speter 48318334Speter/* Define the pseudo-ops used to switch to the .ctors and .dtors sections. 48418334Speter 48518334Speter Note that we want to give these sections the SHF_WRITE attribute 48618334Speter because these sections will actually contain data (i.e. tables of 48718334Speter addresses of functions in the current root executable or shared library 48818334Speter file) and, in the case of a shared library, the relocatable addresses 48918334Speter will have to be properly resolved/relocated (and then written into) by 49018334Speter the dynamic linker when it actually attaches the given shared library 49118334Speter to the executing process. (Note that on SVR4, you may wish to use the 49218334Speter `-z text' option to the ELF linker, when building a shared library, as 49318334Speter an additional check that you are doing everything right. But if you do 49418334Speter use the `-z text' option when building a shared library, you will get 49518334Speter errors unless the .ctors and .dtors sections are marked as writable 49618334Speter via the SHF_WRITE attribute.) */ 49718334Speter 49818334Speter#define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\"" 49918334Speter#define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\"" 50018334Speter 50118334Speter/* On svr4, we *do* have support for the .init and .fini sections, and we 50218334Speter can put stuff in there to be executed before and after `main'. We let 50318334Speter crtstuff.c and other files know this by defining the following symbols. 50418334Speter The definitions say how to change sections to the .init and .fini 50518334Speter sections. This is the same for all known svr4 assemblers. */ 50618334Speter 50718334Speter#define INIT_SECTION_ASM_OP ".section\t.init" 50818334Speter#define FINI_SECTION_ASM_OP ".section\t.fini" 50918334Speter 51018334Speter/* A default list of other sections which we might be "in" at any given 51118334Speter time. For targets that use additional sections (e.g. .tdesc) you 51218334Speter should override this definition in the target-specific file which 51318334Speter includes this file. */ 51418334Speter 51518334Speter#undef EXTRA_SECTIONS 51618334Speter#define EXTRA_SECTIONS in_const, in_ctors, in_dtors 51718334Speter 51818334Speter/* A default list of extra section function definitions. For targets 51918334Speter that use additional sections (e.g. .tdesc) you should override this 52018334Speter definition in the target-specific file which includes this file. */ 52118334Speter 52218334Speter#undef EXTRA_SECTION_FUNCTIONS 52318334Speter#define EXTRA_SECTION_FUNCTIONS \ 52418334Speter CONST_SECTION_FUNCTION \ 52518334Speter CTORS_SECTION_FUNCTION \ 52618334Speter DTORS_SECTION_FUNCTION 52718334Speter 52818334Speter#define READONLY_DATA_SECTION() const_section () 52918334Speter 53018334Speterextern void text_section (); 53118334Speter 53218334Speter#define CONST_SECTION_FUNCTION \ 53318334Spetervoid \ 53418334Speterconst_section () \ 53518334Speter{ \ 53618334Speter if (!USE_CONST_SECTION) \ 53718334Speter text_section(); \ 53818334Speter else if (in_section != in_const) \ 53918334Speter { \ 54018334Speter fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \ 54118334Speter in_section = in_const; \ 54218334Speter } \ 54318334Speter} 54418334Speter 54518334Speter#define CTORS_SECTION_FUNCTION \ 54618334Spetervoid \ 54718334Speterctors_section () \ 54818334Speter{ \ 54918334Speter if (in_section != in_ctors) \ 55018334Speter { \ 55118334Speter fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \ 55218334Speter in_section = in_ctors; \ 55318334Speter } \ 55418334Speter} 55518334Speter 55618334Speter#define DTORS_SECTION_FUNCTION \ 55718334Spetervoid \ 55818334Speterdtors_section () \ 55918334Speter{ \ 56018334Speter if (in_section != in_dtors) \ 56118334Speter { \ 56218334Speter fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \ 56318334Speter in_section = in_dtors; \ 56418334Speter } \ 56518334Speter} 56618334Speter 56718334Speter/* Switch into a generic section. 56818334Speter This is currently only used to support section attributes. 56918334Speter 57018334Speter We make the section read-only and executable for a function decl, 57118334Speter read-only for a const data decl, and writable for a non-const data decl. */ 57218334Speter#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ 57318334Speter fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ 57418334Speter (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ 57518334Speter (DECL) && TREE_READONLY (DECL) ? "a" : "aw") 57618334Speter 57718334Speter 57818334Speter/* A C statement (sans semicolon) to output an element in the table of 57918334Speter global constructors. */ 58018334Speter#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ 58118334Speter do { \ 58218334Speter ctors_section (); \ 58318334Speter fprintf (FILE, "\t%s\t ", INT_ASM_OP); \ 58418334Speter assemble_name (FILE, NAME); \ 58518334Speter fprintf (FILE, "\n"); \ 58618334Speter } while (0) 58718334Speter 58818334Speter/* A C statement (sans semicolon) to output an element in the table of 58918334Speter global destructors. */ 59018334Speter#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ 59118334Speter do { \ 59218334Speter dtors_section (); \ 59318334Speter fprintf (FILE, "\t%s\t ", INT_ASM_OP); \ 59418334Speter assemble_name (FILE, NAME); \ 59518334Speter fprintf (FILE, "\n"); \ 59618334Speter } while (0) 59718334Speter 59818334Speter/* A C statement or statements to switch to the appropriate 59918334Speter section for output of DECL. DECL is either a `VAR_DECL' node 60018334Speter or a constant of some sort. RELOC indicates whether forming 60118334Speter the initial value of DECL requires link-time relocations. */ 60218334Speter 60318334Speter#define SELECT_SECTION(DECL,RELOC) \ 60418334Speter{ \ 60518334Speter if (TREE_CODE (DECL) == STRING_CST) \ 60618334Speter { \ 60718334Speter if (! flag_writable_strings) \ 60818334Speter const_section (); \ 60918334Speter else \ 61018334Speter data_section (); \ 61118334Speter } \ 61218334Speter else if (TREE_CODE (DECL) == VAR_DECL) \ 61318334Speter { \ 61418334Speter if ((flag_pic && RELOC) \ 61518334Speter || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ 61618334Speter || !DECL_INITIAL (DECL) \ 61718334Speter || (DECL_INITIAL (DECL) != error_mark_node \ 61818334Speter && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ 61918334Speter data_section (); \ 62018334Speter else \ 62118334Speter const_section (); \ 62218334Speter } \ 62318334Speter else \ 62418334Speter const_section (); \ 62518334Speter} 62618334Speter 62718334Speter/* A C statement or statements to switch to the appropriate 62818334Speter section for output of RTX in mode MODE. RTX is some kind 62918334Speter of constant in RTL. The argument MODE is redundant except 63018334Speter in the case of a `const_int' rtx. Currently, these always 63118334Speter go into the const section. */ 63218334Speter 63318334Speter#undef SELECT_RTX_SECTION 63418334Speter#define SELECT_RTX_SECTION(MODE,RTX) const_section() 63518334Speter 63618334Speter/* Define the strings used for the special svr4 .type and .size directives. 63718334Speter These strings generally do not vary from one system running svr4 to 63818334Speter another, but if a given system (e.g. m88k running svr) needs to use 63918334Speter different pseudo-op names for these, they may be overridden in the 64018334Speter file which includes this one. */ 64118334Speter 64218334Speter#define TYPE_ASM_OP ".type" 64318334Speter#define SIZE_ASM_OP ".size" 64418334Speter 64518334Speter/* This is how we tell the assembler that a symbol is weak. */ 64618334Speter 64718334Speter#define ASM_WEAKEN_LABEL(FILE,NAME) \ 64818334Speter do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ 64918334Speter fputc ('\n', FILE); } while (0) 65018334Speter 65118334Speter/* The following macro defines the format used to output the second 65218334Speter operand of the .type assembler directive. Different svr4 assemblers 65318334Speter expect various different forms for this operand. The one given here 65418334Speter is just a default. You may need to override it in your machine- 65518334Speter specific tm.h file (depending upon the particulars of your assembler). */ 65618334Speter 65718334Speter#define TYPE_OPERAND_FMT "@%s" 65818334Speter 65918334Speter/* Write the extra assembler code needed to declare a function's result. 66018334Speter Most svr4 assemblers don't require any special declaration of the 66118334Speter result value, but there are exceptions. */ 66218334Speter 66318334Speter#ifndef ASM_DECLARE_RESULT 66418334Speter#define ASM_DECLARE_RESULT(FILE, RESULT) 66518334Speter#endif 66618334Speter 66718334Speter/* These macros generate the special .type and .size directives which 66818334Speter are used to set the corresponding fields of the linker symbol table 66918334Speter entries in an ELF object file under SVR4. These macros also output 67018334Speter the starting labels for the relevant functions/objects. */ 67118334Speter 67218334Speter/* Write the extra assembler code needed to declare a function properly. 67318334Speter Some svr4 assemblers need to also have something extra said about the 67418334Speter function's return value. We allow for that here. */ 67518334Speter 67618334Speter#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 67718334Speter do { \ 67818334Speter fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ 67918334Speter assemble_name (FILE, NAME); \ 68018334Speter putc (',', FILE); \ 68118334Speter fprintf (FILE, TYPE_OPERAND_FMT, "function"); \ 68218334Speter putc ('\n', FILE); \ 68318334Speter ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ 68418334Speter ASM_OUTPUT_LABEL(FILE, NAME); \ 68518334Speter } while (0) 68618334Speter 68718334Speter/* Write the extra assembler code needed to declare an object properly. */ 68818334Speter 68918334Speter#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 69018334Speter do { \ 69118334Speter fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ 69218334Speter assemble_name (FILE, NAME); \ 69318334Speter putc (',', FILE); \ 69418334Speter fprintf (FILE, TYPE_OPERAND_FMT, "object"); \ 69518334Speter putc ('\n', FILE); \ 69618334Speter size_directive_output = 0; \ 69718334Speter if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ 69818334Speter { \ 69918334Speter size_directive_output = 1; \ 70018334Speter fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 70118334Speter assemble_name (FILE, NAME); \ 70218334Speter fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ 70318334Speter } \ 70418334Speter ASM_OUTPUT_LABEL(FILE, NAME); \ 70518334Speter } while (0) 70618334Speter 70718334Speter/* Output the size directive for a decl in rest_of_decl_compilation 70818334Speter in the case where we did not do so before the initializer. 70918334Speter Once we find the error_mark_node, we know that the value of 71018334Speter size_directive_output was set 71118334Speter by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 71218334Speter 71318334Speter#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 71418334Speterdo { \ 71518334Speter char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 71618334Speter if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 71718334Speter && ! AT_END && TOP_LEVEL \ 71818334Speter && DECL_INITIAL (DECL) == error_mark_node \ 71918334Speter && !size_directive_output) \ 72018334Speter { \ 72118334Speter size_directive_output = 1; \ 72218334Speter fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 72318334Speter assemble_name (FILE, name); \ 72418334Speter fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ 72518334Speter } \ 72618334Speter } while (0) 72718334Speter 72818334Speter/* This is how to declare the size of a function. */ 72918334Speter 73018334Speter#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 73118334Speter do { \ 73218334Speter if (!flag_inhibit_size_directive) \ 73318334Speter { \ 73418334Speter char label[256]; \ 73518334Speter static int labelno; \ 73618334Speter labelno++; \ 73718334Speter ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ 73818334Speter ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ 73918334Speter fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 74018334Speter assemble_name (FILE, (FNAME)); \ 74118334Speter fprintf (FILE, ","); \ 74218334Speter assemble_name (FILE, label); \ 74318334Speter fprintf (FILE, "-"); \ 74418334Speter assemble_name (FILE, (FNAME)); \ 74518334Speter putc ('\n', FILE); \ 74618334Speter } \ 74718334Speter } while (0) 74818334Speter 74918334Speter/* A table of bytes codes used by the ASM_OUTPUT_ASCII and 75018334Speter ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table 75118334Speter corresponds to a particular byte value [0..255]. For any 75218334Speter given byte value, if the value in the corresponding table 75318334Speter position is zero, the given character can be output directly. 75418334Speter If the table value is 1, the byte must be output as a \ooo 75518334Speter octal escape. If the tables value is anything else, then the 75618334Speter byte value should be output as a \ followed by the value 75718334Speter in the table. Note that we can use standard UN*X escape 75818334Speter sequences for many control characters, but we don't use 75918334Speter \a to represent BEL because some svr4 assemblers (e.g. on 76018334Speter the i386) don't know about that. Also, we don't use \v 76118334Speter since some versions of gas, such as 2.2 did not accept it. */ 76218334Speter 76318334Speter#define ESCAPES \ 76418334Speter"\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 76518334Speter\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 76618334Speter\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\ 76718334Speter\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\ 76818334Speter\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 76918334Speter\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 77018334Speter\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 77118334Speter\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1" 77218334Speter 77318334Speter/* Some svr4 assemblers have a limit on the number of characters which 77418334Speter can appear in the operand of a .string directive. If your assembler 77518334Speter has such a limitation, you should define STRING_LIMIT to reflect that 77618334Speter limit. Note that at least some svr4 assemblers have a limit on the 77718334Speter actual number of bytes in the double-quoted string, and that they 77818334Speter count each character in an escape sequence as one byte. Thus, an 77918334Speter escape sequence like \377 would count as four bytes. 78018334Speter 78118334Speter If your target assembler doesn't support the .string directive, you 78218334Speter should define this to zero. 78318334Speter*/ 78418334Speter 78518334Speter#define STRING_LIMIT ((unsigned) 256) 78618334Speter 78718334Speter#define STRING_ASM_OP ".string" 78818334Speter 78918334Speter/* The routine used to output NUL terminated strings. We use a special 79018334Speter version of this for most svr4 targets because doing so makes the 79118334Speter generated assembly code more compact (and thus faster to assemble) 79218334Speter as well as more readable, especially for targets like the i386 79318334Speter (where the only alternative is to output character sequences as 79418334Speter comma separated lists of numbers). */ 79518334Speter 79618334Speter#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \ 79718334Speter do \ 79818334Speter { \ 79918334Speter register unsigned char *_limited_str = (unsigned char *) (STR); \ 80018334Speter register unsigned ch; \ 80118334Speter fprintf ((FILE), "\t%s\t\"", STRING_ASM_OP); \ 80218334Speter for (; ch = *_limited_str; _limited_str++) \ 80318334Speter { \ 80418334Speter register int escape; \ 80518334Speter switch (escape = ESCAPES[ch]) \ 80618334Speter { \ 80718334Speter case 0: \ 80818334Speter putc (ch, (FILE)); \ 80918334Speter break; \ 81018334Speter case 1: \ 81118334Speter fprintf ((FILE), "\\%03o", ch); \ 81218334Speter break; \ 81318334Speter default: \ 81418334Speter putc ('\\', (FILE)); \ 81518334Speter putc (escape, (FILE)); \ 81618334Speter break; \ 81718334Speter } \ 81818334Speter } \ 81918334Speter fprintf ((FILE), "\"\n"); \ 82018334Speter } \ 82118334Speter while (0) 82218334Speter 82318334Speter/* The routine used to output sequences of byte values. We use a special 82418334Speter version of this for most svr4 targets because doing so makes the 82518334Speter generated assembly code more compact (and thus faster to assemble) 82618334Speter as well as more readable. Note that if we find subparts of the 82718334Speter character sequence which end with NUL (and which are shorter than 82818334Speter STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ 82918334Speter 83018334Speter#undef ASM_OUTPUT_ASCII 83118334Speter#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ 83218334Speter do \ 83318334Speter { \ 83418334Speter register unsigned char *_ascii_bytes = (unsigned char *) (STR); \ 83518334Speter register unsigned char *limit = _ascii_bytes + (LENGTH); \ 83618334Speter register unsigned bytes_in_chunk = 0; \ 83718334Speter for (; _ascii_bytes < limit; _ascii_bytes++) \ 83818334Speter { \ 83918334Speter register unsigned char *p; \ 84018334Speter if (bytes_in_chunk >= 60) \ 84118334Speter { \ 84218334Speter fprintf ((FILE), "\"\n"); \ 84318334Speter bytes_in_chunk = 0; \ 84418334Speter } \ 84518334Speter for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ 84618334Speter continue; \ 84718334Speter if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT) \ 84818334Speter { \ 84918334Speter if (bytes_in_chunk > 0) \ 85018334Speter { \ 85118334Speter fprintf ((FILE), "\"\n"); \ 85218334Speter bytes_in_chunk = 0; \ 85318334Speter } \ 85418334Speter ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ 85518334Speter _ascii_bytes = p; \ 85618334Speter } \ 85718334Speter else \ 85818334Speter { \ 85918334Speter register int escape; \ 86018334Speter register unsigned ch; \ 86118334Speter if (bytes_in_chunk == 0) \ 86218334Speter fprintf ((FILE), "\t%s\t\"", ASCII_DATA_ASM_OP); \ 86318334Speter switch (escape = ESCAPES[ch = *_ascii_bytes]) \ 86418334Speter { \ 86518334Speter case 0: \ 86618334Speter putc (ch, (FILE)); \ 86718334Speter bytes_in_chunk++; \ 86818334Speter break; \ 86918334Speter case 1: \ 87018334Speter fprintf ((FILE), "\\%03o", ch); \ 87118334Speter bytes_in_chunk += 4; \ 87218334Speter break; \ 87318334Speter default: \ 87418334Speter putc ('\\', (FILE)); \ 87518334Speter putc (escape, (FILE)); \ 87618334Speter bytes_in_chunk += 2; \ 87718334Speter break; \ 87818334Speter } \ 87918334Speter } \ 88018334Speter } \ 88118334Speter if (bytes_in_chunk > 0) \ 88218334Speter fprintf ((FILE), "\"\n"); \ 88318334Speter } \ 88418334Speter while (0) 88518334Speter 88618334Speter/* All SVR4 targets use the ELF object file format. */ 88718334Speter#define OBJECT_FORMAT_ELF 888