aboutsummaryrefslogtreecommitdiff
path: root/binutils
AgeCommit message (Collapse)AuthorFilesLines
2017-11-03Fix integer overflow problems when reading an ELF binary with corrupt ↵Nick Clifton2-25/+50
augmentation data. PR 22386 * dwarf.c (read_cie): Use bfd_size_type for augmentation_data_len. (display_augmentation_data): New function. (display_debug_frames): Use it. Check for integer overflow when testing augmentation_data_len.
2017-11-02Work around integer overflows when readelf is checking for corrupt ELF notes ↵Mingi Cho2-16/+23
when run on a 32-bit host. PR 22384 * readelf.c (print_gnu_property_note): Improve overflow checks so that they will work on a 32-bit host.
2017-11-01FT32B is a new FT32 family member. It has a code compression scheme, which ↵James Bowman2-0/+6
requires the use of linker relaxations. The change is quite large, so submission is in several parts. Part 2 adds a relaxation pass, which actually implements the code compression scheme. bfd * archures.c: Add bfd_mach_ft32b. * cpu-ft32.c: Add arch_info_struct. * elf32-ft32.c: Add R_FT32_RELAX, SC0, SC1, DIFF32. (ft32_elf_relocate_section): Add clauses for R_FT32_SC0, SC1, DIFF32. (ft32_reloc_shortable, elf32_ft32_is_diff_reloc, elf32_ft32_adjust_diff_reloc_value, elf32_ft32_adjust_reloc_if_spans_insn, elf32_ft32_relax_delete_bytes, elf32_ft32_relax_is_branch_target, ft32_elf_relax_section): New function. * reloc.c: Add BFD_RELOC_FT32_RELAX, SC0, SC1, DIFF32. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas * config/tc-ft32.c (md_assemble): add relaxation reloc BFD_RELOC_FT32_RELAX. (md_longopts): Add "norelax" and "no-relax". (md_apply_fix): Add reloc BFD_RELOC_FT32_DIFF32. (relaxable_section, ft32_validate_fix_sub, ft32_force_relocation, ft32_allow_local_subtract): New function. * config/tc-ft32.h: remove unused MD_PCREL_FROM_SECTION. * testsuite/gas/ft32/insnsc.s: New test exercising all FT32B shortcodes. include * elf/ft32.h: Add R_FT32_RELAX, SC0, SC1, DIFF32.
2017-11-01Fix an invalid free called when attempting to link a COFF object against an ↵Nick Clifton1-2/+10
ELF archive with --no-keep-memory enabled. PR 22369 * coffgen.c (_bfd_coff_free_symbols): Fail if called on a non-COFF file. * cofflink.c (coff_link_check_archive_element): Skip non-COFF members of an archive.
2017-10-31Remind users to use the --use-dynamic command line option to dump dynamic ↵Nick Clifton2-1/+21
relocations. * readelf.c (process_relocs): Tell users if no static relocs were found, but if they had added --use-dynamic to the command line then relocs would have been displayed.
2017-10-28PR22361 readelf buffer overflow on fuzzed archive headerAlan Modra2-0/+18
PR 22361 * readelf.c (process_archive_index_and_symbols): Ensure ar_size field is zero terminated for strtoul. (setup_archive, get_archive_member_name): Likewise.
2017-10-27dwarf: Read register number as unsigned in DW_CFA_def_cfa*Simon Marchi2-4/+10
When displaying the .debug_frame section, the register numbers in the DW_CFA_def_cfa* statements are read as signed numbers. I have come across a target that has register 121, encoded as 0x79 in unsigned LEB128. Interpreting this as signed results in -7, which makes readelf display "r-7". The DWARF5 standard (6.4.2.2) states that the register numbers should be treated as unsigned LEB128. Simply replacing READ_SLEB with READ_ULEB resulted in warnings like these: /home/emaisin/src/binutils-gdb/binutils/dwarf.c: In function ‘display_debug_frames’: /home/emaisin/src/binutils-gdb/binutils/dwarf.c:355:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if ((var) != _val) \ ^ /home/emaisin/src/binutils-gdb/binutils/dwarf.c:7866:8: note: in expansion of macro ‘READ_ULEB’ READ_ULEB (fc->cfa_reg); ^ ... so I also changed Frame_Chunk::cfa_reg to an unsigned int. binutils/ChangeLog: * dwarf.c (struct Frame_Chunk) <cfa_reg>: Change type to unsigned int. (display_debug_frames): Read CFA reg as an unsigned number.
2017-10-25Allow for __gnu_lto_slim prefixed with extra "_"Alan Modra2-1/+8
Some targets prefix global symbols with "_". bfd/ * archive.c (_bfd_compute_and_write_armap): Match "__gnu_lto_slim" optionally prefixed with "_". * linker.c (_bfd_generic_link_add_one_symbol): Likewise. binutils/ * nm.c (filter_symbols): Match "__gnu_lto_slim" optionally prefixed with "_". gold/ * symtab.cc (Symbol_table::add_from_relobj): Match "__gnu_lto_slim" optionally prefixed with "_". ld/ * testsuite/ld-plugin/lto-3r.d: Match "__gnu_lto_v" optionally prefixed with "_". * testsuite/ld-plugin/lto-5r.d: Likewise.
2017-10-18[Visium] Disassemble the operands of the stop instruction.Eric Botcazou2-0/+5
binutils/ * MAINTAINERS: Add myself as Visium maintainer. opcodes/ * visium-dis.c (disassem_class1) <case 0>: Print the operands.
2017-10-18Add a warning to the how-to-make-a-release notes to check the permissions on ↵Nick Clifton2-5/+17
the files in the tarball. * README-how-to-make-a-release: A note about checking file and directory permissions.
2017-10-18Move Svein Seldal to Past Maintainers section.Nick Clifton2-1/+5
* MAINTAINERS: Move Svein Seldal to Past Maintainers section.
2017-10-18PR22303, print_core_note out of bounds readAlan Modra2-27/+35
The print_core_note change here fixes the PR, the rest is making readelf a little more bombproof against maliciously crafted binaries. PR 22303 * readelf.c (print_core_note): Ensure "count" sanity check calculation doesn't overflow. (process_notes_at): Perform note namesz and descsz checks using unsigned comparisons against data remaining. Catch alignment overflow of namesz and descsz too. Don't allocate a temp for terminating "name" when there is space available before descdata.
2017-10-17Add myself as dwarf-mode.el maintainerTom Tromey2-0/+5
In https://sourceware.org/ml/binutils/2017-10/msg00160.html, Nick said I should update MAINTAINERS to mention that I'm the dwarf-mode.el maintainer. So, I'm checking this in. 2017-10-17 Tom Tromey <tom@tromey.com> * MAINTAINERS: Add myself as dwarf-mode.el maintainer.
2017-10-11Display more information when decoding DW_AT_endianity, DW_AT_decimal_sign, ↵Nick Clifton5-6/+283
DW_AT_defaulted and DW_AT_discr_list DWARF attributes. * dwarf.c (read_and_display_attr_value): Handle DW_AT_endianity, DW_END_default, DW_END_big, DW_END_little, DW_ATE_UCS, DW_ATE_ASCII, DW_CC_pass_by_reference, DW_CC_pass_by_value, DW_CC_GNU_renesas_sh, DW_CC_GNU_borland_fastcall_i386, DW_AT_decimal_sign, DW_AT_defaulted, DW_AT_discr_list. (get_TAG_name): Report user generated tag values. * testsuite/binutils-all/dwarf-attributes.S: New test. * testsuite/binutils-all/dwarf-attributes.W. Expected output from readelf. * testsuite/binutils-all/readelf.exp: Run the new test.
2017-10-10Bump dwarf-mode version numberTom Tromey2-1/+5
Bump the dwarf-mode version number, so it can be installed by package.el users who installed an earlier verision. 2017-10-10 Tom Tromey <tom@tromey.com> * dwarf-mode.el: Bump to version 1.4.
2017-10-10Asynchronous insertion for dwarf-mode.elTom Tromey2-16/+68
I was recently examining a very large .debug file. I tried to use dwarf-mode, but it blocked Emacs for a very long time while reading output. This patch changes dwarf-mode to run the objdump process asynchronously. This way, I can still do other things in Emacs while waiting for the dumping to finish. 2017-10-10 Tom Tromey <tom@tromey.com> * dwarf-mode.el (dwarf--process, dwarf--deletion-region): New defvar. (dwarf--check-running, dwarf--sentinel, dwarf--invoke) (dwarf--filter): New functions. (dwarf-do-insert-substructure, dwarf-do-refresh): Call dwarf--check-running, dwarf--invoke. (dwarf-browse): Initialize new variables.
2017-10-10Set lexical-binding in dwarf-modeTom Tromey2-1/+5
Emacs has had lexical binding for a while, and it's a good practice to use it; so enable it in dwarf-mode.el. 2017-10-10 Tom Tromey <tom@tromey.com> * dwarf-mode.el: Set lexical-binding.
2017-10-10Bind keys in dwarf-mode-map definitionTom Tromey2-2/+11
It's bad Emacs style to define keys from a top-level form. Instead, one should define a mode map separately and binding keys in the definition. This lets users completely override the map by defining it before loading the mode. 2017-10-10 Tom Tromey <tom@tromey.com> * dwarf-mode.el (dwarf-mode-map): New defvar.
2017-10-10Improve the speed of the --dwarf-start option by skipping processing of any ↵Nick Clifton2-0/+14
comp unit that ends before the specified start address. PR 22249 * dwarf.c (process_debug_info): Skip any comp unit that ends before dwarf_start_die.
2017-10-06DWARF header checksAlan Modra2-86/+95
This patch tidies DWARF header checks, consolidating the "negative" checks (which are really overflow checks) with the section size check. In a number of cases this also ensures that small negative lengths are caught. For instance hdrptr = start + arange.ar_length + initial_length_size; if (hdrptr < start || hdrptr > end) does not detect ar_length in the range [-initial_length_size,-1]. * dwarf.c (process_debug_info): Consolidate header length checks. (display_debug_pubnames_worker): Use "start" to read header. Properly check header length and report errors earlier. Simplify loop printing pubnames. (get_line_filename_and_dirname): Catch small negative "length" values. (display_debug_aranges): Likewise. Report header errors earlier using standardized message. (display_debug_names): Likewise.
2017-10-05Avoid spurious readelf error status from decode_arm_unwind.Joseph Myers2-1/+5
readelf.c:decode_arm_unwind has a variable res that is used as a return value, with FALSE meaning unsuccessful and TRUE meaning successful. This is initialized to FALSE (and then various code in the function sets it to FALSE again on error), meaning that when the function is successful, if it reaches returning res is still returns FALSE, resulting eventually in exit status 1 from readelf without any error message to indicate an error. This patch fixes the initialization to use TRUE, so avoiding those spurious errors. I don't have a self-contained test for this issue; it was observed as many prelink tests failing without the patch and passing with it. * readelf.c (decode_arm_unwind): Initialize res to TRUE.
2017-10-05Fix strip so that is accepts -M as an abbreviation for --merge-notes.Nick Clifton2-1/+7
PR 22260 * objcopy.c (strip_main): Add 'M' character to short options list when calling getopt_long.
2017-10-05Change readelf so that when --wide is active a relocation's full name is ↵Nick Clifton2-1/+7
displayed. PR 22262 binutils* readelf.c (dump_relocations): Do not truncate reloc names when displaying output in wide mode. ld * testsuite/ld-powerpc/relocsort.d: Update expected output (for longer reloc names).
2017-10-05Update README-how-to-make-a-release with the correct sequence for creating ↵Nick Clifton2-39/+34
the source tarball. * README-how-to-make-a-release: Merge steps 3, 4 and 5, and insert the git tag operation at the correct location.
2017-10-05PR22239 - invalid memory read in display_debug_framesAlan Modra2-11/+12
Pointer comparisons have traps for the unwary. After adding a large unknown value to "start", the test "start < end" depends on where "start" is originally in memory. PR 22239 * dwarf.c (read_cie): Don't compare "start" and "end" pointers after adding a possibly wild length to "start", compare the length to the difference of the pointers instead. Remove now redundant "negative" length test.
2017-10-05Update my email address.Tristan Gingold2-3/+8
Also refer to global maintainers for branch release approval.
2017-10-01PR22232, NULL pointer dereference in load_specific_debug_sectionAlan Modra2-2/+10
PR 22232 PR 22230 * objdump.c (load_specific_debug_section): Introduce a temp to stop bfd_get_full_section_contents NULLing out section->start.
2017-10-01PR22230, buffer overflow in display_debug_macroAlan Modra2-4/+11
PR 22230 * objdump.c (load_specific_debug_section): Allocate an extra byte for a terminating NUL.
2017-09-30PR21978, objdump does not display line numbers in certain casesAlan Modra2-12/+24
Same line but different file ought to display file and line. PR 21978 * objdump.c: Formatting. (show_line): Reset prev_line when function name changes.
2017-09-27Prevent an infinite loop in the DWARF parsing code when encountering a CU ↵Nick Clifton2-1/+16
structure with a small negative size. PR 22219 * dwarf.c (process_debug_info): Add a check for a negative cu_length field.
2017-09-27PR22216, infinite loop in readelf process_symbol_tableAlan Modra2-18/+34
This should make readelf bombproof given a fuzzed DT_HASH. Also removes a bogus check that would have resulted in wrong histograms. PR 22216 * readelf.c (process_symbol_table): Check that DT_HASH symbol chains are only visited once, and report an error if not. Display invalid symbol index if chain is out of range. Use the same logic when calculating histograms rather than the PR 17531 fix. Delete bogus check that chained index is less than number of buckets.
2017-09-26Fix address violations when parsing a corrupt DWARF linenumber table.Nick Clifton2-5/+22
PR 22154 * dwarf.c (get_line_filename_and_dirname): Add extra checks for buffer overruns.
2017-09-26Add README file for creating binutils releasesNick Clifton2-0/+139
2017-09-26PR21732, String-concatenated message can not be translatedAlan Modra3-30/+60
Preprocessor tokens like DWARF_VMA_FMT and BFD_VMA_FMT are not understood by gettext, and cause the translation string to be truncated. Even if it were not truncated, we wouldn't want a value that changes depending on host or configure options to be put in a translation string. PR 21732 * dwarf.c (READ_ULEB): Don't use DWARF_VMA_FMT in translated string. (READ_SLEB): Likewise. * readelf.c (bfd_vmatoa): New function. (get_data, get_dynamic_data): Use it for printing error messages.
2017-09-25Free memory returned from bfd_get_synthetic_symtabH.J. Lu2-1/+9
PR binutils/22203 * nm.c (display_rel_file): Free memory returned from bfd_get_synthetic_symtab.
2017-09-22LVU: dump loclists with locviewsAlexandre Oliva8-35/+1048
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-22readelf testsAlan Modra2-43/+49
We have multiple tests that report failure to assemble without saying exactly what test is failing. * testsuite/binutils-all/readelf.exp: Don't perror and exit on bintest.s assembly failure. Report tests unresolved instead. Likewise for version note test, pr18374, decompress, and dw5 tests. (readelf_test): Set testname to include both option and binary file name. Use for pass/fail.
2017-09-22readelf: Handle E_MIPS_MACH_5900Maciej W. Rozycki2-0/+5
Fix commit e407c74b5b60 ("Support for MIPS R5900 (Sony Playstation 2)"), <https://sourceware.org/ml/binutils/2012-12/msg00240.html>, and add the handling of E_MIPS_MACH_5900, correctly showing `5900' among `Flags:' in the output of `-h' rather than `unknown CPU'. binutils/ * readelf.c (get_machine_flags) <E_MIPS_MACH_5900>: New case. gas/ * testsuite/gas/mips/elf_mach_5900.d: New test. * testsuite/gas/mips/mips.exp: Run it.
2017-09-05Fix a buffer overrun when parsing a corrupt MIPS ELF binary.Nick Clifton2-3/+9
PR 21995 * readelf.c (process_mips_specific): Add checks for a NULL data pointer.
2017-09-05Missing relocation R_PPC_VLE_ADDR20 and add VLE flag to details in readelfAlexander Fedotov-B556132-0/+17
include/ * elf/ppc.h (R_PPC_VLE_ADDR20): New relocation. bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_VLE_ADDR20. (ppc_elf_check_relocs): Handle it. (ppc_elf_vle_split20): New function. (ppc_elf_relocate_section): Handle R_PPC_VLE_ADDR20. binutils/ * readelf.c (get_elf_section_flags): Add VLE. (process_section_headers): Add VLE key to details. gas/ * config/tc-ppc.c (md_parse_option): Handle "mno-vle" flag. (ppc_elf_section_letter): New function. * config/tc-ppc.h (md_elf_section_letter): New. * testsuite/gas/elf/section10.d: Adjust for VLE.
2017-08-25PR21994, readelf looping on verdefsAlan Modra2-14/+39
PR 21994 * readelf.c (process_version_sections <SHT_GNU_verdef>): Check vd_aux and vda_next for sanity. Delete "end". Correct overflow checks. (process_version_sections <SHT_GNU_verneed>): Correct overflow check. Don't report invalid vna_next on overflow. Do report invalid vna_next on size less than aux info.
2017-08-23PR21990, Integer overflow in process_version_sectionsAlan Modra2-26/+29
This tidies some of the overflow checking when processing verneed and verdef sections. PR 21990 * readelf.c (process_version_sections <SHT_GNU_verneed>): Check for invalid vn_next field before adding to idx. Use unsigned long for index vars. Move index checks. <SHT_GNU_verdef>: Likewise for vd_next.
2017-08-17Add test of V2 GNU build attribute notes.Nick Clifton8-1/+232
* testsuite/binutils-all/note-3-64.s: New test. Checks assembly and decoding of version2 GNU build attribute notes. * testsuite/binutils-all/note-3-32.s: New test. 32-bit version of the above test. * testsuite/binutils-all/note-3-64.d: New test driver. * testsuite/binutils-all/note-3-32.d: New test driver. * testsuite/binutils-all/objcopy.exp: Run the new test. * readelf.c (is_64bit_abs_reloc): Add R_SPARC_64.
2017-08-16Add new NT_PPC_* available since Linux 4.8Gustavo Romero2-0/+31
Add new note types available since Linux 4.8 to elf/common.h and make the 'readelf' tool aware of it. include/ * elf/common.h (NT_PPC_TAR): New macro. (NT_PPC_PPR): Likewise. (NT_PPC_DSCR): Likewise. (NT_PPC_EBB): Likewise. (NT_PPC_PMU): Likewise. (NT_PPC_TM_CGPR): Likewise. (NT_PPC_TM_CFPR): Likewise. (NT_PPC_TM_CVMX): Likewise. (NT_PPC_TM_CVSX): Likewise. (NT_PPC_TM_SPR): Likewise. (NT_PPC_TM_CTAR): Likewise. (NT_PPC_TM_CPPR): Likewise. (NT_PPC_TM_CDSCR): Likewise. binutils/ * readelf.c (get_note_type): Handle PPC note types available since Linux 4.8.
2017-08-12Collision between NT_GNU_BUILD_ATTRIBUTE_OPEN and NT_PPC_VMXAlan Modra2-4/+15
* readelf.c (process_note): Qualify NT_GNU_BUILD_ATTRIBUTE notes by name data.
2017-08-08Fix address violation bugs when writing beyond the end of a local string buffer.Nick Clifton2-3/+10
PR 21909 * prdbg.c (pr_int_type): Increase size of local string buffer. (pr_float_type): Likewise. (pr_bool_type): Likewise.
2017-08-02Add support for creating archives of slim-LTO modules using MRi script commands.Nick Clifton2-4/+15
PR 21702 * arsup.c (ar_addmod): Add plugin support for the MRI ADDMOD command.
2017-08-02Fix gas and binutils testsuite failures for am33_2.0-linux target.Nick Clifton2-1/+5
gas * testsuite/gas/all/gas.exp: Add am33 to the skip lists of tests passed over by the mn10300 target. * testsuite/gas/elf/elf.exp: Likewise. * testsuite/gas/elf/dwarf2-11.d: Correct skip of am33 target. * 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. binutils * testsuite/binutils-all/objdump.exp (cpus_expected): Add am33-2.
2017-08-02Teach readelf about IA64 MSB relocs.Alan Modra2-4/+15
* readelf.c (is_32bit_abs_reloc): Add R_IA64_SECREL32MSB and R_IA64_DIR32MSB. (is_64bit_abs_reloc): Add R_IA64_DIR64MSB. (is_64bit_pcrel_reloc): Add R_IA64_PCREL64MSB.
2017-08-01Updated Swedish translation for the binutils sub-directory.Nick Clifton2-1202/+580
* po/sv.po: Updated Swedish translation.