Commit Graph

55 Commits

Author SHA1 Message Date
Nick Clifton 236f4ebe3a Remove support for old gnu v2 name mangling.
PR 24044
	* cxxfilt.c (hp_symbol_characters): Delete.
	(main): Remove depcreated demangling styles.
	* stabs.c (parse_stab_argtypes): Remove support for old gnu v2
	demangling opnames.
	* testsuite/binutils-all/cxxfilt.exp: Use the
	--no-strip-underscore option for targets that do prefix their
	symbols with underscores.
	Update tests to elimiate those that use gnu v2 encoding.
2019-01-08 16:53:26 +00:00
Simon Marchi 4ae80ffc55 Revert "Sync libiberty sources with master version in gcc repository. Updated stabs demangling and cxxfilt tests to match."
The previous commit breaks the GDB build, which is still using functions
cplus_demangle_opname & co.  Since removing these usages is not an
obvious fix, let's revert this patch until we get rid of them.
2019-01-07 18:06:35 -05:00
Nick Clifton 053af8c903 Sync libiberty sources with master version in gcc repository. Updated stabs demangling and cxxfilt tests to match.
PR 24044
	* stabs.c (parse_stab_argtypes): Remove call to
	cplus_mangle_opcode.
	* testsuite/binutils-all/cxxfilt.exp: Replace tests of v2 encoding
	with v3 encoding.  Add escape for known failures.
2019-01-07 13:18:53 +00:00
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Nick Clifton af03af8f55 Synchronize libiberty with gcc and add --no-recruse-limit option to tools that support name demangling.
This patch addresses the multitude of bug reports about resource exhaustion
in libiberty's name demangling code.  It adds a limit to the amount of
recursion that is allowed, before an error is triggered.  It also adds a
new demangling option to disable this limit.  (The limit is enabled by
default).

	PR 87681
	PR 87675
	PR 87636
	PR 87335
libiberty * cp-demangle.h (struct d_info): Add recursion_limit field.
	* cp-demangle.c (d_function_type): If the recursion limit is
	enabled and reached, return with a failure result.
        (d_demangle_callback): If the recursion limit is enabled, check
	for a mangled string that is so long that there is not enough
	stack space for the local arrays.
        * cplus-dem.c (struct work): Add recursion_level field.
	(demangle_nested_args): If the recursion limit is enabled and
	reached, return with a failure result.

include	* demangle.h (DMGL_RECURSE_LIMIT): Define.
        (DEMANGLE_RECURSION_LIMIT): Prototype.

binutuils * addr2line.c (demangle_flags): New static variable.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (translate_address): Pass demangle_flags to bfd_demangle.
        (main): Handle --recurse-limit and --no-recurse-limit options.
        * cxxfilt.c (flags): Add DMGL_RECURSE_LIMIT.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (main): Handle new options.
        * dlltool.c (gen_def_file): Include DMGL_RECURSE_LIMIT in flags
        passed to cplus_demangle.
        * nm.c (demangle_flags): New static variable.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (main): Handle new options.
        * objdump.c (demangle_flags): New static variable.
        (usage): Add --recurse-limit and --no-recurse-limit.
        (long_options): Likewise.
        (objdump_print_symname): Pass demangle_flags to bfd_demangle.
        (disassemble_section): Likewise.
        (dump_dymbols): Likewise.
        (main): Handle new options.
        * prdbg.c (demangle_flags): New static variable.
        (tg_variable): Pass demangle_flags to demangler.
        (tg_start_function): Likewise.
        * stabs.c (demangle_flags): New static variable.
        (stab_demangle_template): Pass demangle_flags to demangler.
        (stab_demangle_v3_argtypes): Likewise.
        (stab_demangle_v3_arg): Likewise.
	* doc/binutuls.texi: Document new command line options.
	* NEWS: Mention the new feature.
        * testsuite/config/default.exp (CXXFILT): Define if not already
        defined.
        (CXXFILTFLAGS): Likewise.
        * testsuite/binutils-all/cxxfilt.exp: New file.  Runs a few
        simple tests of the cxxfilt program.
2018-12-07 11:32:55 +00:00
Nick Clifton e45ad1239d Prevent a buffer overrun when parsing corrupt STABS debug information.
PR 22957
	* stabs.c (pop_binincl): Fail if the file index is off the end of
	the stack.
2018-03-13 17:03:04 +00:00
Nick Clifton 81db3241f2 Add range changing to STABS parsing functions, in order to prevent buffer overruns.
PR 22955
	* stabs.c (parse_number): Add p_end parameter and use it to check
	the validity of the pp parameter.  Add checks to prevent walking
	off the end of the string buffer.
	(parse_stab_string): Likewise.
	(parse_stab_type): Likewise.
	(parse_stab_type_number): Likewise.
	(parse_stab_range_type): Likewise.
	(parse_stab_sun_builtin_type): Likewise.
	(parse_stab_sun_floating_type): Likewise.
	(parse_stab_enum_type): Likewise.
	(parse_stab_struct_type): Likewise.
	(parse_stab_baseclasses): Likewise.
	(parse_stab_struct_fields): Likewise.
	(parse_stab_cpp_abbrev): Likewise.
	(parse_stab_one_struct_field): Likewise.
	(parse_stab_members): Likewise.
	(parse_stab_tilde_field): Likewise.
	(parse_stab_array_type): Likewise.
	* parse_stab: Compute the end of the string and then pass it on to
	individual parser functions.
2018-03-13 16:10:45 +00:00
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
Yuri Chornovian de194d8575 Fix spelling typos. 2017-07-18 16:58:14 +01:00
Nick Clifton a2dea0b20b Fix handling of corrupt STABS enum type strings.
PR binutils/21157
	* stabs.c (parse_stab_enum_type): Check for corrupt NAME:VALUE
	pairs.
	(parse_number): Exit early if passed an empty string.
2017-02-14 14:07:29 +00:00
Nick Clifton b972a0d61a Fix compile time warning about pointer comparison.
PR 21034
	* stabs.c (parse_stab_members): Fix thinko checking for g++
	version 1 stabs information.
2017-01-10 11:45:12 +00:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Ambrogino Modigliani 222c2bf0a2 Fix spelling in comments in C source files (binutils)
* dwarf.c: Fix spelling in comments.
	* dwarf.h: Fix spelling in comments.
	* objcopy.c: Fix spelling in comments.
	* od-macho.c: Fix spelling in comments.
	* rclex.c: Fix spelling in comments.
	* readelf.c: Fix spelling in comments.
	* stabs.c: Fix spelling in comments.
2016-11-27 15:00:23 +10:30
Alan Modra 2b80414579 -Wimplicit-fallthrough error fixes
Well, not all are errors, but a little more substantive than just
fiddling with comments.

bfd/
	* coffcode.h (coff_slurp_symbol_table): Revert accidental commit
	made 2015-01-08.
	* elf32-nds32.c (nds32_elf_grok_psinfo): Add missing break.
	* reloc.c (bfd_default_reloc_type_lookup): Add missing breaks.
opcodes/
	* arc-ext.c (create_map): Add missing break.
	* msp430-decode.opc (encode_as): Likewise.
	* msp430-decode.c: Regenerate.
binutils/
	* coffdump.c (dump_coff_where): Add missing break.
	* stabs.c (stab_xcoff_builtin_type): Likewise.
gas/
	* config/tc-arc.c (find_opcode_match): Add missing break.
	* config/tc-i960.c (get_cdisp): Likewise.
	* config/tc-metag.c (parse_swap, md_apply_fix): Likewise.
	* config/tc-mt.c (md_parse_option): Likewise.
	* config/tc-nds32.c (nds32_apply_fix): Likewise.
	* config/tc-hppa.c (pa_ip): Assert rather than testing last
	condition of multiple if statements.
	* config/tc-s390.c (s390_exp_compare): Return 0 on error.
	* config/tc-tic4x.c (tic4x_operand_parse): Add as_bad and break
	out of case rather than falling into next case.  Formatting.
ld/
	* plugin.c (asymbol_from_plugin_symbol): Avoid compiler warning
	by adding return.
2016-10-06 09:39:56 +10:30
Alan Modra 6f2750feaf Copyright update for binutils 2016-01-01 23:00:01 +10:30
H.J. Lu 3aade68889 Remove trailing spaces in binutils 2015-08-12 04:42:37 -07:00
H.J. Lu 7cb9e39bd8 Use 0xffffffffffffffffLL to silence GCC 6 warning
GCC 6 warns:

error: result of ‘4294967295ll << 32’ requires 65 bits to represent, but ‘long long int’ only has 64 bits [-Werror=shift-overflow=]

on ((((bfd_signed_vma) 0xffffffff) << 32) | 0xffffffff).  This patch
replaces it with bfd_signed_vma) 0xffffffffffffffffLL.

	* stabs.c (parse_stab_range_type): Use 0xffffffffffffffffLL.
2015-07-24 09:05:33 -07:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Nick Clifton f41e4712a7 Fix more memory faults uncovered by fuzzing various executables.
PR binutils/17512
	* dwarf.c (read_and_display_attr_value): Check that we do not read
	past end.
	(display_debug_pubnames_worker): Add range checks.
	(process_debug_info): Check for invalid pointer sizes.
	(display_loc_list): Likewise.
	(display_loc_list_dwo): Likewise.
	(display_debug_ranges): Likewise.
	(display_debug_aranges): Check for invalid address size.
	(read_cie): Add range checks.  Replace call strchr with while loop.
	* objdump.c (dump_dwarf): Replace abort with a warning message.
	(print_section_stabs): Improve range checks.
	* rdcoff.c (coff_get_slot): Use long for indx parameter type.
	Add check for an excesively large index.
	* rddbg.c (read_section_stabs_debugging_info): Zero terminate the
	string table.  Avoid walking off the end of the stabs data.
	* stabs.c (parse_stab_string): Add check for a NULL name.

	PR binutils/17512
	* coffcode.h (coff_slurp_line_table): Set the line number of
	corrupt entries to -1.
	(coff_slurp_symbol_table): Alway initialise the value of the
	symbol.
	* coffgen.c (coff_print_symbol): Check that the combined pointer
	is valid.
	(coff_print_symbol): Do not print negative line numbers.
	* peXXigen.c (pe_print_idata): Add range checking displaying
	member names.
2014-11-12 22:39:58 +00:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Alan Modra cb566e3aa8 PR binutils/15018
* stabs.c (parse_stab_members): Always set physname here to avoid
	gcc warning..
	(parse_stab_argtypes): ..and don't duplicate the init here.
2013-01-15 13:41:05 +00:00
Nick Clifton b149968f7a PR binutils/13925
* stabs.c (stab_demangle_v3_arglist): Cope with the demangler
	returning an empty context for a function with no arguments.
2012-03-30 12:51:07 +00:00
Nick Clifton 1fcab1afa6 * stabs.c (parse_stab_enum_type): Fix memory leaks.
(parse_stab_struct_type): Ditto.
	(parse_stab_struct_fields): Ditto.
	(parse_stab_one_struct_field): Ditto.
	(parse_stab_members): Ditto.
	(stab_demangle_qualified): Ditto.
2011-03-25 17:46:07 +00:00
Nick Clifton 3d540e936b bfd/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * aoutx.h (aout_link_input_bfd): Remove unused variable sym_count.
        * elf-eh-frame.c (_bfd_elf_eh_frame_section_offset): Remove unused
        variables htab and hdr_info and mark info parameter as unused.
        * elf.c (prep_headers): Remove unused variable i_phdrp.
        (_bfd_elf_write_object_contents): Remove unused variable i_ehdrp.
        * elf32-i386.c (elf_i386_relocate_section): Mark variabled warned
        as unused.
        * peXXigen.c (pe_print_reloc): Remove unused variable datasize.
        * verilog.c (verilog_write_section): Remove unused variable
        address.

binutils/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * dwarf.c (process_debug_info): Remove unused variable
        cu_abbrev_offset_ptr.
        (display_debug_lines_decoded): Remove unused variable prev_line.
        * elfedit.c (process_archive): Remove unused variable
        file_name_size.
        * ieee.c (ieee_start_compilation_unit): Remove unused variable
        nindx.
        (ieee_set_type): Remove unused variables info, targetindx and
        baseindx.
        * objdump.c (disassmble_byte): Remove unused variable done_dot.
        * rddbg.c (read_section_stabs_debugging_info): Remove unused
        variable other.
        * readelf.c (dump_section_as_strings): Remove unused variable
        addr.
        (process_archive): Remove unused variable file_name_size.
        * stabs.c (parse_stab_string): Mark desc parameter as unused.
        Remove unused variable lineno.
        (parse_stab_struct_type): Remove unused variable orig.
        (stab_demangle_type): Remove unused variables constp, volatilep
        and hold.

gas/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * as.c (create_obj_attrs_section): Remove unused variable addr.
        * listing.c (listing_listing): Remove unused variable message.
        * read.c: Remove unnecessary register type qualifiers.
        (s_mri): Only define/use old_flag variable if MRI_MODE_CHANGE is
        defined.

ld/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * ldlang.c (wild_sort): Remove unused variable section_name.

opcodes/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * i386-dis.c (print_insn): Remove unused variable op.
        (OP_sI): Remove unused variable mask.
2010-04-09 14:40:18 +00:00
Nick Clifton 91d6fa6a03 Add -Wshadow to the gcc command line options used when compiling the binutils.
Fix up all warnings generated by the addition of this switch.
2009-12-11 13:42:17 +00:00
Nick Clifton 3f5e193bd6 Updated soruces in binutils/* to compile cleanly with -Wc++-compat.
* binutils/addr2line.c (slurp_symtab): Fix casts. Introduce
        variable minisyms to avoid aliasing varning.
        * binutils/ar.c: Add casts. (normalize): Use name del instead of
        delete. (display_target_list,display_info_table): Change loop
        counter variable a to int.
        * binutils/bucomm.c: Add casts.
        * binutils/debug.c: Update function to use new names. (struct
        debug_baseclass): Rename member from virtual to
        is_virtual. (struct debug_type_s,struct debug_field_s,struct
        debug_baseclass_s,struct debug_method_s,struct
        debug_method_variant_s,struct debug_type_s): Rename struct from
        avoid name collision.
        * /binutils/debug.h: Use new struct names.
        * binutils/dwarf.c: Add casts. (free_debug_memory): Change loop
        counter variable a to int.
        * binutils/ieee.c: Add casts. (enum ieee_var_kind): Move to top
        level. (ieee_class_baseclass): Rename parameter virtual to
        is_virtual. (ieee_class_method_var): Rename variable virtual to
        is_virtual.
        * binutils/nm.c: Add casts.
        * binutils/objcopy.c: Add casts. (copy_archive): Rename variable
        delete to del.
        * binutils/objdump.c: Add casts. (dump_dwarf_section): Change loop
        counter variable i to int.
        * binutils/prdbg.c: Add
        casts. (pr_class_baseclass,tg_class_baseclass): Rename parameters
        virtual to is_virtual.
        * binutils/readelf.c: Add casts. (struct
        ia64_unw_table_entry,struct hppa_unw_table_entry): Move to top
        level.
        * binutils/size.c: Add casts.
        * binutils/stabs.c (parse_stab_type, parse_stab_range_type)
        (parse_stab_cpp_abbrev): Rename parameter from typename to
        type_name. (parse_stab_baseclasses): Rename variable virtual to
        is_virtual.
        * binutils/strings.c: Add casts.
        * binutils/wrstabs.c (stab_class_baseclass): Rename parameter
        virtual to is_virtual.
2009-09-10 13:40:44 +00:00
Alan Modra aa820537ea update copyright dates 2009-09-02 07:25:43 +00:00
Nick Clifton 6176abac10 PR 6934
* stabs.c (parse_stab_string): Parse and ignore =Y<name> strings
        generated by the SUNPro C++ compiler.
2008-10-02 17:10:01 +00:00
Nick Clifton 42b722c134 PR 6922
* stabs.c (parse_stab_sun_builtin_type): Parse, but ignore SUN's
   'b' and 'v' extensions.
2008-09-30 12:19:51 +00:00
Nick Clifton 32866df75e Change sources over to using GPLv3 2007-07-05 16:54:46 +00:00
Alan Modra 3db64b0092 bfd/
Many files: Include sysdep.h before bfd.h.
	* Makefile.am: Run "make dep-am".
	* Makefile.in: Regenerate.
binutils/
	* bucumm.h: Split off host dependencies to..
	* sysdep.h: ..here.
	Many files: Include sysdep.h.  Remove duplicate headers and reorder.
	* Makefile.am: Run "make dep-am".
	* Makefile.in: Regenerate.
ld/
	Many files: Include sysdep.h first.  Remove duplicate headers.
	* Makefile.am: Run "make dep-am".
	* Makefile.in: Regenerate.
opcodes/
	* Makefile.am: Run "make dep-am".
	* Makefile.in: Regenerate.
	* ns32k-dis.c: Include sysdep.h first.
2007-04-26 14:47:00 +00:00
Nick Clifton 0112cd268b * bfd-in.h (STRING_AND_COMMA): New macro. Takes one constant string as its
argument and emits the string followed by a comma and then the length of
  the string.
  (CONST_STRNEQ): New macro.  Checks to see if a variable string has a constant
  string as its initial characters.
  (CONST_STRNCPY): New macro.  Copies a constant string to the start of a
  variable string.
* bfd-in2.h: Regenerate.
* <remainign files>: Make use of the new macros.
2006-09-16 18:12:17 +00:00
Nick Clifton b43b5d5f76 Update FSF address 2005-05-08 14:17:41 +00:00
Ian Lance Taylor 2b25cacb21 PR binutils/536
* stabs.c (stab_demangle_template): Call stab_demangle_count
	rather than stab_demangle_get_count to get the length of a pointer
	target.
2004-11-10 16:10:17 +00:00
Ian Lance Taylor 2b4c4cc415 * stabs.c (stab_demangle_v3_arglist): New static function, broken
out of stab_demangle_v3_argtypes.
	(stab_demangle_v3_argtypes): Call it.
	(stab_demangle_v3_arg): Handle DEMANGLE_COMPONENT_FUNCTION_TYPE.
	If we find an unrecognized component, print out its number.
2004-10-25 15:25:20 +00:00
Ian Lance Taylor 12d08d706b Update copyright year. 2004-01-12 21:08:00 +00:00
Ian Lance Taylor 041821e62e * stabs.c (parse_stab_argtypes): Handle g++ ABI version 3 names.
(stab_demangle_argtypes): Likewise.
	(stab_demangle_v3_argtypes): New static function.
	(stab_demangle_v3_arg): New static function.
2004-01-12 21:04:04 +00:00
Kazu Hirata aaad4cf36a * ChangeLog-9197: Fix comment typos.
* coffgrok.c: Likewise.
	* filemode.c: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* prdbg.c: Likewise.
	* stabs.c: Likewise.
	* unwind-ia64.c: Likewise.
2003-12-06 00:06:12 +00:00
Nick Clifton 1be5957932 Fix 'the the' typo 2003-11-06 11:58:58 +00:00
Andreas Jaeger 2da42df615 * addr2line.c: Convert to ISO C90 prototypes, change PTR, remove
unneeded (void *) casts.
	* ar.c: Likewise.
	* arlex.l: Likewise.
	* arparse.y: Likewise.
	* arsup.c: Likewise.
	* binemul.c: Likewise.
	* binemul.h: Likewise.
	* bucomm.c: Likewise.
	* bucomm.h: Likewise.
	* budbg.h: Likewise.
	* budemang.c: Likewise.
	* budemang.h: Likewise.
	* coffdump.c: Likewise.
	* coffgrok.c: Likewise.
	* cxxfilt.c: Likewise.
	* debug.c: Likewise.
	* debug.h: Likewise.
	* deflex.l: Likewise.
	* dlltool.c: Likewise.
	* dlltool.h: Likewise.
	* dllwrap.c: Likewise.
	* emul_aix.c: Likewise.
	* filemode.c: Likewise.
	* ieee.c: Likewise.
	* nlmconv.c: Likewise.
	* nlmconv.h: Likewise.
	* nlmheader.y: Likewise.
	* nm.c: Likewise.
	* prdbg.c: Likewise.
	* rclex.l: Likewise.
	* rcparse.y: Likewise.
	* rdcoff.c: Likewise.
	* rddbg.c: Likewise.
	* rename.c: Likewise.
	* resbin.c: Likewise.
	* rescoff.c: Likewise.
	* resrc.c: Likewise.
	* size.c: Likewise.
	* srconv.c: Likewise.
	* stabs.c: Likewise.
	* strings.c: Likewise.
	* sysdump.c: Likewise.
	* sysinfo.y: Likewise.
	* syslex.l: Likewise.
	* unwind-ia64.c: Likewise.
	* unwind-ia64.h: Likewise.
	* version.c: Likewise.
	* windres.c: Likewise.
	* windres.h: Likewise.
	* winduni.c: Likewise.
	* wrstabs.c: Likewise.
2003-09-14 12:20:17 +00:00
Nick Clifton 7eb5191ac3 Remove redundant defintions of BYTES_IN_WORD and add conditional defintion in
aout64.h.
2003-03-06 16:45:42 +00:00
Nick Clifton 6de15b9e9d For N_SLINE only include function_start_offset if the symbol is within a
function; otherwise, the value is absolute.
2003-02-13 10:38:37 +00:00
Alan Modra b34976b65a s/boolean/bfd_boolean/ s/true/TRUE/ s/false/FALSE/. Simplify
comparisons of bfd_boolean vars with TRUE/FALSE.  Formatting.
2002-11-30 08:39:46 +00:00
Nick Clifton 4b73ca9289 Cope with demangling function names that include a double underscore. 2002-08-16 11:44:03 +00:00
Kazu Hirata d43efbe328 * arsup.c: Remove ARGSUSED.
* debug.c: Likewise.
	* ieee.c: Likewise.
	* nlmconv.c: Likewise.
	* prdbg.c: Likewise.
	* stabs.c: Likewise.
	* wrstabs.c: Likewise.
2002-05-26 14:55:04 +00:00
Kazu Hirata 9f66665ac5 * size.c: Fix formatting.
* srconv.c: Likewise.
	* stabs.c: Likewise.
	* sysdump.c: Likewise.
	* unwind-ia64.c: Likewise.
	* wrstabs.c: Likewise.
2002-05-24 00:33:36 +00:00
H.J. Lu 3882b01078 Locale changes from Bruno Haible <haible@clisp.cons.org>. 2001-09-19 05:33:36 +00:00
Ben Elliston d81d65845e 2001-08-29 Ben Elliston <bje@redhat.com>
* stabs.c (stab_demangle_template): Initialise s4.
2001-08-29 10:55:43 +00:00
Alan Modra 8855cbcaee * stabs.c: Update copyright. Include "filenames.h".
(parse_stab): Use IS_ABSOLUTE_PATH. Ignore N_WARNING stabs.
2001-01-24 02:34:07 +00:00
Alan Modra 3c9f43b196 Warning fixes. 2000-07-10 14:51:04 +00:00