Index: defaults.h =================================================================== --- defaults.h (revision 116106) +++ defaults.h (working copy) @@ -355,6 +355,14 @@ #endif #endif +/* If a compilation always places functions in more than one section, + then you may need to define HAVE_MULTIPLE_FUNCTION_SECTIONS to TRUE + in your target configuration file in order to support the DWARF2 debug + format. This avoids unaligned symbol differences from being emitted. */ +#ifndef HAVE_MULTIPLE_FUNCTION_SECTIONS +#define HAVE_MULTIPLE_FUNCTION_SECTIONS false +#endif + /* If we have named section and we support weak symbols, then use the .jcr section for recording java classes which need to be registered at program start-up time. */ Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 116106) +++ dwarf2out.c (working copy) @@ -3904,7 +3904,8 @@ static GTY(()) unsigned line_info_table_in_use; /* True if the compilation unit places functions in more than one section. */ -static GTY(()) bool have_multiple_function_sections = false; +static GTY(()) bool have_multiple_function_sections + = HAVE_MULTIPLE_FUNCTION_SECTIONS; /* A pointer to the base of a table that contains line information for each source code line outside of .text in the compilation unit. */ Index: predict.c =================================================================== --- predict.c (revision 116106) +++ predict.c (working copy) @@ -1820,6 +1820,8 @@ static void choose_function_section (void) { + size_t len; + if (DECL_SECTION_NAME (current_function_decl) || !targetm.have_named_sections /* Theoretically we can split the gnu.linkonce text section too, @@ -1836,12 +1838,19 @@ return; if (cfun->function_frequency == FUNCTION_FREQUENCY_HOT) - DECL_SECTION_NAME (current_function_decl) = - build_string (strlen (HOT_TEXT_SECTION_NAME), HOT_TEXT_SECTION_NAME); + { + len = strlen (HOT_TEXT_SECTION_NAME); + if (len) + DECL_SECTION_NAME (current_function_decl) = + build_string (len, HOT_TEXT_SECTION_NAME); + } if (cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED) - DECL_SECTION_NAME (current_function_decl) = - build_string (strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME), - UNLIKELY_EXECUTED_TEXT_SECTION_NAME); + { + len = strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME); + if (len) + DECL_SECTION_NAME (current_function_decl) = + build_string (len, UNLIKELY_EXECUTED_TEXT_SECTION_NAME); + } } static bool Index: config/pa/som.h =================================================================== --- config/pa/som.h (revision 116106) +++ config/pa/som.h (working copy) @@ -23,20 +23,45 @@ #undef TARGET_SOM #define TARGET_SOM 1 +/* Finally, our preferred format is DWARF2_DEBUG! */ +#define DWARF2_DEBUGGING_INFO 1 +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG + /* We do not use BINCL stabs in SOM. ??? If it does not hurt, we probably should to avoid useless divergence from other embedded stabs implementations. */ #undef DBX_USE_BINCL -#define DBX_LINES_FUNCTION_RELATIVE 1 +/* Don't generate dbx function end. */ +#define NO_DBX_FUNCTION_END 1 -/* gdb needs a null N_SO at the end of each file for scattered loading. */ +/* Put the eh frame data in the data section. */ +#define EH_FRAME_IN_DATA_SECTION 1 -#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END +/* Provide empty names for hot and unlikely executed text sections. */ +#define HOT_TEXT_SECTION_NAME "" +#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME "" +/* The HP linker can't handle unaligned symbol differences. When a + compilation unit has multiple function sections, the DWARF2 output + code avoids emitting unaligned symbol differences. Effectively, + every function is placed in its own unnamed subspace when using + SOM. However, these subspace switches aren't noticed by + dwarf2out_begin_function (), so we need to forcibly initialize + have_multiple_function_sections to TRUE. */ +#define HAVE_MULTIPLE_FUNCTION_SECTIONS true + +#if 0 +/* If using HP ld do not call pxdb. Use size as a program that does nothing + and returns 0. /bin/true cannot be used because it is a script without + an interpreter. */ +#define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size" +#endif + /* HPUX has a program 'chatr' to list the dependencies of dynamically linked executables and shared libraries. */ #define LDD_SUFFIX "chatr" + /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl" or "static /usr/lib/X11R5/libX11.sl". @@ -176,6 +201,8 @@ #define TARGET_ASM_FILE_START pa_som_file_start #define TARGET_ASM_INIT_SECTIONS pa_som_asm_init_sections +#define TARGET_ASM_NAMED_SECTION pa_som_asm_named_section +#define TARGET_ASM_UNIQUE_SECTION pa_som_unique_section /* String to output before writable data. */ #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n" Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 116106) +++ config/pa/pa.c (working copy) @@ -108,6 +108,9 @@ static int pa_adjust_priority (rtx, int); static int pa_issue_rate (void); static void pa_som_asm_init_sections (void) ATTRIBUTE_UNUSED; +static void pa_som_asm_named_section (const char *, unsigned int, + tree) ATTRIBUTE_UNUSED; +static void pa_som_unique_section (tree, int) ATTRIBUTE_UNUSED; static section *pa_select_section (tree, int, unsigned HOST_WIDE_INT) ATTRIBUTE_UNUSED; static void pa_encode_section_info (tree, rtx, int); @@ -488,11 +491,27 @@ if (flag_pic == 1 || TARGET_64BIT) flag_pic = 2; + if (TARGET_SOM) + { + /* We have named sections but they are only for special purposes. */ + if (flag_function_sections) + { + warning (0, "-ffunction-sections not supported for this target"); + flag_function_sections = 0; + } + if (flag_data_sections) + { + warning (0, "-fdata-sections not supported for this target"); + flag_data_sections = 0; + } + } + /* We can't guarantee that .dword is available for 32-bit targets. */ if (UNITS_PER_WORD == 4) targetm.asm_out.aligned_op.di = NULL; - /* The unaligned ops are only available when using GAS. */ + /* The unaligned ops are only available when using GAS. Note that + the HP linker isn't in general able to handle unaligned fixups. */ if (!TARGET_GAS) { targetm.asm_out.unaligned_op.hi = NULL; @@ -9372,6 +9391,40 @@ exception_section = data_section; } +/* Implement TARGET_ASM_NAMED_SECTION. */ + +static void +pa_som_asm_named_section (const char *name ATTRIBUTE_UNUSED, + unsigned int flags ATTRIBUTE_UNUSED, + tree decl ATTRIBUTE_UNUSED) +{ + /* Currently, we only use named sections for debug sections. */ + if (!(flags & SECTION_DEBUG)) + gcc_unreachable (); + + if (flags & SECTION_DECLARED) + { + fprintf (asm_out_file, "\t.SPACE $DWARF_DEBUG$\n\t.SUBSPA %s\n", name); + return; + } + + fprintf (asm_out_file, + "\t.SPACE $DWARF_DEBUG$,PRIVATE,UNLOADABLE,SORT=80\n"); + fprintf (asm_out_file, + "\t.SUBSPA %s,UNLOADABLE,ACCESS=0,ALIGN=8,SORT=8\n", + name); +} + +/* Implement TARGET_ASM_UNIQUE_SECTION. */ + +static void +pa_som_unique_section (tree decl ATTRIBUTE_UNUSED, + int reloc ATTRIBUTE_UNUSED) +{ + /* We don't use unique section names for declarations, but + we need to override the default implementation. */ +} + /* On hpux10, the linker will give an error if we have a reference in the read-only data section to a symbol defined in a shared library. Therefore, expressions that might require a reloc can