xref: /openbsd/gnu/usr.bin/gcc/gcc/config/pa/elf.h (revision c87b03e5)
1*c87b03e5Sespie /* Definitions for ELF assembler support.
2*c87b03e5Sespie    Copyright (C) 1999 Free Software Foundation, Inc.
3*c87b03e5Sespie 
4*c87b03e5Sespie This file is part of GNU CC.
5*c87b03e5Sespie 
6*c87b03e5Sespie GNU CC is free software; you can redistribute it and/or modify
7*c87b03e5Sespie it under the terms of the GNU General Public License as published by
8*c87b03e5Sespie the Free Software Foundation; either version 2, or (at your option)
9*c87b03e5Sespie any later version.
10*c87b03e5Sespie 
11*c87b03e5Sespie GNU CC is distributed in the hope that it will be useful,
12*c87b03e5Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c87b03e5Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*c87b03e5Sespie GNU General Public License for more details.
15*c87b03e5Sespie 
16*c87b03e5Sespie You should have received a copy of the GNU General Public License
17*c87b03e5Sespie along with GNU CC; see the file COPYING.  If not, write to
18*c87b03e5Sespie the Free Software Foundation, 59 Temple Place - Suite 330,
19*c87b03e5Sespie Boston, MA 02111-1307, USA.  */
20*c87b03e5Sespie 
21*c87b03e5Sespie /* So we can conditionalize small amounts of code in pa.c or pa.md.  */
22*c87b03e5Sespie #define OBJ_ELF
23*c87b03e5Sespie 
24*c87b03e5Sespie #define ENDFILE_SPEC "crtend.o%s"
25*c87b03e5Sespie 
26*c87b03e5Sespie #define STARTFILE_SPEC "%{!shared: \
27*c87b03e5Sespie 			 %{!symbolic: \
28*c87b03e5Sespie 			  %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
29*c87b03e5Sespie 			crtbegin.o%s"
30*c87b03e5Sespie 
31*c87b03e5Sespie #define TEXT_SECTION_ASM_OP "\t.text"
32*c87b03e5Sespie #define DATA_SECTION_ASM_OP "\t.data"
33*c87b03e5Sespie #define BSS_SECTION_ASM_OP "\t.section\t.bss"
34*c87b03e5Sespie 
35*c87b03e5Sespie #undef ASM_FILE_START
36*c87b03e5Sespie #define ASM_FILE_START(FILE) \
37*c87b03e5Sespie do {  \
38*c87b03e5Sespie      if (TARGET_PA_20) \
39*c87b03e5Sespie        fputs("\t.LEVEL 2.0\n", FILE); \
40*c87b03e5Sespie      else if (TARGET_PA_11) \
41*c87b03e5Sespie        fputs("\t.LEVEL 1.1\n", FILE); \
42*c87b03e5Sespie      else \
43*c87b03e5Sespie        fputs("\t.LEVEL 1.0\n", FILE); \
44*c87b03e5Sespie      if (profile_flag)\
45*c87b03e5Sespie        fprintf (FILE, "\t.IMPORT _mcount, ENTRY\n");\
46*c87b03e5Sespie      if (write_symbols != NO_DEBUG) \
47*c87b03e5Sespie        output_file_directive ((FILE), main_input_filename); \
48*c87b03e5Sespie    } while (0)
49*c87b03e5Sespie 
50*c87b03e5Sespie #undef ASM_DECLARE_FUNCTION_NAME
51*c87b03e5Sespie #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
52*c87b03e5Sespie do {  \
53*c87b03e5Sespie   if (TREE_PUBLIC (DECL)) \
54*c87b03e5Sespie     { \
55*c87b03e5Sespie       fputs ("\t.EXPORT ", FILE); \
56*c87b03e5Sespie       assemble_name (FILE, NAME); \
57*c87b03e5Sespie       fputs (",ENTRY\n", FILE); \
58*c87b03e5Sespie     } \
59*c87b03e5Sespie    } while (0)
60*c87b03e5Sespie 
61*c87b03e5Sespie /* This is how to output a command to make the user-level label named NAME
62*c87b03e5Sespie    defined for reference from other files.
63*c87b03e5Sespie 
64*c87b03e5Sespie    We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED.  This
65*c87b03e5Sespie    macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
66*c87b03e5Sespie    placing useless function definitions in the output file.
67*c87b03e5Sespie 
68*c87b03e5Sespie    Also note that the SOM based tools need the symbol imported as a CODE
69*c87b03e5Sespie    symbol, while the ELF based tools require the symbol to be imported as
70*c87b03e5Sespie    an ENTRY symbol.  What a crock.  */
71*c87b03e5Sespie 
72*c87b03e5Sespie #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)	\
73*c87b03e5Sespie   do { int save_referenced;					\
74*c87b03e5Sespie        save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
75*c87b03e5Sespie        fputs ("\t.IMPORT ", FILE);					\
76*c87b03e5Sespie 	 assemble_name (FILE, NAME);				\
77*c87b03e5Sespie        if (FUNCTION_NAME_P (NAME))     				\
78*c87b03e5Sespie 	 fputs (",ENTRY\n", FILE);				\
79*c87b03e5Sespie        else							\
80*c87b03e5Sespie 	 fputs (",DATA\n", FILE);				\
81*c87b03e5Sespie        TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
82*c87b03e5Sespie      } while (0)
83*c87b03e5Sespie 
84*c87b03e5Sespie /* The bogus HP assembler requires ALL external references to be
85*c87b03e5Sespie    "imported", even library calls. They look a bit different, so
86*c87b03e5Sespie    here's this macro.
87*c87b03e5Sespie 
88*c87b03e5Sespie    Also note not all libcall names are passed to
89*c87b03e5Sespie    targetm.encode_section_info (__main for example).  To make sure all
90*c87b03e5Sespie    libcall names have section info recorded in them, we do it here.  */
91*c87b03e5Sespie 
92*c87b03e5Sespie #undef ASM_OUTPUT_EXTERNAL_LIBCALL
93*c87b03e5Sespie #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
94*c87b03e5Sespie   do { fputs ("\t.IMPORT ", FILE);					\
95*c87b03e5Sespie        if (!function_label_operand (RTL, VOIDmode))			\
96*c87b03e5Sespie 	 hppa_encode_label (RTL);					\
97*c87b03e5Sespie        assemble_name (FILE, XSTR ((RTL), 0));		       		\
98*c87b03e5Sespie        fputs (",ENTRY\n", FILE);					\
99*c87b03e5Sespie      } while (0)
100*c87b03e5Sespie 
101*c87b03e5Sespie /* Biggest alignment supported by the object file format of this
102*c87b03e5Sespie    machine.  Use this macro to limit the alignment which can be
103*c87b03e5Sespie    specified using the `__attribute__ ((aligned (N)))' construct.  If
104*c87b03e5Sespie    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
105*c87b03e5Sespie #define MAX_OFILE_ALIGNMENT (32768 * 8)
106