From 8e7fa2c825bfd57d12dcd52dbc2361d3f777ec2f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 15 Mar 2001 17:14:47 -0800 Subject: [PATCH] dwarf2asm.c (dw2_asm_output_offset): Use ASM_OUTPUT_DWARF_OFFSET if provided by the target. * dwarf2asm.c (dw2_asm_output_offset): Use ASM_OUTPUT_DWARF_OFFSET if provided by the target. (dw2_asm_output_pcrel): Likewise with ASM_OUTPUT_DWARF_PCREL. (dw2_asm_output_addr): New. * dwarf2asm.h (dw2_asm_output_addr): Declare. * dwarf2out.c (output_cfi): Use it for program addresses. (output_call_frame_info, output_die): Likewise. (output_aranges, output_line_info): Likewise. From-SVN: r40524 --- gcc/ChangeLog | 11 ++++ gcc/dwarf2asm.c | 143 ++++++++++++++++++++++++++++++++++-------------- gcc/dwarf2asm.h | 4 ++ gcc/dwarf2out.c | 32 +++++------ 4 files changed, 133 insertions(+), 57 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c13da94446bd..1aa9b707743c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2001-03-15 Richard Henderson + + * dwarf2asm.c (dw2_asm_output_offset): Use ASM_OUTPUT_DWARF_OFFSET + if provided by the target. + (dw2_asm_output_pcrel): Likewise with ASM_OUTPUT_DWARF_PCREL. + (dw2_asm_output_addr): New. + * dwarf2asm.h (dw2_asm_output_addr): Declare. + * dwarf2out.c (output_cfi): Use it for program addresses. + (output_call_frame_info, output_die): Likewise. + (output_aranges, output_line_info): Likewise. + 2001-03-15 Bruce Korb * gcc.c(main): make more rigorous diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c index ca1efb547b7e..464c2b17946c 100644 --- a/gcc/dwarf2asm.c +++ b/gcc/dwarf2asm.c @@ -91,6 +91,8 @@ unaligned_integer_asm_op (size) } #endif /* UNALIGNED_INT_ASM_OP */ +/* Output an immediate constant in a given size. */ + void dw2_asm_output_data VPARAMS ((int size, unsigned HOST_WIDE_INT value, const char *comment, ...)) @@ -127,6 +129,12 @@ dw2_asm_output_data VPARAMS ((int size, unsigned HOST_WIDE_INT value, va_end (ap); } +/* Output the difference between two symbols in a given size. */ +/* ??? There appear to be assemblers that do not like such + subtraction, but do support ASM_SET_OP. It's unfortunately + impossible to do here, since the ASM_SET_OP for the difference + symbol must appear after both symbols are defined. */ + void dw2_asm_output_delta VPARAMS ((int size, const char *lab1, const char *lab2, const char *comment, ...)) @@ -169,6 +177,12 @@ dw2_asm_output_delta VPARAMS ((int size, const char *lab1, const char *lab2, va_end (ap); } +/* Output a section-relative reference to a label. In general this + can only be done for debugging symbols. E.g. on most targets with + the GNU linker, this is accomplished with a direct reference and + the knowledge that the debugging section will be placed at VMA 0. + Some targets have special relocations for this that we must use. */ + void dw2_asm_output_offset VPARAMS ((int size, const char *label, const char *comment, ...)) @@ -188,6 +202,93 @@ dw2_asm_output_offset VPARAMS ((int size, const char *label, comment = va_arg (ap, const char *); #endif +#ifdef ASM_OUTPUT_DWARF_OFFSET + ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label); +#else +#ifdef UNALIGNED_INT_ASM_OP + fputs (unaligned_integer_asm_op (size), asm_out_file); + assemble_name (asm_out_file, label); +#else + assemble_integer (gen_rtx_SYMBOL_REF (Pmode, label), size, 1); +#endif +#endif + + if (flag_debug_asm && comment) + { + fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); + vfprintf (asm_out_file, comment, ap); + } + fputc ('\n', asm_out_file); + + va_end (ap); +} + +/* Output a self-relative reference to a label, possibly in a + different section or object file. */ + +void +dw2_asm_output_pcrel VPARAMS ((int size, const char *label, + const char *comment, ...)) +{ +#ifndef ANSI_PROTOTYPES + int size; + const char *label; + const char *comment; +#endif + va_list ap; + + VA_START (ap, comment); + +#ifndef ANSI_PROTOTYPES + size = va_arg (ap, int); + label = va_arg (ap, const char *); + comment = va_arg (ap, const char *); +#endif + +#ifdef ASM_OUTPUT_DWARF_PCREL + ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, label); +#else +#ifdef UNALIGNED_INT_ASM_OP + fputs (unaligned_integer_asm_op (size), asm_out_file); + assemble_name (asm_out_file, label); + fputc ('-', asm_out_file); + fputc ('.', asm_out_file); +#else + abort (); +#endif +#endif + + if (flag_debug_asm && comment) + { + fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); + vfprintf (asm_out_file, comment, ap); + } + fputc ('\n', asm_out_file); + + va_end (ap); +} + +/* Output an absolute reference to a label. */ + +void +dw2_asm_output_addr VPARAMS ((int size, const char *label, + const char *comment, ...)) +{ +#ifndef ANSI_PROTOTYPES + int size; + const char *label; + const char *comment; +#endif + va_list ap; + + VA_START (ap, comment); + +#ifndef ANSI_PROTOTYPES + size = va_arg (ap, int); + label = va_arg (ap, const char *); + comment = va_arg (ap, const char *); +#endif + #ifdef UNALIGNED_INT_ASM_OP fputs (unaligned_integer_asm_op (size), asm_out_file); assemble_name (asm_out_file, label); @@ -205,47 +306,7 @@ dw2_asm_output_offset VPARAMS ((int size, const char *label, va_end (ap); } -void -dw2_asm_output_pcrel VPARAMS ((int size, const char *label, - const char *comment, ...)) -{ -#ifndef ANSI_PROTOTYPES - int size; - const char *label; - const char *comment; -#endif - va_list ap; - - VA_START (ap, comment); - -#ifndef ANSI_PROTOTYPES - size = va_arg (ap, int); - label = va_arg (ap, const char *); - comment = va_arg (ap, const char *); -#endif - -#ifdef UNALIGNED_INT_ASM_OP - fputs (unaligned_integer_asm_op (size), asm_out_file); - - /* ??? This needs target conditionalization. E.g. the solaris - assembler uses %r_disp32(label). Others don't like "." and - we need to generate a temporary label here. */ - assemble_name (asm_out_file, label); - fputc ('-', asm_out_file); - fputc ('.', asm_out_file); -#else - abort (); -#endif - - if (flag_debug_asm && comment) - { - fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); - vfprintf (asm_out_file, comment, ap); - } - fputc ('\n', asm_out_file); - - va_end (ap); -} +/* Similar, but use an RTX expression instead of a text label. */ void dw2_asm_output_addr_rtx VPARAMS ((int size, rtx addr, diff --git a/gcc/dwarf2asm.h b/gcc/dwarf2asm.h index a1a2ae984e6a..51b67555cb3e 100644 --- a/gcc/dwarf2asm.h +++ b/gcc/dwarf2asm.h @@ -40,6 +40,10 @@ extern void dw2_asm_output_pcrel PARAMS ((int, const char *, const char *, ...)) /* ATTRIBUTE_PRINTF_3 */; +extern void dw2_asm_output_addr PARAMS ((int, const char *, + const char *, ...)) + /* ATTRIBUTE_PRINTF_3 */; + extern void dw2_asm_output_addr_rtx PARAMS ((int, rtx, const char *, ...)) /* ATTRIBUTE_PRINTF_3 */; diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 573bc913c945..e4978930ce8d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -1546,8 +1546,8 @@ output_cfi (cfi, fde) switch (cfi->dw_cfi_opc) { case DW_CFA_set_loc: - dw2_asm_output_offset (DWARF2_ADDR_SIZE, - cfi->dw_cfi_oprnd1.dw_cfi_addr, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, + cfi->dw_cfi_oprnd1.dw_cfi_addr, NULL); break; case DW_CFA_advance_loc1: dw2_asm_output_delta (1, cfi->dw_cfi_oprnd1.dw_cfi_addr, @@ -1679,8 +1679,8 @@ output_call_frame_info (for_eh) trailing null) so the pointer is 4-byte aligned. The Solaris ld can't handle unaligned relocs. */ dw2_asm_output_nstring ("eh", -1, "CIE Augmentation"); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, "__EXCEPTION_TABLE__", - "pointer to exception region info"); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, "__EXCEPTION_TABLE__", + "pointer to exception region info"); } else { @@ -1743,8 +1743,8 @@ output_call_frame_info (for_eh) stripattributes (FRAME_SECTION), "FDE CIE offset"); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, fde->dw_fde_begin, - "FDE initial location"); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin, + "FDE initial location"); dw2_asm_output_delta (DWARF2_ADDR_SIZE, fde->dw_fde_end, fde->dw_fde_begin, "FDE address range"); @@ -5724,7 +5724,7 @@ output_die (die) break; case dw_val_class_lbl_id: - dw2_asm_output_offset (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name); break; case dw_val_class_lbl_offset: @@ -5938,7 +5938,7 @@ output_aranges () dw2_asm_output_data (2, 0, NULL); } - dw2_asm_output_offset (DWARF2_ADDR_SIZE, text_section_label, "Address"); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address"); dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label, text_section_label, "Length"); @@ -5952,7 +5952,7 @@ output_aranges () if (die->die_tag == DW_TAG_subprogram) { - dw2_asm_output_offset (DWARF2_ADDR_SIZE, get_AT_low_pc (die), + dw2_asm_output_addr (DWARF2_ADDR_SIZE, get_AT_low_pc (die), "Address"); dw2_asm_output_delta (DWARF2_ADDR_SIZE, get_AT_hi_pc (die), get_AT_low_pc (die), "Length"); @@ -6440,7 +6440,7 @@ output_line_info () dw2_asm_output_data (1, 0, "DW_LNE_set_address"); dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); dw2_asm_output_data (1, DW_LNE_set_address, NULL); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); } strcpy (prev_line_label, line_label); @@ -6451,7 +6451,7 @@ output_line_info () current_file = line_info->dw_file_num; dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file"); dw2_asm_output_data_uleb128 (current_file, "(\"%s\")", - line_file_table.table[current_file]); + file_table.table[current_file]); } /* Emit debug info for the current line number, choosing the encoding @@ -6498,7 +6498,7 @@ output_line_info () dw2_asm_output_data (1, 0, "DW_LNE_set_address"); dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); dw2_asm_output_data (1, DW_LNE_set_address, NULL); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, text_end_label, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_end_label, NULL); } dw2_asm_output_data (1, 0, "DW_LNE_end_sequence"); @@ -6534,7 +6534,7 @@ output_line_info () dw2_asm_output_data (1, 0, "DW_LNE_set_address"); dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); dw2_asm_output_data (1, DW_LNE_set_address, NULL); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); } else { @@ -6550,7 +6550,7 @@ output_line_info () dw2_asm_output_data (1, 0, "DW_LNE_set_address"); dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); dw2_asm_output_data (1, DW_LNE_set_address, NULL); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); } } strcpy (prev_line_label, line_label); @@ -6562,7 +6562,7 @@ output_line_info () current_file = line_info->dw_file_num; dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file"); dw2_asm_output_data_uleb128 (current_file, "(\"%s\")", - line_file_table.table[current_file]); + file_table.table[current_file]); } /* Emit debug info for the current line number, choosing the encoding @@ -6611,7 +6611,7 @@ output_line_info () dw2_asm_output_data (1, 0, "DW_LNE_set_address"); dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); dw2_asm_output_data (1, DW_LNE_set_address, NULL); - dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL); + dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); } /* Output the marker for the end of this sequence. */