binutils-gdb/binutils/dwarf.h

325 lines
9.1 KiB
C
Raw Normal View History

bfd/ * Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
2008-07-10 03:32:23 +02:00
/* dwarf.h - DWARF support header file
Copyright (C) 2005-2020 Free Software Foundation, Inc.
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
2007-07-05 18:54:46 +02:00
This file is part of GNU Binutils.
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
2007-07-05 18:54:46 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
2007-07-05 18:54:46 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
2007-07-05 18:54:46 +02:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
DWARF-5 basic functionality binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23 22:54:01 +01:00
#include "dwarf2.h" /* for enum dwarf_unit_type */
typedef unsigned HOST_WIDEST_INT dwarf_vma;
typedef HOST_WIDEST_INT dwarf_signed_vma;
typedef unsigned HOST_WIDEST_INT dwarf_size_type;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
/* Structure found in the .debug_line section. */
typedef struct
{
dwarf_vma li_length;
unsigned short li_version;
Add support for generating DWARF-5 format directory and file name tables from the assembler. PR 25611 PR 25614 * dwarf.h (DWARF2_Internal_LineInfo): Add li_address_size and li_segment_size fields. * dwarf.c (read_debug_line_header): Record the address size and segment selector size values (if present) in the lineinfo structure. (display_formatted_table): Warn if the format count is empty but the table itself is not empty. Display the format count and entry count at the start of the table dump. (display_debug_lines_raw): Display the address size and segement selector size fields, if present. * testsuite/binutils-all/dw5.W: Update expected output. gas * dwarf2dbg.c (DWARF2_FILE_TIME_NAME): Default to -1. (DWARF2_FILE_SIZE_NAME): Default to -1. (DWARF2_LINE_VERSION): Default to the current dwarf level or 3, whichever is higher. (DWARF2_LINE_MAX_OPS_PER_INSN): Provide a default value of 1. (NUM_MD5_BYTES): Define. (struct file entry): Add md5 field. (get_filenum): Delete and replace with... (get_basename): New function. (get_directory_table_entry): New function. (allocate_filenum): New function. (allocate_filename_to_slot): New function. (dwarf2_where): Use new functions. (dwarf2_directive_filename): Add support for extended .file pseudo-op. (dwarf2_directive_loc): Allow the use of file number zero with DWARF 5 or higher. (out_file_list): Rename to... (out_dir_and_file_list): Add DWARF 5 support. (out_debug_line): Emit extra values into the section header for DWARF 5. (out_debug_str): Allow for file 0 to be used with DWARF 5. * doc/as.texi (.file): Update the description of this pseudo-op. * testsuite/gas/elf-dwarf-5-file0.s: Add more lines. * testsuite/gas/elf-dwarf-5-file0.d: Update expected dump output. * testsuite/gas/lns/lns-diag-1.l: Update expected error message. * NEWS: Mention the new feature.
2020-03-11 11:17:14 +01:00
unsigned char li_address_size;
unsigned char li_segment_size;
dwarf_vma li_prologue_length;
unsigned char li_min_insn_length;
unsigned char li_max_ops_per_insn;
unsigned char li_default_is_stmt;
int li_line_base;
unsigned char li_line_range;
unsigned char li_opcode_base;
DWARF-5 basic functionality binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23 22:54:01 +01:00
unsigned int li_offset_size;
}
DWARF2_Internal_LineInfo;
/* Structure found in .debug_pubnames section. */
typedef struct
{
dwarf_vma pn_length;
unsigned short pn_version;
dwarf_vma pn_offset;
dwarf_vma pn_size;
}
DWARF2_Internal_PubNames;
/* Structure found in .debug_info section. */
typedef struct
{
dwarf_vma cu_length;
unsigned short cu_version;
dwarf_vma cu_abbrev_offset;
unsigned char cu_pointer_size;
DWARF-5 basic functionality binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23 22:54:01 +01:00
enum dwarf_unit_type cu_unit_type;
}
DWARF2_Internal_CompUnit;
/* Structure found in .debug_aranges section. */
typedef struct
{
dwarf_vma ar_length;
unsigned short ar_version;
dwarf_vma ar_info_offset;
unsigned char ar_pointer_size;
unsigned char ar_segment_size;
}
DWARF2_Internal_ARange;
/* N.B. The order here must match the order in debug_displays. */
enum dwarf_section_display_enum
{
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
abbrev = 0,
aranges,
frame,
info,
line,
pubnames,
gnu_pubnames,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
eh_frame,
macinfo,
macro,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
str,
DWARF-5 basic functionality binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23 22:54:01 +01:00
line_str,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
loc,
loclists,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
pubtypes,
gnu_pubtypes,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
ranges,
rnglists,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
static_func,
static_vars,
types,
weaknames,
gdb_index,
debug_names,
trace_info,
trace_abbrev,
trace_aranges,
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
info_dwo,
abbrev_dwo,
types_dwo,
line_dwo,
loc_dwo,
macro_dwo,
macinfo_dwo,
str_dwo,
str_index,
str_index_dwo,
debug_addr,
dwp_cu_index,
dwp_tu_index,
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
gnu_debuglink,
gnu_debugaltlink,
separate_debug_str,
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
max
};
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
struct dwarf_section
{
/* A debug section has a different name when it's stored compressed
or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
possibilities. NAME is set to whichever one is used for this
input file, as determined by load_debug_section(). */
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
const char * uncompressed_name;
const char * compressed_name;
const char * name;
/* If non-NULL then FILENAME is the name of the separate debug info
file containing the section. */
const char * filename;
unsigned char * start;
dwarf_vma address;
dwarf_size_type size;
enum dwarf_section_display_enum abbrev_sec;
/* Used by clients to help them implement the reloc_at callback. */
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
void * reloc_info;
unsigned long num_relocs;
More fixes for memory access violations exposed by fuzzed binaries. PR binutils/17512 * dwarf.h (struct dwarf_section): Add user_data field. * dwarf.c (frame_need_space): Check for an over large register number. (display_debug_frames): Check the return value from frame_need_space. Check for a CFA expression that is so long the start address wraps around. (debug_displays): Initialise the user_data field. * objdump.c (load_specific_debug_section): Save the BFD section pointer in the user_data field of the dwarf_section structure. (free_debug_section): Update BFD section data when freeing section contents. * readelf.c (load_specific_debug_section): Initialise the user_data field. * archive.c (do_slurp_coff_armap): Add range checks to prevent running off the end of the string table. * compress.c (bfd_get_full_section_contents): Return a NULL pointer for zero sized sections. Do not attempt to copy a buffer onto itself. * elf-attrs.c (_bfd_elf_parse_attributes): Check for an empty header. Add range checks to avoid running off the end of the section. * elf.c (bfd_elf_get_str_section): Seek before allocating so that if the seek fails, no memory is allocated. (bfd_elf_string_from_elf_section): Do not allocate a string from a non string section. It only leads to trouble later on. (_bfd_elf_print_private_bfd_data): Check for there being too little external dynamic data. (bfd_section_from_shdr): Replace assertion with a failure mode. (bfd_section_from_shdr): When walking a loaded group section use the internal structure size, not the external size. Check for the group section being empty. * elf32-i386.c (elf_i386_rtype_to_howto): Replace assertion with a failure mode. * elfcode.h (elf_slurp_reloc_table): Likewise. * reloc.c (bfd_perform_relocation): Avoid seg-fault if the howto parameter is NULL.
2014-12-01 17:43:46 +01:00
/* A spare field for random use. */
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
void * user_data;
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
};
/* A structure containing the name of a debug section
and a pointer to a function that can decode it. */
struct dwarf_section_display
{
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
struct dwarf_section section;
int (* display) (struct dwarf_section *, void *);
int * enabled;
bfd_boolean relocate;
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
};
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern struct dwarf_section_display debug_displays [];
/* This structure records the information that
we extract from the.debug_info section. */
typedef struct
{
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
dwarf_vma cu_offset;
dwarf_vma base_address;
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
/* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
is used with the form DW_AT_GNU_FORM_addr_index. */
dwarf_vma addr_base;
/* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
is used when calculating ranges. */
dwarf_vma ranges_base;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
/* This is an array of offsets to the location list table. */
dwarf_vma * loc_offsets;
LVU: dump loclists with locviews When dumping location lists, also dump locview lists that may be interspersed with them, and bring view pairs next to the corresponding location list entries. This patch supports DW_AT_GNU_locviews as a separate attribute for DWARF4- loc_lists and split (dwo) loclists, as well as DWARF5 loclists. It also supports, in DWARF5 loclists, the proposed DW_LLE_GNU_view_pair loclist entry type proposed for DWARF6. The tests use 32-bit DWARF, even on 64-bit targets, resolving offsets to constants so as to reduce the risk that relocations be created for them, or that the offsets be rejected as nonconstants. The patch also adds an xfail to an unrelated test, namely dw5, so that no unexpected fails remain on nds32*-elf, one of the tested targets. Reviewed-by: Alan Modra <amodra@gmail.com> for include/ChangeLog * dwarf2.def (DW_AT_GNU_locviews): New. * dwarf2.h (enum dwarf_location_list_entry_type): Add DW_LLE_GNU_view_pair. (DW_LLE_view_pair): Define. for binutils/ChangeLog * dwarf.h (debug_info): Add loc_views and num_loc_views. * dwarf.c (vm1): New constant. (print_dwarf_view): New function. (read_and_display_attr_value): Support DW_AT_GNU_locviews. (process_debug_info): Keep num_loc_offsets and num_loc_views in sync. (display_view_pair_list): New function. (display_loc_list_dwo): Take vstart_ptr; update it. Dump location view pairs before the range they apply to, when a viewlist augments the loc list. (display_loc_list): Likewise. Check view numbers in range tests. (display_loclists_list): Likewise. Handle view pair entries, and warn on trailing ones. (loc_views): New variable. (loc_offsets_compar): Compare loc_views if loc_offsets are the same. (display_debug_loc): Check and sort loc_views too. Accept loc_view as expected_start. Skip if lists and views are the same. Dump locview list separately in order, and pass the locview list base to each list dump function. Warn and skip overlap and hole checking if we find loclists and locviews to not be adjacent. * testsuite/binutils-all/locview-1.s: New. * testsuite/binutils-all/readelf.locview-1: New. * testsuite/binutils-all/locview-2.s: New. * testsuite/binutils-all/readelf.locview-2: New. * testsuite/binutils-all/readelf.exp: Run new tests. Fix option spelling in pr18374 fail message. XFAIL dw5 test on nds32*-elf.
2017-09-22 22:05:51 +02:00
/* This is an array of offsets to the location view table. */
dwarf_vma * loc_views;
int * have_frame_base;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
unsigned int num_loc_offsets;
unsigned int max_loc_offsets;
LVU: dump loclists with locviews When dumping location lists, also dump locview lists that may be interspersed with them, and bring view pairs next to the corresponding location list entries. This patch supports DW_AT_GNU_locviews as a separate attribute for DWARF4- loc_lists and split (dwo) loclists, as well as DWARF5 loclists. It also supports, in DWARF5 loclists, the proposed DW_LLE_GNU_view_pair loclist entry type proposed for DWARF6. The tests use 32-bit DWARF, even on 64-bit targets, resolving offsets to constants so as to reduce the risk that relocations be created for them, or that the offsets be rejected as nonconstants. The patch also adds an xfail to an unrelated test, namely dw5, so that no unexpected fails remain on nds32*-elf, one of the tested targets. Reviewed-by: Alan Modra <amodra@gmail.com> for include/ChangeLog * dwarf2.def (DW_AT_GNU_locviews): New. * dwarf2.h (enum dwarf_location_list_entry_type): Add DW_LLE_GNU_view_pair. (DW_LLE_view_pair): Define. for binutils/ChangeLog * dwarf.h (debug_info): Add loc_views and num_loc_views. * dwarf.c (vm1): New constant. (print_dwarf_view): New function. (read_and_display_attr_value): Support DW_AT_GNU_locviews. (process_debug_info): Keep num_loc_offsets and num_loc_views in sync. (display_view_pair_list): New function. (display_loc_list_dwo): Take vstart_ptr; update it. Dump location view pairs before the range they apply to, when a viewlist augments the loc list. (display_loc_list): Likewise. Check view numbers in range tests. (display_loclists_list): Likewise. Handle view pair entries, and warn on trailing ones. (loc_views): New variable. (loc_offsets_compar): Compare loc_views if loc_offsets are the same. (display_debug_loc): Check and sort loc_views too. Accept loc_view as expected_start. Skip if lists and views are the same. Dump locview list separately in order, and pass the locview list base to each list dump function. Warn and skip overlap and hole checking if we find loclists and locviews to not be adjacent. * testsuite/binutils-all/locview-1.s: New. * testsuite/binutils-all/readelf.locview-1: New. * testsuite/binutils-all/locview-2.s: New. * testsuite/binutils-all/readelf.locview-2: New. * testsuite/binutils-all/readelf.exp: Run new tests. Fix option spelling in pr18374 fail message. XFAIL dw5 test on nds32*-elf.
2017-09-22 22:05:51 +02:00
unsigned int num_loc_views;
/* List of .debug_ranges offsets seen in this .debug_info. */
dwarf_vma * range_lists;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
unsigned int num_range_lists;
unsigned int max_range_lists;
}
debug_info;
Extend readelf and objdump so that they will display and follow multiple links to separate debug information files. PR 23843 * dwarf.h (struct separate_info): New structure for containing information on separate debug info files. * dwarf.c (struct dwo_info): New structure for containing dwo links. (first_dwo_info): Chain of dwo_info structures. (first_separate_file): Chain of separate_info structures. (separate_debug_file, separate_debug_filename): Delete. (fetch_alt_indirect_string): Scan all separate debug info files for the requested string. (add_dwo_info): New function. (add_dwo_name): New function. (add_dwo_dir): New function. (add_dwo_id: New function. (free_dwo_info): New function. (read_and_display_attr_value): Store DWO data using the new functions. (load_debug_section_with_follow): If necessary, scan the list of separate debug info files for the requested section. (add_separate_debug_file): New function. (load_separate_debug_info): Call add_separate_debug_file to store the information on the newly loaded file. (load_dwo_file): Likewise. (load_separate_debif_file): Rename to load_separate_debug_files. Change return type to boolean. If following links then attempt to load all separate debug info files, not just the first one. (free_debug_memory): Release memory in dwo_info and separate_info chains. * objdump.c (dump_dwarf): Iterate over all loaded debg info files. * readelf.c (process_object): Likewise. * doc/debug.options.texi: Update descriptions of links and follow-links options. * testsuite/binutils-all/objdump.WK2: Update expected output. * testsuite/binutils-all/readelf.k2: Likewise. * NEWS: Announce the new feature.
2019-02-22 11:36:24 +01:00
typedef struct separate_info
{
void * handle; /* The pointer returned by open_debug_file(). */
const char * filename;
struct separate_info * next;
} separate_info;
extern separate_info * first_separate_info;
extern unsigned int eh_addr_size;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern int do_debug_info;
extern int do_debug_abbrevs;
extern int do_debug_lines;
extern int do_debug_pubnames;
extern int do_debug_pubtypes;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern int do_debug_aranges;
extern int do_debug_ranges;
extern int do_debug_frames;
extern int do_debug_frames_interp;
extern int do_debug_macinfo;
extern int do_debug_str;
extern int do_debug_str_offsets;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern int do_debug_loc;
extern int do_gdb_index;
extern int do_trace_info;
extern int do_trace_abbrevs;
extern int do_trace_aranges;
extern int do_debug_addr;
extern int do_debug_cu_index;
extern int do_wide;
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
extern int do_debug_links;
extern int do_follow_links;
extern bfd_boolean do_checks;
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern int dwarf_cutoff_level;
extern unsigned long dwarf_start_die;
* doc/binutils.texi: Add --dwarf-check option. * dwarf.c (dwarf_check): New global flag. (fetch_indexed_string): New function. (fetch_indexed_value): New function. (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. (decode_location_expression): Add DW_OP_GNU_addr_index. (read_and_display_attr_value): Add DW_FORM_GNU_str_index, DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. (get_AT_name): Add new attributes for Fission. (process_debug_info): Load new debug sections for Fission. (load_debug_info): Check for .debug_info.dwo section. (display_loc_list, display_loc_list_dwo): New functions. (display_debug_loc): Move logic to above two functions. (display_debug_info): Choose abbrev section based on info section. (display_debug_types): Likewise. (display_trace_info): Likewise. (comp_addr_base): New function. (display_debug_addr): New function. (display_debug_str_offsets): New function. (display_debug_ranges): Allow missing range lists. Suppress diagnostics if dwarf_check not set. (debug_displays): Add column to select abbrev section. * dwarf.h (enum dwarf_section_display_enum): Add new debug sections for Fission. (struct dwarf_section): Add abbrev_sec field. (struct dwarf_section_display): New type. (debug_info): Add addr_base, ranges_base fields. (dwarf_check): New global variable. * objdump.c (usage): Add --dwarf-check option. (enum option_values): Add OPTION_DWARF_CHECK. (long_options): Add --dwarf-check. (main): Likewise. * readelf.c (OPTION_DWARF_CHECK): New macro. (options): Add --dwarf-check. (parse_args): Likewise. (process_section_headers): Use const_strneq instead of streq.
2012-05-11 20:18:34 +02:00
extern int dwarf_check;
extern void init_dwarf_regnames_by_elf_machine_code (unsigned int);
extern void init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch,
unsigned long mach);
binutils/ 2008-01-28 H.J. Lu <hongjiu.lu@intel.com> * dwarf.c: Include "elf/common.h". (eh_addr_size): Changed to int. (dwarf_regnames_i386): New. (dwarf_regnames_x86_64): Likewise. (dwarf_regnames): Likewise. (dwarf_regnames_count): Likewise. (init_dwarf_regnames): Likewise. (regname): Likewise. (frame_display_row): Properly support different address size. Call regname to get register name. (display_debug_frames): Call regname to get register name. Display DW_CFA_def_cfa_register as DW_CFA_def_cfa_register instead of DW_CFA_def_cfa_reg. * dwarf.h (init_dwarf_regnames): New. * objdump.c: Include "elf-bfd.h". (dump_dwarf): Call init_dwarf_regnames on ELF input. * readelf.c (guess_is_rela): Change argument to int. (parse_args): Remove the undocumented upper case options for -wX. (process_file_header): Call init_dwarf_regnames if do_dwarf_register is true. gas/testsuite/ 2008-01-28 H.J. Lu <hongjiu.lu@intel.com> * gas/cfi/cfi-alpha-1.d: Replace DW_CFA_def_cfa_reg with DW_CFA_def_cfa_register. * gas/cfi/cfi-alpha-3.d: Likewise. * gas/cfi/cfi-hppa-1.d: Likewise. * gas/cfi/cfi-i386.d: Likewise. * gas/cfi/cfi-m68k.d: Likewise. * gas/cfi/cfi-mips-1.d: Likewise. * gas/cfi/cfi-sh-1.d: Likewise. * gas/cfi/cfi-sparc-1.d: Likewise. * gas/cfi/cfi-sparc64-1.d: Likewise. * gas/cfi/cfi-x86_64.d: Likewise. * gas/cfi/cfi-common-1.d: Updated for i386/x86-64 register names. * gas/cfi/cfi-common-2.d: Likewise. * gas/cfi/cfi-common-5.d: Likewise. * gas/cfi/cfi-i386.d: Likewise. * gas/cfi/cfi-x86_64.d: Likewise. ld/testsuite/ 2008-01-28 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/eh1.d: Replace DW_CFA_def_cfa_reg with DW_CFA_def_cfa_register. Updated for i386/x86-64 register names. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise. * ld-elf/eh4.d: Likewise. * ld-elf/eh5.d: Likewise.
2008-01-28 16:15:32 +01:00
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
extern bfd_boolean load_debug_section (enum dwarf_section_display_enum, void *);
extern void free_debug_section (enum dwarf_section_display_enum);
Extend readelf and objdump so that they will display and follow multiple links to separate debug information files. PR 23843 * dwarf.h (struct separate_info): New structure for containing information on separate debug info files. * dwarf.c (struct dwo_info): New structure for containing dwo links. (first_dwo_info): Chain of dwo_info structures. (first_separate_file): Chain of separate_info structures. (separate_debug_file, separate_debug_filename): Delete. (fetch_alt_indirect_string): Scan all separate debug info files for the requested string. (add_dwo_info): New function. (add_dwo_name): New function. (add_dwo_dir): New function. (add_dwo_id: New function. (free_dwo_info): New function. (read_and_display_attr_value): Store DWO data using the new functions. (load_debug_section_with_follow): If necessary, scan the list of separate debug info files for the requested section. (add_separate_debug_file): New function. (load_separate_debug_info): Call add_separate_debug_file to store the information on the newly loaded file. (load_dwo_file): Likewise. (load_separate_debif_file): Rename to load_separate_debug_files. Change return type to boolean. If following links then attempt to load all separate debug info files, not just the first one. (free_debug_memory): Release memory in dwo_info and separate_info chains. * objdump.c (dump_dwarf): Iterate over all loaded debg info files. * readelf.c (process_object): Likewise. * doc/debug.options.texi: Update descriptions of links and follow-links options. * testsuite/binutils-all/objdump.WK2: Update expected output. * testsuite/binutils-all/readelf.k2: Likewise. * NEWS: Announce the new feature.
2019-02-22 11:36:24 +01:00
extern bfd_boolean load_separate_debug_files (void *, const char *);
Add support to readelf and objdump for following links to separate debug information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15 12:34:03 +01:00
extern void close_debug_file (void *);
extern void * open_debug_file (const char *);
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
extern void free_debug_memory (void);
extern void dwarf_select_sections_by_names (const char *);
extern void dwarf_select_sections_by_letters (const char *);
extern void dwarf_select_sections_all (void);
extern unsigned int * find_cu_tu_set (void *, unsigned int);
extern void * cmalloc (size_t, size_t);
extern void * xcalloc2 (size_t, size_t);
extern void * xcmalloc (size_t, size_t);
extern void * xcrealloc (void *, size_t, size_t);
2005-09-30 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CFILES): Add dwarf.c. (readelf_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: New file. * dwarf.h. Likewise. * readelf.c: Include "dwarf.h" instead of "bfd.h". (do_debug_info): Remove the static definition. (do_debug_abbrevs): Likewise. (do_debug_lines): Likewise. (do_debug_pubnames): Likewise. (do_debug_aranges): Likewise. (do_debug_ranges): Likewise. (do_debug_frames): Likewise. (do_debug_frames_interp): Likewise. (do_debug_macinfo): Likewise. (do_debug_str): Likewise. (do_debug_loc): Likewise. (is_relocatable): Likewise. (have_frame_base): Likewise. (need_base_address): Likewise. (eh_addr_size): Likewise. (error): Likewise. (warn): Likewise. (cmalloc): Likewise. (xcmalloc): Likewise. (xcrealloc): Likewise. (dwarf_section): Removed. (byte_get_little_endian): Likewise. (byte_get_signed): Likewise. (byte_get_big_endian): Likewise. (read_leb128): Likewise. (State_Machine_Registers): Likewise. (state_machine_regs): Likewise. (reset_state_machine): Likewise. (process_extended_line_op): Likewise. (debug_str_section): Likewise. (fetch_indirect_string): Likewise. (debug_abbrev_section): Likewise. (abbrev_attr): Likewise. (first_abbrev): Likewise. (last_abbrev): Likewise. (free_abbrevs): Likewise. (add_abbrev_attr): Likewise. (process_abbrev_section): Likewise. (get_TAG_name): Likewise. (get_FORM_name): Likewise. (display_block): Likewise. (decode_location_expression): Likewise. (debug_info): Likewise. (debug_information): Likewise. (num_debug_info_entries): Likewise. (last_pointer_size): Likewise. (warned_about_missing_comp_units): Likewise. (read_and_display_attr_value): Likewise. (get_AT_name): Likewise. (read_and_display_attr): Likewise. (process_debug_info): Likewise. (get_pointer_size_and_offset_of_comp_unit): Likewise. (get_debug_info): Likewise. (display_debug_lines): Likewise. (display_debug_pubnames): Likewise. (display_debug_macinfo): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_ranges): Likewise. (Frame_Chunk): Likewise. (DW_CFA_unreferenced): Likewise. (frame_need_space): Likewise. (frame_display_row): Likewise. (size_of_encoded_value): Likewise. (get_encoded_value): Likewise. (GET): Likewise. (LEB): Likewise. (SLEB): Likewise. (display_debug_frames): Likewise. (display_debug_not_supported): Likewise. (debug_displays): Likewise. (load_debug_section): Updated. (free_debug_section): Likewise. (display_debug_section): Likewise. (process_object): Call free_debug_memory to free debug memory.
2005-09-30 16:55:05 +02:00
/* A callback into the client. Returns TRUE if there is a
relocation against the given debug section at the given
offset. */
extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma);
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
extern dwarf_vma read_leb128 (unsigned char *, const unsigned char *const,
bfd_boolean, unsigned int *, int *);
Add support for debuginfod to the binutils (disable by default, enabled via a configure time option). debuginfod is a lightweight web service that indexes ELF/DWARF debugging resources by build-id and serves them over HTTP. This patch enables objdump and readelf to query debuginfod servers when they are otherwise not able to find separate debug files. Binutils can be built with debuginfod using the --with-debuginfod configure option. This requires that libdebuginfod be installed and found at configure time. debuginfod is packaged with elfutils, starting with version 0.178. For more information see https://sourceware.org/elfutils/. toplevel* config/debuginfod.m4: New file. Add macro AC_DEBUGINFOD. Adds new configure option --with-debuginfod. * configure: Regenerate. * configure.ac: Call AC_DEBUGINFOD. binutils* Makefile.am (readelf_LDADD, objdump_LDADD): Add libdebuginfod. * Makefile.in: Regenerate. * NEWS: Update. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Call AC_DEBUGINFOD. * doc/Makefile.in: Regenerate. * doc/binutils.texi: Add section on using binutils with debuginfod. * dwarf.c (debuginfod_fetch_separate_debug_info): New function. Query debuginfod servers for the target debug file. (load_separate_debug_info): Call debuginfod_fetch_separate_debug_info if configured with debuginfod. (load_separate_debug_files): Add file argument to load_separate_debug_info calls. * dwarf.h (get_build_id): Add declaration. * objdump.c (get_build_id): New function. Get build-id of file. * readelf.c (get_build_id): Likewise. * testsuite/binutils-all/debuginfod.exp: New tests. * testsuite/binutils-all/linkdebug.s: Add .note.gnu.build-id section.
2020-01-09 14:19:20 +01:00
#if HAVE_LIBDEBUGINFOD
extern unsigned char * get_build_id (void *);
#endif
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
static inline void
report_leb_status (int status, const char *file, unsigned long lnum)
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
{
if ((status & 1) != 0)
error (_("%s:%lu: end of data encountered whilst reading LEB\n"), file, lnum);
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
else if ((status & 2) != 0)
error (_("%s:%lu: read LEB value is too large to store in destination variable\n"), file, lnum);
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
}
#define SKIP_ULEB(start, end) \
do \
{ \
unsigned int _len; \
read_leb128 (start, end, FALSE, &_len, NULL); \
start += _len; \
} \
while (0)
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
#define SKIP_SLEB(start, end) \
do \
{ \
unsigned int _len; \
read_leb128 (start, end, TRUE, &_len, NULL); \
start += _len; \
} \
while (0)
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
#define READ_ULEB(var, start, end) \
do \
{ \
dwarf_vma _val; \
unsigned int _len; \
int _status; \
\
_val = read_leb128 (start, end, FALSE, &_len, &_status); \
start += _len; \
(var) = _val; \
if ((var) != _val) \
_status |= 2; \
report_leb_status (_status, __FILE__, __LINE__); \
} \
while (0)
Revise sleb128 and uleb128 reader This patch catches and reports errors when reading leb128 values, addressing a FIXME in read_leb128. * dwarf.h (read_leb128): Update prototype. (report_leb_status): New inline function. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define. * dwarf.c: Use above macros throughout file. Formatting. (read_leb128): Reorder params. Add status return param. Don't stop reading until finding terminator or end of data. Detect loss of significant bits. Sign extend only on terminating byte. (read_sleb128, read_uleb128): Delete functions. (SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros. (read_and_print_leb128): Rewrite. (process_extended_line_op): Return a size_t. Use size_t vars. Adjust to suit new macros. Add proper name size to "data" when processing DW_LNE_define_file. (process_abbrev_section): Adjust to suit new macros. (decode_location_expression, skip_attr_bytes): Likewise. (get_type_signedness): Likewise. (read_and_display_attr_value): Likewise. Consolidate block code. (process_debug_info): Adjust to suit new macros. (display_formatted_table, display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. Properly check for end of DW_LNS_extended_op. (display_debug_macinfo): Adjust to suit new macros. (get_line_filename_and_dirname, display_debug_macro): Likewise. (display_view_pair_list): Likewise. Don't back off when hitting end of data. (display_loc_list): Adjust to suit new macros. (display_loclists_list, display_loc_list_dwo): Likewise. (display_debug_rnglists_list, read_cie): Likewise. (display_debug_frames): Likewise. * readelf.c: Use new ULEB macros throughout file. (read_uleb128): Delete. (decode_arm_unwind_bytecode): Use read_leb128. (decode_tic6x_unwind_bytecode): Likewise. (display_tag_value): Adjust to suit new macros. (display_arc_attribute, display_arm_attribute): Likewise. (display_gnu_attribute, display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute, display_tic6x_attribute): Likewise. (display_msp430x_attribute, display_msp430_gnu_attribute): Likewise. (display_riscv_attribute, process_attributes): Likewise.
2019-12-23 08:31:34 +01:00
#define READ_SLEB(var, start, end) \
do \
{ \
dwarf_signed_vma _val; \
unsigned int _len; \
int _status; \
\
_val = read_leb128 (start, end, TRUE, &_len, &_status); \
start += _len; \
(var) = _val; \
if ((var) != _val) \
_status |= 2; \
report_leb_status (_status, __FILE__, __LINE__); \
} \
while (0)