Home | History | Annotate | Line # | Download | only in rs6000
xcoff.h revision 1.6
      1  1.1  mrg /* Definitions of target machine for GNU compiler,
      2  1.1  mrg    for some generic XCOFF file format
      3  1.6  mrg    Copyright (C) 2001-2016 Free Software Foundation, Inc.
      4  1.1  mrg 
      5  1.1  mrg    This file is part of GCC.
      6  1.1  mrg 
      7  1.1  mrg    GCC is free software; you can redistribute it and/or modify it
      8  1.1  mrg    under the terms of the GNU General Public License as published
      9  1.1  mrg    by the Free Software Foundation; either version 3, or (at your
     10  1.1  mrg    option) any later version.
     11  1.1  mrg 
     12  1.1  mrg    GCC is distributed in the hope that it will be useful, but WITHOUT
     13  1.1  mrg    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     14  1.1  mrg    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
     15  1.1  mrg    License for more details.
     16  1.1  mrg 
     17  1.1  mrg    You should have received a copy of the GNU General Public License
     18  1.1  mrg    along with GCC; see the file COPYING3.  If not see
     19  1.1  mrg    <http://www.gnu.org/licenses/>.  */
     20  1.1  mrg 
     21  1.1  mrg #define TARGET_OBJECT_FORMAT OBJECT_XCOFF
     22  1.1  mrg 
     23  1.1  mrg /* The RS/6000 uses the XCOFF format.  */
     24  1.1  mrg #define XCOFF_DEBUGGING_INFO 1
     25  1.1  mrg 
     26  1.1  mrg /* Define if the object format being used is COFF or a superset.  */
     27  1.1  mrg #define OBJECT_FORMAT_COFF
     28  1.1  mrg 
     29  1.1  mrg /* Define the magic numbers that we recognize as COFF.
     30  1.1  mrg 
     31  1.1  mrg     AIX 4.3 adds U803XTOCMAGIC (0757) for 64-bit objects and AIX V5 adds
     32  1.1  mrg     U64_TOCMAGIC (0767), but collect2.c does not include files in the
     33  1.1  mrg     correct order to conditionally define the symbolic name in this macro.
     34  1.1  mrg 
     35  1.1  mrg     The AIX linker accepts import/export files as object files,
     36  1.1  mrg     so accept "#!" (0x2321) magic number.  */
     37  1.1  mrg #define MY_ISCOFF(magic) \
     38  1.1  mrg   ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC \
     39  1.1  mrg    || (magic) == U802TOCMAGIC || (magic) == 0757 || (magic) == 0767 \
     40  1.1  mrg    || (magic) == 0x2321)
     41  1.1  mrg 
     42  1.1  mrg /* We don't have GAS for the RS/6000 yet, so don't write out special
     43  1.1  mrg     .stabs in cc1plus.  */
     44  1.1  mrg 
     45  1.1  mrg #define FASCIST_ASSEMBLER
     46  1.1  mrg 
     47  1.1  mrg /* We define this to prevent the name mangler from putting dollar signs into
     48  1.1  mrg    function names.  */
     49  1.1  mrg 
     50  1.1  mrg #define NO_DOLLAR_IN_LABEL
     51  1.1  mrg 
     52  1.1  mrg /* We define this to 0 so that gcc will never accept a dollar sign in a
     53  1.1  mrg    variable name.  This is needed because the AIX assembler will not accept
     54  1.1  mrg    dollar signs.  */
     55  1.1  mrg 
     56  1.1  mrg #define DOLLARS_IN_IDENTIFIERS 0
     57  1.1  mrg 
     58  1.1  mrg /* AIX .align pseudo-op accept value from 0 to 12, corresponding to
     59  1.1  mrg    log base 2 of the alignment in bytes; 12 = 4096 bytes = 32768 bits.  */
     60  1.1  mrg 
     61  1.1  mrg #define MAX_OFILE_ALIGNMENT 32768
     62  1.1  mrg 
     63  1.1  mrg /* Default alignment factor for csect directives, chosen to honor
     64  1.1  mrg    BIGGEST_ALIGNMENT.  */
     65  1.1  mrg #define XCOFF_CSECT_DEFAULT_ALIGNMENT_STR "4"
     66  1.1  mrg 
     67  1.1  mrg /* Return nonzero if this entry is to be written into the constant
     68  1.1  mrg    pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
     69  1.1  mrg    or a CONST containing one of them.  If -mfp-in-toc (the default),
     70  1.1  mrg    we also do this for floating-point constants.  We actually can only
     71  1.1  mrg    do this if the FP formats of the target and host machines are the
     72  1.1  mrg    same, but we can't check that since not every file that uses these
     73  1.1  mrg    target macros includes real.h.  We also do this when we can write the
     74  1.1  mrg    entry into the TOC and the entry is not larger than a TOC entry.  */
     75  1.1  mrg 
     76  1.1  mrg #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)			\
     77  1.1  mrg   (TARGET_TOC								\
     78  1.1  mrg    && (GET_CODE (X) == SYMBOL_REF					\
     79  1.1  mrg        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS	\
     80  1.1  mrg 	   && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)		\
     81  1.1  mrg        || GET_CODE (X) == LABEL_REF					\
     82  1.1  mrg        || (GET_CODE (X) == CONST_INT 					\
     83  1.1  mrg 	   && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))	\
     84  1.1  mrg        || (GET_CODE (X) == CONST_DOUBLE					\
     85  1.1  mrg 	   && (TARGET_MINIMAL_TOC					\
     86  1.1  mrg 	       || (SCALAR_FLOAT_MODE_P (GET_MODE (X))			\
     87  1.1  mrg 		   && ! TARGET_NO_FP_IN_TOC)))))
     88  1.1  mrg 
     89  1.6  mrg #undef TARGET_DEBUG_UNWIND_INFO
     90  1.6  mrg #define TARGET_DEBUG_UNWIND_INFO  rs6000_xcoff_debug_unwind_info
     91  1.1  mrg #define TARGET_ASM_OUTPUT_ANCHOR  rs6000_xcoff_asm_output_anchor
     92  1.1  mrg #define TARGET_ASM_GLOBALIZE_LABEL  rs6000_xcoff_asm_globalize_label
     93  1.1  mrg #define TARGET_ASM_INIT_SECTIONS  rs6000_xcoff_asm_init_sections
     94  1.1  mrg #define TARGET_ASM_RELOC_RW_MASK  rs6000_xcoff_reloc_rw_mask
     95  1.1  mrg #define TARGET_ASM_NAMED_SECTION  rs6000_xcoff_asm_named_section
     96  1.1  mrg #define TARGET_ASM_SELECT_SECTION  rs6000_xcoff_select_section
     97  1.1  mrg #define TARGET_ASM_SELECT_RTX_SECTION  rs6000_xcoff_select_rtx_section
     98  1.1  mrg #define TARGET_ASM_UNIQUE_SECTION  rs6000_xcoff_unique_section
     99  1.1  mrg #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
    100  1.1  mrg #define TARGET_STRIP_NAME_ENCODING  rs6000_xcoff_strip_name_encoding
    101  1.1  mrg #define TARGET_SECTION_TYPE_FLAGS  rs6000_xcoff_section_type_flags
    102  1.3  mrg #ifdef HAVE_AS_TLS
    103  1.3  mrg #define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
    104  1.3  mrg #endif
    105  1.1  mrg 
    106  1.1  mrg /* FP save and restore routines.  */
    107  1.1  mrg #define	SAVE_FP_PREFIX "._savef"
    108  1.1  mrg #define SAVE_FP_SUFFIX ""
    109  1.1  mrg #define	RESTORE_FP_PREFIX "._restf"
    110  1.1  mrg #define RESTORE_FP_SUFFIX ""
    111  1.1  mrg 
    112  1.1  mrg /* Function name to call to do profiling.  */
    113  1.1  mrg #undef  RS6000_MCOUNT
    114  1.1  mrg #define RS6000_MCOUNT ".__mcount"
    115  1.1  mrg 
    116  1.1  mrg /* This outputs NAME to FILE up to the first null or '['.  */
    117  1.1  mrg 
    118  1.1  mrg #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
    119  1.1  mrg   assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME))
    120  1.1  mrg 
    121  1.1  mrg /* This is how to output the definition of a user-level label named NAME,
    122  1.1  mrg    such as the label on a static function or variable NAME.  */
    123  1.1  mrg 
    124  1.1  mrg #define ASM_OUTPUT_LABEL(FILE,NAME)	\
    125  1.1  mrg   do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
    126  1.1  mrg 
    127  1.1  mrg /* This is how to output a command to make the user-level label named NAME
    128  1.1  mrg    defined for reference from other files.  */
    129  1.1  mrg 
    130  1.1  mrg /* Globalizing directive for a label.  */
    131  1.1  mrg #define GLOBAL_ASM_OP "\t.globl "
    132  1.1  mrg 
    133  1.1  mrg #undef TARGET_ASM_FILE_START
    134  1.1  mrg #define TARGET_ASM_FILE_START rs6000_xcoff_file_start
    135  1.1  mrg #define TARGET_ASM_FILE_END rs6000_xcoff_file_end
    136  1.1  mrg #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
    137  1.1  mrg #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
    138  1.1  mrg 
    139  1.5  mrg /* This macro produces the initial definition of a function name.  */
    140  1.5  mrg 
    141  1.5  mrg #undef ASM_DECLARE_FUNCTION_NAME
    142  1.5  mrg #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
    143  1.5  mrg   rs6000_xcoff_declare_function_name ((FILE), (NAME), (DECL))
    144  1.5  mrg #undef ASM_DECLARE_OBJECT_NAME
    145  1.5  mrg #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
    146  1.5  mrg   rs6000_xcoff_declare_object_name ((FILE), (NAME), (DECL))
    147  1.1  mrg 
    148  1.1  mrg /* Output a reference to SYM on FILE.  */
    149  1.1  mrg 
    150  1.1  mrg #define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
    151  1.1  mrg   rs6000_output_symbol_ref (FILE, SYM)
    152  1.1  mrg 
    153  1.1  mrg /* This says how to output an external.
    154  1.1  mrg    Dollar signs are converted to underscores.  */
    155  1.1  mrg 
    156  1.1  mrg #undef  ASM_OUTPUT_EXTERNAL
    157  1.1  mrg #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)				\
    158  1.1  mrg { char *buffer = (char *) alloca (strlen (NAME) + 1);			\
    159  1.1  mrg   char *p;								\
    160  1.1  mrg   int dollar_inside = 0;						\
    161  1.1  mrg   strcpy (buffer, NAME);						\
    162  1.1  mrg   p = strchr (buffer, '$');						\
    163  1.1  mrg   while (p) {								\
    164  1.1  mrg     *p = '_';								\
    165  1.1  mrg     dollar_inside++;							\
    166  1.1  mrg     p = strchr (p + 1, '$');						\
    167  1.1  mrg   }									\
    168  1.1  mrg   if (dollar_inside) {							\
    169  1.1  mrg       fputs ("\t.extern .", FILE);					\
    170  1.1  mrg       RS6000_OUTPUT_BASENAME (FILE, buffer);				\
    171  1.1  mrg       putc ('\n', FILE);						\
    172  1.1  mrg       fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME);		\
    173  1.1  mrg     }									\
    174  1.1  mrg }
    175  1.1  mrg 
    176  1.1  mrg /* This is how to output a reference to a user-level label named NAME.
    177  1.1  mrg    `assemble_name' uses this.  */
    178  1.1  mrg 
    179  1.1  mrg #define ASM_OUTPUT_LABELREF(FILE,NAME)	\
    180  1.1  mrg   asm_fprintf ((FILE), "%U%s", rs6000_xcoff_strip_dollar (NAME));
    181  1.1  mrg 
    182  1.1  mrg /* This is how to output an internal label prefix.  rs6000.c uses this
    183  1.1  mrg    when generating traceback tables.  */
    184  1.1  mrg 
    185  1.1  mrg #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
    186  1.1  mrg   fprintf (FILE, "%s..", PREFIX)
    187  1.1  mrg 
    188  1.1  mrg /* This is how to output a label for a jump table.  Arguments are the same as
    189  1.1  mrg    for (*targetm.asm_out.internal_label), except the insn for the jump table is
    190  1.1  mrg    passed.  */
    191  1.1  mrg 
    192  1.1  mrg #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN)	\
    193  1.1  mrg { ASM_OUTPUT_ALIGN (FILE, 2); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); }
    194  1.1  mrg 
    195  1.1  mrg /* This is how to store into the string LABEL
    196  1.1  mrg    the symbol_ref name of an internal numbered label where
    197  1.1  mrg    PREFIX is the class of label and NUM is the number within the class.
    198  1.1  mrg    This is suitable for output with `assemble_name'.  */
    199  1.1  mrg 
    200  1.1  mrg #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
    201  1.1  mrg   sprintf (LABEL, "*%s..%u", rs6000_xcoff_strip_dollar (PREFIX), (unsigned) (NUM))
    202  1.1  mrg 
    203  1.1  mrg /* This is how to output an assembler line to define N characters starting
    204  1.1  mrg    at P to FILE.  */
    205  1.1  mrg 
    206  1.1  mrg #define ASM_OUTPUT_ASCII(FILE, P, N)  output_ascii ((FILE), (P), (N))
    207  1.1  mrg 
    208  1.1  mrg /* This is how to advance the location counter by SIZE bytes.  */
    209  1.1  mrg 
    210  1.1  mrg #define SKIP_ASM_OP "\t.space "
    211  1.1  mrg 
    212  1.1  mrg #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
    213  1.6  mrg   fprintf (FILE, "%s" HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
    214  1.1  mrg 
    215  1.1  mrg /* This says how to output an assembler line
    216  1.1  mrg    to define a global common symbol.  */
    217  1.1  mrg 
    218  1.1  mrg #define COMMON_ASM_OP "\t.comm "
    219  1.1  mrg 
    220  1.1  mrg #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)	\
    221  1.1  mrg   do { fputs (COMMON_ASM_OP, (FILE));			\
    222  1.1  mrg        RS6000_OUTPUT_BASENAME ((FILE), (NAME));		\
    223  1.1  mrg        if ((ALIGN) > 32)				\
    224  1.6  mrg 	 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \
    225  1.3  mrg 		  floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
    226  1.1  mrg        else if ((SIZE) > 4)				\
    227  1.6  mrg          fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \
    228  1.1  mrg        else						\
    229  1.6  mrg 	 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \
    230  1.1  mrg   } while (0)
    231  1.1  mrg 
    232  1.1  mrg /* This says how to output an assembler line
    233  1.1  mrg    to define a local common symbol.
    234  1.3  mrg    The assembler in AIX 6.1 and later supports an alignment argument.
    235  1.3  mrg    For earlier releases of AIX, we try to maintain
    236  1.1  mrg    alignment after preceding TOC section if it was aligned
    237  1.1  mrg    for 64-bit mode.  */
    238  1.1  mrg 
    239  1.1  mrg #define LOCAL_COMMON_ASM_OP "\t.lcomm "
    240  1.1  mrg 
    241  1.3  mrg #if TARGET_AIX_VERSION >= 61
    242  1.3  mrg #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)	\
    243  1.3  mrg   do { fputs (LOCAL_COMMON_ASM_OP, (FILE));			\
    244  1.3  mrg        RS6000_OUTPUT_BASENAME ((FILE), (NAME));			\
    245  1.3  mrg        if ((ALIGN) > 32)					\
    246  1.6  mrg 	 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s%u_,%u\n",	\
    247  1.3  mrg 		  (SIZE), xcoff_bss_section_name,			\
    248  1.3  mrg 		  floor_log2 ((ALIGN) / BITS_PER_UNIT),			\
    249  1.3  mrg 		  floor_log2 ((ALIGN) / BITS_PER_UNIT));		\
    250  1.3  mrg        else if ((SIZE) > 4)					\
    251  1.6  mrg 	 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s3_,3\n",	\
    252  1.3  mrg 		  (SIZE), xcoff_bss_section_name);		\
    253  1.3  mrg        else							\
    254  1.6  mrg 	 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s,2\n",	\
    255  1.3  mrg 		  (SIZE), xcoff_bss_section_name);		\
    256  1.3  mrg      } while (0)
    257  1.3  mrg #endif
    258  1.3  mrg 
    259  1.1  mrg #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)	\
    260  1.1  mrg   do { fputs (LOCAL_COMMON_ASM_OP, (FILE));		\
    261  1.1  mrg        RS6000_OUTPUT_BASENAME ((FILE), (NAME));		\
    262  1.6  mrg        fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s\n", \
    263  1.1  mrg 		(TARGET_32BIT ? (SIZE) : (ROUNDED)),	\
    264  1.1  mrg 		xcoff_bss_section_name);		\
    265  1.1  mrg      } while (0)
    266  1.1  mrg 
    267  1.3  mrg #ifdef HAVE_AS_TLS
    268  1.3  mrg #define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)	\
    269  1.6  mrg   do { fputs (COMMON_ASM_OP, (FILE));			\
    270  1.3  mrg        RS6000_OUTPUT_BASENAME ((FILE), (NAME));		\
    271  1.6  mrg        fprintf ((FILE), "[UL]," HOST_WIDE_INT_PRINT_UNSIGNED"\n", \
    272  1.3  mrg        (SIZE));						\
    273  1.3  mrg   } while (0)
    274  1.3  mrg #endif
    275  1.3  mrg 
    276  1.1  mrg /* This is how we tell the assembler that two symbols have the same value.  */
    277  1.1  mrg #define SET_ASM_OP "\t.set "
    278  1.1  mrg 
    279  1.5  mrg /* This is how we tell the assembler to equate two values.
    280  1.5  mrg    The semantic of AIX assembler's .set do not correspond to middle-end expectations.
    281  1.5  mrg    We output aliases as alternative symbols in the front of the definition
    282  1.5  mrg    via DECLARE_FUNCTION_NAME and DECLARE_OBJECT_NAME.
    283  1.5  mrg    We still need to define this macro to let middle-end know that aliases are
    284  1.5  mrg    supported.
    285  1.5  mrg  */
    286  1.5  mrg #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) do { } while (0)
    287  1.5  mrg 
    288  1.5  mrg /* Used by rs6000_assemble_integer, among others.  */
    289  1.1  mrg 
    290  1.1  mrg /* Used by rs6000_assemble_integer, among others.  */
    291  1.1  mrg #define DOUBLE_INT_ASM_OP "\t.llong\t"
    292  1.1  mrg 
    293  1.1  mrg /* Output before instructions.  */
    294  1.1  mrg #define TEXT_SECTION_ASM_OP "\t.csect .text[PR]"
    295  1.1  mrg 
    296  1.1  mrg /* Output before writable data.  */
    297  1.1  mrg #define DATA_SECTION_ASM_OP \
    298  1.1  mrg   "\t.csect .data[RW]," XCOFF_CSECT_DEFAULT_ALIGNMENT_STR
    299  1.1  mrg 
    300  1.1  mrg 
    301  1.6  mrg /* The eh_frames are put in the read-only text segment.
    302  1.6  mrg    Local code labels/function will also be in the local text segment so use
    303  1.6  mrg    PC relative addressing.
    304  1.6  mrg    Global symbols must be in the data segment to allow loader relocations.
    305  1.6  mrg    So use DW_EH_PE_indirect to allocate a slot in the local data segment.
    306  1.6  mrg    There is no constant offset to this data segment from the text segment,
    307  1.6  mrg    so use addressing relative to the data segment.
    308  1.6  mrg  */
    309  1.6  mrg #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
    310  1.6  mrg   (((GLOBAL) ? DW_EH_PE_indirect | DW_EH_PE_datarel : DW_EH_PE_pcrel) \
    311  1.6  mrg    | (TARGET_64BIT ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4))
    312  1.6  mrg 
    313  1.6  mrg #define EH_FRAME_THROUGH_COLLECT2 1
    314  1.6  mrg #define EH_TABLES_CAN_BE_READ_ONLY 1
    315  1.6  mrg 
    316  1.6  mrg /* AIX Assembler implicitly assumes DWARF 64 bit extension in 64 bit mode.  */
    317  1.6  mrg #define DWARF_OFFSET_SIZE PTR_SIZE
    318  1.6  mrg 
    319  1.6  mrg #define ASM_OUTPUT_DWARF_PCREL(FILE,SIZE,LABEL) \
    320  1.6  mrg   rs6000_asm_output_dwarf_pcrel ((FILE), (SIZE), (LABEL));
    321  1.6  mrg 
    322  1.6  mrg #define ASM_OUTPUT_DWARF_DATAREL(FILE,SIZE,LABEL) \
    323  1.6  mrg   rs6000_asm_output_dwarf_datarel ((FILE), (SIZE), (LABEL));
    324  1.5  mrg 
    325  1.5  mrg #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
    326  1.5  mrg 
    327