aboutsummaryrefslogtreecommitdiff
path: root/binutils/elfcomm.h
AgeCommit message (Collapse)AuthorFilesLines
2022-11-23Don't use "long" in readelf for file offsetsAlan Modra1-13/+13
The aim here is to improve readelf handling of large 64-bit object files on LLP64 hosts (Windows) where long is only 32 bits. The patch changes more than just file offsets. Addresses and sizes are also changed to avoid "long". Most places get to use uint64_t even where size_t may be more appropriate, because that allows some overflow checks to be implemented easily (*alloc changes). * dwarf.c (cmalloc, xcmalloc, xcrealloc, xcalloc2): Make nmemb parameter uint64_t. * dwarf.h: Update prototypes. (struct dwarf_section): Make num_relocs uint64_t. * elfcomm.c (setup_archive): Update error format. * elfcomm.h (struct archive_info): Make sym_size, longnames_size, nested_member_origin, next_arhdr_offset uint64_t. * readelf.c (struct filedata): Make archive_file_offset, archive_file_size, string_table_length, dynamic_addr, dynamic_nent, dynamic_strings_length, num_dynamic_syms, dynamic_syminfo_offset uint64_t. (many functions): Replace uses of "unsigned long" with "uint64_t" or "size_t".
2022-08-13Replace elf_vma with uint64_tAlan Modra1-11/+9
This patch replaces all uses of elf_vma with uint64_t, removes tests of sizeof (elf_vma), and does a little tidying of byte_get_little_endian and byte_get_big_endian.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-05-12SAFE_BYTE_GET64Alan Modra1-9/+8
Functions dealing with lack of a 64-bit integer type can disappear now that we require C99. Printing using dwarf_vmatoa is better too. binutils/ * dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete. (skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with SAFE_BYTE_GET_AND_INC. (read_and_display_attr_value): Likewise. Print using dwarf_vmatoa. (process_debug_info, process_cu_tu_index): Likewise. * elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian), (byte_get, byte_get_little_endian, byte_get_big_endian), (byte_get_signed): Make size param unsigned. Remove code dealing with 4-byte elf_vma. (byte_get_64): Delete. * elfcomm.h (byte_put, byte_put_little_endian, byte_put_big_endian), (byte_get, byte_get_little_endian, byte_get_big_endian), (byte_get_signed): Update prototypes. (byte_get_64): Delete. gas/ * testsuite/gas/elf/dwarf-5-file0.d: Update. * testsuite/gas/i386/dwarf5-line-1.d: Update.
2021-04-01Remove strneq macro and use startswith.Martin Liska1-1/+0
bfd/ChangeLog: * ecoff.c (strneq): Remove strneq and use startswith. (_bfd_ecoff_slurp_armap): Likewise. binutils/ChangeLog: * elfcomm.h (strneq): Remove strneq and use startswith. * readelf.c (ia64_process_unwind): Likewise. (process_note): Likewise. gas/ChangeLog: * config/obj-coff.c (strneq): Remove strneq and use startswith. (weak_is_altname): Likewise. (obj_coff_section): Likewise. * config/tc-cr16.c (process_label_constant): Likewise. * config/tc-crx.c (strneq): Likewise. include/ChangeLog: * opcode/cr16.h (strneq): Remove strneq and use startswith. ld/ChangeLog: * ldbuildid.c (strneq): Remove strneq and use startswith. (validate_build_id_style): Likewise. (compute_build_id_size): Likewise. opcodes/ChangeLog: * arm-dis.c (strneq): Remove strneq and use startswith. * cr16-dis.c (print_insn_cr16): Likewise. * score-dis.c (streq): Likewise. (strneq): Likewise. * score7-dis.c (strneq): Likewise.
2021-04-01Replace const_strneq with startswith.Martin Liska1-1/+0
binutils/ChangeLog: * dwarf.c (display_debug_lines_raw): Replace const_strneq with startswith. (display_debug_lines_decoded): Likewise. (display_debug_links): Likewise. * elfcomm.c (setup_archive): Likewise. * elfcomm.h (const_strneq): Likewise. * readelf.c (process_section_headers): Likewise. (slurp_ia64_unwind_table): Likewise. (slurp_hppa_unwind_table): Likewise. (decode_arm_unwind): Likewise. (display_debug_section): Likewise. (process_note): Likewise.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2020-05-05Restore readelf's warnings that describe real problems with the file being ↵Nick Clifton1-2/+2
examined. Fix bug displaying empty file name tables. binutils* dwarf.c (do_checks): New global variable. (display_formatted_table): Warn about an unexpected number of columns in the table, if checks are enabled. Do not complain about the lack of data following the number of entries in the table if the table is empty. (display_debug_lines_decoded): Only warn about an unexpected number of columns in a table if checks are enabled. * dwarf.h (do_checks): Add a prototype. * elfcomm.c (error): Remove weak attribute. (warn): Likewise. * readelf.c (do_checks): Delete. (warn): Delete. (process_section_headers): Only warn about empty sections if checks are enabled. gas * dwarf2dbg.c (out_dir_and_file_list): Add comments describing the construction of a DWARF-5 directory name table. * testsuite/gas/elf/pr25917.d: Update expected output.
2020-03-19Don't use bfd.h in binutils/elfcomm.cAlan Modra1-3/+3
Better than warning about bfd types, just don't include bfd.h and warn against including the header again. * elfcomm.c: Don't include bfd.h or bucomm.h. (program_name): Declare. (process_archive_index_and_symbols): Replace bfd_boolean with int, and substitute FALSE and TRUE. (setup_archive, setup_nested_archive): Likewise. * elfcomm.h: Likewise.
2020-03-19setup_archive parameter mismatchAlan Modra1-1/+1
* elfcomm.c (setup_archive): Make file_size an off_t. Comment. * elfcomm.h (setup_archive): Update prototype.
2020-03-14readelf large memory allocationAlan Modra1-1/+1
* elfcomm.h (setup_archive): Update prototype. * elfcomm.c (setup_archive): Add file_size parameter and sanity check longnames_size. (setup_nested_archive): Get file size and pass to setup_archive. * elfedit.c (process_archive): Likewise. * readelf.c (process_archive): Pass filedata->file_size to setup_archive.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2019-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2018-07-24PR23430, Indices misspelledAlan Modra1-1/+1
PR 23430 include/ * elf/common.h (SHT_SYMTAB_SHNDX): Fix comment typo. bfd/ * dwarf2.c (dwarf_debug_section_enum): Fix comment typo. * elf.c (bfd_section_from_shdr, elf_sort_sections): Likewise. binutils/ * elfcomm.h (struct archive_info): Rename uses_64bit_indicies to uses_64bit_indices. * elfcomm.c (setup_archive): Update uses of above. * readelf.c (process_archive): Likewise. (get_section_type_name): Rename indicies to indices. (get_32bit_elf_symbols, get_64bit_elf_symbols): Likewise. (process_section_groups): Likewise. cpu/ * or1kcommon.cpu (spr-reg-indices): Fix description typo. opcodes/ * or1k-desc.h: Regenerate.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2017-11-15Add support to readelf and objdump for following links to separate debug ↵Nick Clifton1-5/+5
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-01-02Update year range in copyright notice of all files.Alan Modra1-1/+1
2016-07-16Don't include libbfd.h outside of bfd, part 3Alan Modra1-7/+0
Fix od-macho.c to use a leb128 function from binutils/dwarf.c rather than one from bfd/libbfd.c. binutils/ * elfcomm.h (HOST_WIDEST_INT): Move to.. * sysdep.h: ..here. * od-macho.c: Don't include libbfd.h. Do include dwarf.h (dump_dyld_info_rebase): Use read_leb128 rather than read_unsigned_leb128. (dump_dyld_info_bind, dump_dyld_info_export_1): Likewise. (dump_segment_split_info): Likewise. (dump_dyld_info): Rename vars to avoid shadowing dwarf.h enums. (dump_load_command): Likewise.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-12-11Use autoconf check for long long in binutilsAlan Modra1-1/+1
Also fix a place where %lld was wrongly used to print a dwarf_vma. * configure.ac: Check for long long and sizes of long long and long. * elfcomm.h (HOST_WIDEST_INT): Test HAVE_LONG_LONG in place of __STDC_VERSION__ and __GNUC__. * strings.c (print_strings): Likewise. * dwarf.c (DWARF_VMA_FMT, DWARF_VMA_FMT_LONG): Likewise. (read_debug_line_header): Use dwarf_vmatoa to print warning. * configure: Regenerate. * config.in: Regenerate.
2014-12-01Add checks for memory access violations exposed by fuzzed archives.Nick Clifton1-1/+1
PR binutils/17531 * dwarf.c (process_cu_tu_index): Check for an out of range row index. * elfcomm.c (adjust_relative_path): Change name_len parameter to an unsigned long. Check for path length overflow. (process_archive_index_and_symbols): Check for invalid header size. (setup_archive): Add checks for invalid archives. (get_archive_member_name): Add range checks. * elfcomm.h (adjust_relative_path): Update prototyoe. * readelf.c (process_archive): Add range checks.
2014-03-05Update copyright yearsAlan Modra1-2/+1
2012-07-17 * elfcomm.c (setup_archive): Extract index table and symbol tableNick Clifton1-2/+3
scanning code into... (process_archive_index_and_symbols): ... this function and add support for 64-bit index tables. * elfcomm.h (struct archive_info): Change type of index_num and index_array to elf_vma. Add 'uses_64bit_indicies' field. * readelf.c (process_archive): Fix support for 64-bit indicies.
2012-02-15 * dwarf.c (dwarf_vmatoa64): New function.Cary Coutant1-0/+1
(read_and_display_attr_value): Print 8-byte forms as single hex numbers. (process_debug_info): Print type signatures as single hex numbers. * elfcomm.c (byte_get_64): New function. * elfcomm.h (byte_get_64): New function.
2010-11-21Add and use elfcomm.c/elfcomm.h.H.J. Lu1-0/+110
2010-11-21 H.J. Lu <hongjiu.lu@intel.com> PR binutils/12235 * elfcomm.c: New. * elfcomm.h: Likewise. * Makefile.am (HFILES): Add elfcomm.h. (CFILES): Add elfcomm.c. (ELFLIBS): New. (readelf_SOURCES): Add $(ELFLIBS). (elfedit_SOURCES): Likewise. (objdump_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: Include "elfcomm.h". (byte_get): Removed. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (byte_get_signed): Likewise. (error): Likewise. (warn): Likewise. * dwarf.h (dwarf_vma): Defined with HOST_WIDEST_INT. (dwarf_size_type): Likewise. (byte_get): Removed. (byte_get_signed): Likewise. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (error): Likewise. (warn): Likewise. * elfedit.c: Include "elfcomm.h". Don't include "aout/ar.h". Call error () instead of non_fatal (). (streq): Removed. (strneq): Likewise. (const_strneq): Likewise. (non_fatal): Likewise. (BYTE_GET): Likewise. (BYTE_PUT): Likewise. (byte_get): Likewise. (byte_put): Likewise. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (byte_put_little_endian): Likewise. (byte_put_big_endian): Likewise. (adjust_relative_path): Likewise. (archive_info): Likewise. (setup_archive): Likewise. (release_archive): Likewise. (setup_nested_archive): Likewise. (get_archive_member_name): Likewise. (get_archive_member_name_at): Likewise. (make_qualified_name): Likewise. * objdump.c: Include "elfcomm.h". * readelf.c: Include "elfcomm.h". Don't include "aout/ar.h". (BYTE_GET): Removed. (BYTE_GET_SIGNED): Removed. (streq): Likewise. (strneq): Likewise. (const_strneq): Likewise. (byte_put): Likewise. (byte_put_little_endian): Likewise. (byte_put_big_endian): Likewise. (adjust_relative_path): Likewise. (archive_info): Likewise. (setup_archive): Likewise. (release_archive): Likewise. (setup_nested_archive): Likewise. (get_archive_member_name): Likewise. (get_archive_member_name_at): Likewise. (make_qualified_name): Likewise.