From 89442fc4839f511530f0c71bc5e505bd0bc9b19d Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Wed, 28 Jan 2015 22:05:06 -0800 Subject: Reformat experimental header for compatibility with old DWARF consumers. 2015-01-28 Cary Coutant binutils/ * dwarf.c (read_debug_line_header): Adjust to reformatted header. (display_line_program): Add missing space in output. (display_debug_lines_raw): Adjust to reformatted header. * dwarf.h (DWARF2_Internal_LineInfo): Remove li_actuals_table_offset. --- binutils/dwarf.c | 53 ++++++++++++++++++++++++++++++++++------------------- binutils/dwarf.h | 1 - 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f418cb1..0dd428a 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -2826,7 +2826,7 @@ read_debug_line_header (struct dwarf_section * section, linfo->li_address_size = 0; linfo->li_segment_size = 0; } - else + else if (linfo->li_version != DWARF2_LINE_EXPERIMENTAL_VERSION) { SAFE_BYTE_GET_AND_INC (linfo->li_address_size, hdrptr, 1, end); SAFE_BYTE_GET_AND_INC (linfo->li_segment_size, hdrptr, 1, end); @@ -2834,12 +2834,6 @@ read_debug_line_header (struct dwarf_section * section, SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, offset_size, end); - if (linfo->li_version != DWARF2_LINE_EXPERIMENTAL_VERSION) - linfo->li_actuals_table_offset = 0; - else - SAFE_BYTE_GET_AND_INC (linfo->li_actuals_table_offset, hdrptr, - offset_size, end); - SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end); if (linfo->li_version >= 4) @@ -3069,7 +3063,7 @@ display_line_program (unsigned char *start, unsigned char *end, return; } - printf ("%s:\n", table_name); + printf (" %s:\n", table_name); while (data < end) { @@ -3348,6 +3342,8 @@ display_debug_lines_raw (struct dwarf_section *section, { static DWARF2_Internal_LineInfo saved_linfo; DWARF2_Internal_LineInfo linfo; + unsigned int logicals_table_offset = 0; + unsigned int actuals_table_offset = 0; unsigned char *end_of_header_length; unsigned char *standard_opcodes; unsigned char *start_of_line_program; @@ -3395,14 +3391,13 @@ display_debug_lines_raw (struct dwarf_section *section, printf (_(" Offset: 0x%lx\n"), (long)(data - start)); printf (_(" Length: %ld\n"), (long) linfo.li_length); printf (_(" DWARF Version: %d\n"), linfo.li_version); - if (linfo.li_version >= 5) + if (linfo.li_version >= 5 && + linfo.li_version != DWARF2_LINE_EXPERIMENTAL_VERSION) { printf (_(" Address Size: %u\n"), linfo.li_address_size); printf (_(" Segment Size: %u\n"), linfo.li_segment_size); } printf (_(" Prologue Length: %d\n"), linfo.li_prologue_length); - if (linfo.li_version == DWARF2_LINE_EXPERIMENTAL_VERSION) - printf (_(" Actuals Table Offset: 0x%x\n"), linfo.li_actuals_table_offset); printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); if (linfo.li_version >= 4) printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); @@ -3412,14 +3407,11 @@ display_debug_lines_raw (struct dwarf_section *section, printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); end_of_header_length = data + initial_length_size + 2 + offset_size; - if (linfo.li_version >= 5) + if (linfo.li_version >= 5 && + linfo.li_version != DWARF2_LINE_EXPERIMENTAL_VERSION) end_of_header_length += 2; start_of_line_program = end_of_header_length + linfo.li_prologue_length; - if (linfo.li_version == DWARF2_LINE_EXPERIMENTAL_VERSION - && linfo.li_actuals_table_offset > 0) - end_of_logicals = end_of_header_length + linfo.li_actuals_table_offset; - else - end_of_logicals = end; + end_of_logicals = end; /* PR 17512: file: 1665-6428-0.004. */ if (linfo.li_line_range == 0) @@ -3447,6 +3439,29 @@ display_debug_lines_raw (struct dwarf_section *section, data = standard_opcodes + linfo.li_opcode_base - 1; + if (linfo.li_version == DWARF2_LINE_EXPERIMENTAL_VERSION) + { + /* Skip the fake directory and filename table. */ + data += 2; + + /* Skip the fake extended opcode that wraps the rest + of the section. */ + data += 5; + + /* Read the logicals table offset and actuals table offset. */ + SAFE_BYTE_GET_AND_INC (logicals_table_offset, data, offset_size, end); + SAFE_BYTE_GET_AND_INC (actuals_table_offset, data, offset_size, end); + + start_of_line_program = end_of_header_length + logicals_table_offset; + + if (actuals_table_offset > 0) + end_of_logicals = end_of_header_length + actuals_table_offset; + + putchar ('\n'); + printf (_(" Logicals Table Offset: 0x%x\n"), logicals_table_offset); + printf (_(" Actuals Table Offset: 0x%x\n"), actuals_table_offset); + } + /* Display the contents of the Directory table. */ if (linfo.li_version >= 5) display_dir_file_table_v5 (start, end, &data, _("Directory"), @@ -3487,12 +3502,12 @@ display_debug_lines_raw (struct dwarf_section *section, if (linfo.li_version == DWARF2_LINE_EXPERIMENTAL_VERSION && hdrptr != NULL - && linfo.li_actuals_table_offset > 0) + && actuals_table_offset > 0) { if (end_of_logicals > end) { warn (_("Actuals table offset %s extends beyond end of section\n"), - dwarf_vmatoa ("u", linfo.li_actuals_table_offset)); + dwarf_vmatoa ("u", actuals_table_offset)); end_of_logicals = end; } display_line_program (start, end_of_logicals, &data, diff --git a/binutils/dwarf.h b/binutils/dwarf.h index 55cfbfe..306bbbd 100644 --- a/binutils/dwarf.h +++ b/binutils/dwarf.h @@ -43,7 +43,6 @@ typedef struct unsigned char li_address_size; unsigned char li_segment_size; unsigned int li_prologue_length; - unsigned int li_actuals_table_offset; unsigned char li_min_insn_length; unsigned char li_max_ops_per_insn; unsigned char li_default_is_stmt; -- cgit v1.1