xcoff.h revision 132718
190075Sobrien/* Definitions of target machine for GNU compiler, 290075Sobrien for some generic XCOFF file format 3132718Skan Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 490075Sobrien 5132718Skan This file is part of GCC. 690075Sobrien 7132718Skan GCC is free software; you can redistribute it and/or modify it 8132718Skan under the terms of the GNU General Public License as published 9132718Skan by the Free Software Foundation; either version 2, or (at your 10132718Skan option) any later version. 1190075Sobrien 12132718Skan GCC is distributed in the hope that it will be useful, but WITHOUT 13132718Skan ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14132718Skan or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15132718Skan License for more details. 1690075Sobrien 17132718Skan You should have received a copy of the GNU General Public License 18132718Skan along with GCC; see the file COPYING. If not, write to the 19132718Skan Free Software Foundation, 59 Temple Place - Suite 330, Boston, 20132718Skan MA 02111-1307, USA. */ 2190075Sobrien 2290075Sobrien#define TARGET_OBJECT_FORMAT OBJECT_XCOFF 2390075Sobrien 2490075Sobrien/* The RS/6000 uses the XCOFF format. */ 25117395Skan#define XCOFF_DEBUGGING_INFO 1 2690075Sobrien 2790075Sobrien/* Define if the object format being used is COFF or a superset. */ 2890075Sobrien#define OBJECT_FORMAT_COFF 2990075Sobrien 3090075Sobrien/* Define the magic numbers that we recognize as COFF. 3190075Sobrien 3290075Sobrien AIX 4.3 adds U803XTOCMAGIC (0757) for 64-bit objects and AIX V5 adds 3390075Sobrien U64_TOCMAGIC (0767), but collect2.c does not include files in the 3490075Sobrien correct order to conditionally define the symbolic name in this macro. 3590075Sobrien 3690075Sobrien The AIX linker accepts import/export files as object files, 3790075Sobrien so accept "#!" (0x2321) magic number. */ 3890075Sobrien#define MY_ISCOFF(magic) \ 3990075Sobrien ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC \ 4090075Sobrien || (magic) == U802TOCMAGIC || (magic) == 0757 || (magic) == 0767 \ 4190075Sobrien || (magic) == 0x2321) 4290075Sobrien 4390075Sobrien/* We don't have GAS for the RS/6000 yet, so don't write out special 4490075Sobrien .stabs in cc1plus. */ 4590075Sobrien 4690075Sobrien#define FASCIST_ASSEMBLER 4790075Sobrien 4890075Sobrien/* We define this to prevent the name mangler from putting dollar signs into 4990075Sobrien function names. */ 5090075Sobrien 5190075Sobrien#define NO_DOLLAR_IN_LABEL 5290075Sobrien 5390075Sobrien/* We define this to 0 so that gcc will never accept a dollar sign in a 5490075Sobrien variable name. This is needed because the AIX assembler will not accept 5590075Sobrien dollar signs. */ 5690075Sobrien 5790075Sobrien#define DOLLARS_IN_IDENTIFIERS 0 5890075Sobrien 5990075Sobrien/* Define the extra sections we need. We define three: one is the read-only 6090075Sobrien data section which is used for constants. This is a csect whose name is 6190075Sobrien derived from the name of the input file. The second is for initialized 6290075Sobrien global variables. This is a csect whose name is that of the variable. 6390075Sobrien The third is the TOC. */ 6490075Sobrien 6590075Sobrien#define EXTRA_SECTIONS \ 6690075Sobrien read_only_data, private_data, read_only_private_data, toc, bss 6790075Sobrien 6890075Sobrien/* Define the routines to implement these extra sections. 6990075Sobrien BIGGEST_ALIGNMENT is 64, so align the sections that much. */ 7090075Sobrien 7190075Sobrien#define EXTRA_SECTION_FUNCTIONS \ 72132718Skan READ_ONLY_DATA_SECTION_FUNCTION \ 73132718Skan PRIVATE_DATA_SECTION_FUNCTION \ 74132718Skan READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION \ 75132718Skan TOC_SECTION_FUNCTION 76132718Skan 77132718Skan#define READ_ONLY_DATA_SECTION_FUNCTION \ 7890075Sobrienvoid \ 79132718Skanread_only_data_section (void) \ 8090075Sobrien{ \ 8190075Sobrien if (in_section != read_only_data) \ 8290075Sobrien { \ 8390075Sobrien fprintf (asm_out_file, "\t.csect %s[RO],3\n", \ 8490075Sobrien xcoff_read_only_section_name); \ 8590075Sobrien in_section = read_only_data; \ 8690075Sobrien } \ 87132718Skan} 88132718Skan 89132718Skan#define PRIVATE_DATA_SECTION_FUNCTION \ 9090075Sobrienvoid \ 91132718Skanprivate_data_section (void) \ 9290075Sobrien{ \ 9390075Sobrien if (in_section != private_data) \ 9490075Sobrien { \ 9590075Sobrien fprintf (asm_out_file, "\t.csect %s[RW],3\n", \ 9690075Sobrien xcoff_private_data_section_name); \ 9790075Sobrien in_section = private_data; \ 9890075Sobrien } \ 99132718Skan} 100132718Skan 101132718Skan#define READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION \ 10290075Sobrienvoid \ 103132718Skanread_only_private_data_section (void) \ 10490075Sobrien{ \ 10590075Sobrien if (in_section != read_only_private_data) \ 10690075Sobrien { \ 10790075Sobrien fprintf (asm_out_file, "\t.csect %s[RO],3\n", \ 10890075Sobrien xcoff_private_data_section_name); \ 10990075Sobrien in_section = read_only_private_data; \ 11090075Sobrien } \ 111132718Skan} 112132718Skan 113132718Skan#define TOC_SECTION_FUNCTION \ 11490075Sobrienvoid \ 115132718Skantoc_section (void) \ 11690075Sobrien{ \ 11790075Sobrien if (TARGET_MINIMAL_TOC) \ 11890075Sobrien { \ 119132718Skan /* toc_section is always called at least once \ 120132718Skan from rs6000_xcoff_file_start, so this is \ 121132718Skan guaranteed to always be defined once and \ 122132718Skan only once in each file. */ \ 12390075Sobrien if (! toc_initialized) \ 12490075Sobrien { \ 12590075Sobrien fputs ("\t.toc\nLCTOC..1:\n", asm_out_file); \ 12690075Sobrien fputs ("\t.tc toc_table[TC],toc_table[RW]\n", asm_out_file); \ 12790075Sobrien toc_initialized = 1; \ 12890075Sobrien } \ 12990075Sobrien \ 13090075Sobrien if (in_section != toc) \ 13190075Sobrien fprintf (asm_out_file, "\t.csect toc_table[RW]%s\n", \ 13290075Sobrien (TARGET_32BIT ? "" : ",3")); \ 13390075Sobrien } \ 13490075Sobrien else \ 13590075Sobrien { \ 13690075Sobrien if (in_section != toc) \ 13790075Sobrien fputs ("\t.toc\n", asm_out_file); \ 13890075Sobrien } \ 13990075Sobrien in_section = toc; \ 14090075Sobrien} 14190075Sobrien 14290075Sobrien/* Define the name of our readonly data section. */ 14390075Sobrien 14490075Sobrien#define READONLY_DATA_SECTION read_only_data_section 14590075Sobrien 146117395Skan/* Return nonzero if this entry is to be written into the constant 14790075Sobrien pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF 14890075Sobrien or a CONST containing one of them. If -mfp-in-toc (the default), 14990075Sobrien we also do this for floating-point constants. We actually can only 15090075Sobrien do this if the FP formats of the target and host machines are the 15190075Sobrien same, but we can't check that since not every file that uses 15290075Sobrien GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when 15390075Sobrien we can write the entry into the TOC and the entry is not larger 15490075Sobrien than a TOC entry. */ 15590075Sobrien 15690075Sobrien#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ 15790075Sobrien (TARGET_TOC \ 15890075Sobrien && (GET_CODE (X) == SYMBOL_REF \ 15990075Sobrien || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ 16090075Sobrien && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ 16190075Sobrien || GET_CODE (X) == LABEL_REF \ 16290075Sobrien || (GET_CODE (X) == CONST_INT \ 16390075Sobrien && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ 16490075Sobrien || (GET_CODE (X) == CONST_DOUBLE \ 16590075Sobrien && (TARGET_POWERPC64 \ 16690075Sobrien || TARGET_MINIMAL_TOC \ 16790075Sobrien || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ 16890075Sobrien && ! TARGET_NO_FP_IN_TOC))))) 16990075Sobrien 170117395Skan#define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label 171117395Skan#define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section 172117395Skan#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section 173117395Skan#define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section 174117395Skan#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section 175117395Skan#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding 176117395Skan#define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags 17790075Sobrien 17890075Sobrien/* FP save and restore routines. */ 17990075Sobrien#define SAVE_FP_PREFIX "._savef" 18090075Sobrien#define SAVE_FP_SUFFIX "" 18190075Sobrien#define RESTORE_FP_PREFIX "._restf" 18290075Sobrien#define RESTORE_FP_SUFFIX "" 18390075Sobrien 18490075Sobrien/* Function name to call to do profiling. */ 185132718Skan#undef RS6000_MCOUNT 18690075Sobrien#define RS6000_MCOUNT ".__mcount" 18790075Sobrien 18890075Sobrien/* This outputs NAME to FILE up to the first null or '['. */ 18990075Sobrien 190117395Skan#define RS6000_OUTPUT_BASENAME(FILE, NAME) \ 191117395Skan assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME)) 19290075Sobrien 19390075Sobrien/* This is how to output the definition of a user-level label named NAME, 19490075Sobrien such as the label on a static function or variable NAME. */ 19590075Sobrien 19690075Sobrien#define ASM_OUTPUT_LABEL(FILE,NAME) \ 19790075Sobrien do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0) 19890075Sobrien 19990075Sobrien/* This is how to output a command to make the user-level label named NAME 20090075Sobrien defined for reference from other files. */ 20190075Sobrien 202117395Skan/* Globalizing directive for a label. */ 203117395Skan#define GLOBAL_ASM_OP "\t.globl " 20490075Sobrien 205132718Skan#undef TARGET_ASM_FILE_START 206132718Skan#define TARGET_ASM_FILE_START rs6000_xcoff_file_start 207132718Skan#define TARGET_ASM_FILE_END rs6000_xcoff_file_end 208132718Skan#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE 209132718Skan#define TARGET_ASM_FILE_START_FILE_DIRECTIVE false 21090075Sobrien 21190075Sobrien/* This macro produces the initial definition of a function name. 21290075Sobrien On the RS/6000, we need to place an extra '.' in the function name and 21390075Sobrien output the function descriptor. 21490075Sobrien 21590075Sobrien The csect for the function will have already been created by the 21690075Sobrien `text_section' call previously done. We do have to go back to that 21790075Sobrien csect, however. 21890075Sobrien 21990075Sobrien The third and fourth parameters to the .function pseudo-op (16 and 044) 22090075Sobrien are placeholders which no longer have any use. */ 22190075Sobrien 22290075Sobrien#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \ 223132718Skan{ if (TREE_PUBLIC (DECL)) \ 22490075Sobrien { \ 22596263Sobrien if (!RS6000_WEAK || !DECL_WEAK (decl)) \ 22690075Sobrien { \ 22790075Sobrien fputs ("\t.globl .", FILE); \ 22890075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 22990075Sobrien putc ('\n', FILE); \ 23090075Sobrien } \ 23190075Sobrien } \ 23290075Sobrien else \ 23390075Sobrien { \ 23490075Sobrien fputs ("\t.lglobl .", FILE); \ 23590075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 23690075Sobrien putc ('\n', FILE); \ 23790075Sobrien } \ 23890075Sobrien fputs ("\t.csect ", FILE); \ 23990075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 24090075Sobrien fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", FILE); \ 24190075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 24290075Sobrien fputs (":\n", FILE); \ 24390075Sobrien fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE); \ 24490075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 24590075Sobrien fputs (", TOC[tc0], 0\n", FILE); \ 24690075Sobrien in_section = no_section; \ 24790075Sobrien function_section(DECL); \ 24890075Sobrien putc ('.', FILE); \ 24990075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 25090075Sobrien fputs (":\n", FILE); \ 251132718Skan if (write_symbols != NO_DEBUG) \ 25290075Sobrien xcoffout_declare_function (FILE, DECL, NAME); \ 25390075Sobrien} 25490075Sobrien 25590075Sobrien/* Output a reference to SYM on FILE. */ 25690075Sobrien 25790075Sobrien#define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \ 25890075Sobrien rs6000_output_symbol_ref (FILE, SYM) 25990075Sobrien 26090075Sobrien/* This says how to output an external. */ 26190075Sobrien 262132718Skan#undef ASM_OUTPUT_EXTERNAL 263117395Skan#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ 264117395Skan{ rtx _symref = XEXP (DECL_RTL (DECL), 0); \ 265117395Skan if ((TREE_CODE (DECL) == VAR_DECL \ 266117395Skan || TREE_CODE (DECL) == FUNCTION_DECL) \ 267117395Skan && (NAME)[strlen (NAME) - 1] != ']') \ 268117395Skan { \ 269117395Skan XSTR (_symref, 0) = concat (XSTR (_symref, 0), \ 270117395Skan (TREE_CODE (DECL) == FUNCTION_DECL \ 271117395Skan ? "[DS]" : "[RW]"), \ 272117395Skan NULL); \ 273117395Skan } \ 27490075Sobrien} 27590075Sobrien 27690075Sobrien/* This is how to output an internal label prefix. rs6000.c uses this 27790075Sobrien when generating traceback tables. */ 27890075Sobrien 27990075Sobrien#define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ 28090075Sobrien fprintf (FILE, "%s..", PREFIX) 28190075Sobrien 28290075Sobrien/* This is how to output a label for a jump table. Arguments are the same as 283132718Skan for (*targetm.asm_out.internal_label), except the insn for the jump table is 28490075Sobrien passed. */ 28590075Sobrien 28690075Sobrien#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \ 287132718Skan{ ASM_OUTPUT_ALIGN (FILE, 2); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); } 28890075Sobrien 28990075Sobrien/* This is how to store into the string LABEL 29090075Sobrien the symbol_ref name of an internal numbered label where 29190075Sobrien PREFIX is the class of label and NUM is the number within the class. 29290075Sobrien This is suitable for output with `assemble_name'. */ 29390075Sobrien 29490075Sobrien#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ 29590075Sobrien sprintf (LABEL, "*%s..%u", (PREFIX), (unsigned) (NUM)) 29690075Sobrien 29790075Sobrien/* This is how to output an assembler line to define N characters starting 29890075Sobrien at P to FILE. */ 29990075Sobrien 30090075Sobrien#define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) 30190075Sobrien 30290075Sobrien/* This is how to advance the location counter by SIZE bytes. */ 30390075Sobrien 304117395Skan#define SKIP_ASM_OP "\t.space " 305117395Skan 30690075Sobrien#define ASM_OUTPUT_SKIP(FILE,SIZE) \ 307132718Skan fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE)) 30890075Sobrien 30990075Sobrien/* This says how to output an assembler line 31090075Sobrien to define a global common symbol. */ 31190075Sobrien 312117395Skan#define COMMON_ASM_OP "\t.comm " 313117395Skan 314117395Skan#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ 315117395Skan do { fputs (COMMON_ASM_OP, (FILE)); \ 31690075Sobrien RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ 317117395Skan if ((ALIGN) > 32) \ 318132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \ 319117395Skan exact_log2 ((ALIGN) / BITS_PER_UNIT)); \ 320117395Skan else if ((SIZE) > 4) \ 321132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \ 32290075Sobrien else \ 323132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \ 32490075Sobrien } while (0) 32590075Sobrien 32690075Sobrien/* This says how to output an assembler line 32790075Sobrien to define a local common symbol. 32890075Sobrien Alignment cannot be specified, but we can try to maintain 32990075Sobrien alignment after preceding TOC section if it was aligned 33090075Sobrien for 64-bit mode. */ 33190075Sobrien 332117395Skan#define LOCAL_COMMON_ASM_OP "\t.lcomm " 333117395Skan 33490075Sobrien#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ 335117395Skan do { fputs (LOCAL_COMMON_ASM_OP, (FILE)); \ 33690075Sobrien RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ 337132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%s\n", \ 338132718Skan (TARGET_32BIT ? (SIZE) : (ROUNDED)), \ 33990075Sobrien xcoff_bss_section_name); \ 34090075Sobrien } while (0) 34190075Sobrien 34290075Sobrien/* This is how we tell the assembler that two symbols have the same value. */ 34390075Sobrien#define SET_ASM_OP "\t.set " 34490075Sobrien 345102780Skan/* This is how we tell the assembler to equate two values. */ 346102780Skan#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 347102780Skan do { fprintf ((FILE), "%s", SET_ASM_OP); \ 348102780Skan RS6000_OUTPUT_BASENAME (FILE, LABEL1); \ 349102780Skan fprintf (FILE, ","); \ 350102780Skan RS6000_OUTPUT_BASENAME (FILE, LABEL2); \ 351102780Skan fprintf (FILE, "\n"); \ 352102780Skan } while (0) 353102780Skan 35490075Sobrien/* Used by rs6000_assemble_integer, among others. */ 35590075Sobrien#define DOUBLE_INT_ASM_OP "\t.llong\t" 35690075Sobrien 35790075Sobrien/* Output before instructions. */ 35890075Sobrien#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]" 35990075Sobrien 36090075Sobrien/* Output before writable data. 36190075Sobrien Align entire section to BIGGEST_ALIGNMENT. */ 36290075Sobrien#define DATA_SECTION_ASM_OP "\t.csect .data[RW],3" 36390075Sobrien 36490075Sobrien/* Define the name of the section to use for the EH language specific 36590075Sobrien data areas (.gcc_except_table on most other systems). */ 36690075Sobrien#define TARGET_ASM_EXCEPTION_SECTION data_section 36790075Sobrien 36890075Sobrien/* Define to prevent DWARF2 unwind info in the data section rather 36990075Sobrien than in the .eh_frame section. We do this because the AIX linker 37090075Sobrien would otherwise garbage collect these sections. */ 37190075Sobrien#define EH_FRAME_IN_DATA_SECTION 1 372