OSDN Git Service

PR c++/19797
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / som.h
index a87b2fd..d937876 100644 (file)
@@ -1,5 +1,6 @@
 /* Definitions for SOM assembler support.
-   Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
+   Inc.
 
 This file is part of GCC.
 
@@ -27,33 +28,11 @@ Boston, MA 02111-1307, USA.  */
    from other embedded stabs implementations.  */
 #undef DBX_USE_BINCL
 
-/* We make the first line stab special to avoid adding several
-   gross hacks to GAS.  */
-#undef  ASM_OUTPUT_SOURCE_LINE
-#define ASM_OUTPUT_SOURCE_LINE(file, line, counter)            \
-  { static tree last_function_decl = NULL;                     \
-    if (current_function_decl == last_function_decl)           \
-      {                                                                \
-       rtx func = DECL_RTL (current_function_decl);            \
-       const char *name = XSTR (XEXP (func, 0), 0);            \
-       fprintf (file, "\t.stabn 68,0,%d,L$M%d-%s\nL$M%d:\n",   \
-                line, counter,                                 \
-                (* targetm.strip_name_encoding) (name),        \
-                counter);                                      \
-      }                                                                \
-    else                                                       \
-      fprintf (file, "\t.stabn 68,0,%d,0\n", line);            \
-    last_function_decl = current_function_decl;                        \
-  }
+#define DBX_LINES_FUNCTION_RELATIVE 1
 
 /* gdb needs a null N_SO at the end of each file for scattered loading.  */
 
-#undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
-#define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
-  text_section (); \
-  fputs ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
-  fprintf (FILE,                                                       \
-          "\t.stabs \"\",%d,0,0,L$text_end0000\nL$text_end0000:\n", N_SO)
+#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
 
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
@@ -206,84 +185,15 @@ do {                                                              \
 
 #define TARGET_ASM_FILE_START pa_som_file_start
 
-/* Select and return a TEXT_SECTION_ASM_OP string.  */
+/* String to output before text.  */
 #define TEXT_SECTION_ASM_OP som_text_section_asm_op ()
 
-/* Output before code in the default text section.  */
-#define DEFAULT_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$"
-
-/* Output before text in a new subspace.  This allows the linker to
-   place stubs between functions.  */
-#define NEW_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$"
-    
-/* Output before text in a new one-only subspace.  */
-#define ONE_ONLY_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\
-\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,SORT=24,COMDAT"
-
-/* Output before read-only data.  */
-#define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n"
-
-/* Output before one-only readonly data.  We make readonly data one only
-   by creating a new $LIT$ subspace in $TEXT$ with the comdat flag.  */
-#define ONE_ONLY_READONLY_DATA_SECTION_ASM_OP "\t.SPACE $TEXT$\n\
-\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=16,COMDAT\n"
-
-/* Output before writable data.  */
+/* String to output before writable data.  */
 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
 
-/* Output before one-only data.  We make data one only by creating
-   a new $DATA$ subspace in $PRIVATE$ with the comdat flag.  */
-#define ONE_ONLY_DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\
-\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=24,COMDAT\n"
-
-/* Output before uninitialized data.  */
+/* String to output before uninitialized data.  */
 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
 
-#define EXTRA_SECTIONS                                                 \
-  in_readonly_data,                                                    \
-  in_one_only_readonly_data,                                           \
-  in_one_only_data
-
-#define EXTRA_SECTION_FUNCTIONS                                                \
-  READONLY_DATA_FUNCTION                                               \
-  ONE_ONLY_READONLY_DATA_SECTION_FUNCTION                              \
-  ONE_ONLY_DATA_SECTION_FUNCTION                                       \
-  FORGET_SECTION_FUNCTION
-
-#define READONLY_DATA_FUNCTION                                         \
-void                                                                   \
-readonly_data (void)                                                   \
-{                                                                      \
-  if (in_section != in_readonly_data)                                  \
-    {                                                                  \
-      in_section = in_readonly_data;                                   \
-      fputs (READONLY_DATA_ASM_OP, asm_out_file);                      \
-    }                                                                  \
-}                                                                      \
-
-#define ONE_ONLY_READONLY_DATA_SECTION_FUNCTION                                \
-void                                                                   \
-one_only_readonly_data_section (void)                                  \
-{                                                                      \
-  in_section = in_one_only_readonly_data;                              \
-  fputs (ONE_ONLY_READONLY_DATA_SECTION_ASM_OP, asm_out_file);         \
-}                                                                      \
-
-#define ONE_ONLY_DATA_SECTION_FUNCTION                                 \
-void                                                                   \
-one_only_data_section (void)                                           \
-{                                                                      \
-  in_section = in_one_only_data;                                       \
-  fputs (ONE_ONLY_DATA_SECTION_ASM_OP, asm_out_file);                  \
-}
-
-#define FORGET_SECTION_FUNCTION                                                \
-void                                                                   \
-forget_section (void)                                                  \
-{                                                                      \
-  in_section = no_section;                                             \
-}                                                                      \
-
 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
    which reference data within the $TEXT$ space (for example constant
    strings in the $LIT$ subspace).
@@ -296,7 +206,8 @@ forget_section (void)                                                       \
    $TEXT$ space during PIC generation.  Instead place all constant
    data into the $PRIVATE$ subspace (this reduces sharing, but it
    works correctly).  */
-#define READONLY_DATA_SECTION (flag_pic ? data_section : readonly_data)
+#define READONLY_DATA_SECTION \
+  (flag_pic ? data_section : som_readonly_data_section)
 
 /* We must not have a reference to an external symbol defined in a
    shared library in a readonly section, else the SOM linker will
@@ -305,38 +216,47 @@ forget_section (void)                                                     \
    So, we force exception information into the data section.  */
 #define TARGET_ASM_EXCEPTION_SECTION data_section
 
-/* This is how to output a command to make the user-level label named NAME
-   defined for reference from other files.
-
-   We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED.  This
-   macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
-   placing useless function definitions in the output file.
-
-   Also note that the SOM based tools need the symbol imported as a CODE
-   symbol, while the ELF based tools require the symbol to be imported as
-   an ENTRY symbol.  What a crock.  */
-
-#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)  \
-  do { int save_referenced;                                    \
-       save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
-       fputs ("\t.IMPORT ", FILE);                             \
-       assemble_name (FILE, NAME);                             \
-       if (FUNCTION_NAME_P (NAME))                                     \
-        fputs (",CODE\n", FILE);                               \
-       else                                                    \
-        fputs (",DATA\n", FILE);                               \
-       TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
+/* This is how to output a command to make the user-level label
+   named NAME defined for reference from other files.  We use
+   assemble_name_raw instead of assemble_name since a symbol in
+   a .IMPORT directive that isn't otherwise referenced is not
+   placed in the symbol table of the assembled object.
+
+   Failure to import a function reference can cause the HP linker
+   to segmentation fault!
+
+   Note that the SOM based tools need the symbol imported as a
+   CODE symbol, while the ELF based tools require the symbol to
+   be imported as an ENTRY symbol.  */
+
+#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
+  pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
+#define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
+  do { fputs ("\t.IMPORT ", FILE);                                     \
+       assemble_name_raw (FILE, NAME);                                 \
+       if (FUNCTION_NAME_P (NAME))                                     \
+        fputs (",CODE\n", FILE);                                       \
+       else                                                            \
+        fputs (",DATA\n", FILE);                                       \
      } while (0)
 
 /* The bogus HP assembler requires ALL external references to be
-   "imported", even library calls. They look a bit different, so
+   "imported", even library calls.  They look a bit different, so
    here's this macro.
 
    Also note not all libcall names are passed to pa_encode_section_info
    (__main for example).  To make sure all libcall names have section
-   info recorded in them, we do it here.  We must also ensure that
-   we don't import a libcall that has been previously exported since
-   the HP assembler may change an ENTRY symbol to a CODE symbol.  */
+   info recorded in them, we do it here.
+
+   We must also ensure that a libcall that has been previously
+   exported is not subsequently imported since the HP assembler may
+   change the type from an ENTRY to a CODE symbol.  This would make
+   the symbol local.  We are forced to use the identifier node
+   associated with the real assembler name for this check as the
+   symbol_ref available in ASM_DECLARE_FUNCTION_NAME is not the
+   same as the one used here.  As a result, we can't use flags
+   in the symbol_ref for this check.  The identifier check assumes
+   assemble_external_libcall is called before the symbol is used.  */
 
 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
   do { const char *name;                                               \
@@ -345,12 +265,12 @@ forget_section (void)                                                     \
        if (!function_label_operand (RTL, VOIDmode))                    \
         hppa_encode_label (RTL);                                       \
                                                                        \
-       name = (*targetm.strip_name_encoding) (XSTR ((RTL), 0));                \
+       name = targetm.strip_name_encoding (XSTR ((RTL), 0));           \
        id = maybe_get_identifier (name);                               \
-       if (! id || ! TREE_SYMBOL_REFERENCED (id))                      \
+       if (!id || !TREE_SYMBOL_REFERENCED (id))                                \
         {                                                              \
           fputs ("\t.IMPORT ", FILE);                                  \
-          assemble_name (FILE, XSTR ((RTL), 0));                       \
+          assemble_name_raw (FILE, XSTR ((RTL), 0));                   \
           fputs (",CODE\n", FILE);                                     \
         }                                                              \
      } while (0)
@@ -377,11 +297,9 @@ do {                                               \
    The .align directive in the HP assembler allows alignments up to 4096
    bytes.  However, the maximum alignment of a global common symbol is 8
    bytes for objects smaller than the page size (4096 bytes).  For larger
-   objects, the linker provides an alignment of 32 bytes.  */
-#define MAX_OFILE_ALIGNMENT                                            \
-  (TREE_PUBLIC (decl) && DECL_COMMON (decl)                            \
-   ? (host_integerp (DECL_SIZE_UNIT (decl), 1) >= 4096 ? 256 : 64)     \
-   : 32768)
+   objects, the linker provides an alignment of 32 bytes.  Unfortunately,
+   this macro doesn't provide a mechanism to test for common symbols.  */
+#define MAX_OFILE_ALIGNMENT 32768
 
 /* The SOM linker hardcodes paths into binaries.  As a result, dotdots
    must be removed from library prefixes to prevent binaries from depending
@@ -401,11 +319,30 @@ do {                                              \
 #define SUPPORTS_WEAK 0
 #endif
 
-/* We can support one only if we support weak.  */
-#define SUPPORTS_ONE_ONLY SUPPORTS_WEAK
+/* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
+   directive.  This provides one-only linkage semantics even though we
+   don't have weak support.  */
+#ifdef HAVE_GAS_NSUBSPA_COMDAT
+#define SUPPORTS_SOM_COMDAT (TARGET_GAS)
+#else
+#define SUPPORTS_SOM_COMDAT 0
+#endif
 
-/* Use weak (secondary definitions) to make one only declarations.  */
-#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
+/* We can support one only if we support weak or comdat.  */
+#define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
+
+/* We use DECL_COMMON for uninitialized one-only variables as we don't
+   have linkonce .bss.  We use SOM secondary definitions or comdat for
+   initialized variables and functions.  */
+#define MAKE_DECL_ONE_ONLY(DECL) \
+  do {                                                                 \
+    if (TREE_CODE (DECL) == VAR_DECL                                   \
+        && (DECL_INITIAL (DECL) == 0                                   \
+            || DECL_INITIAL (DECL) == error_mark_node))                        \
+      DECL_COMMON (DECL) = 1;                                          \
+    else if (SUPPORTS_WEAK)                                            \
+      DECL_WEAK (DECL) = 1;                                            \
+  } while (0)
 
 /* This is how we tell the assembler that a symbol is weak.  The SOM
    weak implementation uses the secondary definition (sdef) flag.
@@ -430,12 +367,7 @@ do {                                               \
   do { fputs ("\t.weak\t", FILE);                              \
        assemble_name (FILE, NAME);                             \
        fputc ('\n', FILE);                                     \
-       if (! FUNCTION_NAME_P (NAME))                           \
-        {                                                      \
-          fputs ("\t.EXPORT ", FILE);                          \
-          assemble_name (FILE, NAME);                          \
-          fputs (",DATA\n", FILE);                             \
-        }                                                      \
+       targetm.asm_out.globalize_label (FILE, NAME);           \
   } while (0)
 
 /* We can't handle weak aliases, and therefore can't support pragma weak.