diff options
Diffstat (limited to 'gcc/config/pa/som.h')
-rw-r--r-- | gcc/config/pa/som.h | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h index e06a0912493..d937876d0e5 100644 --- a/gcc/config/pa/som.h +++ b/gcc/config/pa/som.h @@ -216,38 +216,47 @@ do { \ 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; \ @@ -261,7 +270,7 @@ do { \ 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) @@ -358,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. |