* configure.ac: Add od-elf32_avr to build.
	* configure: Regenerate.
	* od-elf32_avr.c: New file.
	* objdump.h: Declare objdump_private_desc_elf32_avr.
	* od-elf32_avr.c: Forgot to add a new file.
More fixes for invalid memory accesses triggered by fuzzed binaries.

	PR binutils/17531
	* dwarf.c (display_debug_frames): Check for a negative
	augmentation data length.
	(display_gdb_index): Check for invalid offsets.
	* elfcomm.c (process_archive_index_and_symbols): Check for an
	index number that overflows when multiplied by the ar index size.
	* readelf.c (dump_ia64_unwind): Add range checks.
	(slurp_ia64_unwind_table): Change to a boolean function.  Add
	range checks.
	(process_version_sections): Add range checks.
	(get_symbol_version_string): Add check for missing section
	headers.
Automatic date update in version.in
python/py-objfile.c (objfpy_get_owner): Increment refcount of result.

gdb/ChangeLog:

	* python/py-objfile.c (objfpy_get_owner): Increment refcount of result.
ppc64_elf_edit_opd revamp, take 2

Now that ld -r relocs are sorted by the pr17666 fix, there isn't so
much need to sort incoming relocs.

	* elf64-ppc.c (sort_r_offset): Delete.
	(ppc64_elf_edit_opd): Don't sort input relocs.
Ensure zero termination of tic4x insn buffer

	* config/tc-tic4x.c (md_assemble): Ensure insn->name is zero
	terminated.  Simplify concatenation of parallel insn.
Fix windres memory leak

	* windres.c (open_file_search): Free path buffer on failure.
More fixes for memory access violations triggered by fuzzed binaries.

	PR binutils/17512
	* objdump.c (display_any_bfd): Avoid infinite loop closing and
	opening the same archive again and again.

	* archive64.c (bfd_elf64_archive_slurp_armap): Add range checks.
	* libbfd.c (safe_read_leb128): New function.
	* libbfd-in.h (safe_read_leb128): Add prototype.
	* libbfd.h: Regenerate.
	* elf-attrs.c (_bfd_elf_parse_attributes): Use safe_read_leb128.
	Check for an over-long subsection length.
	* elf.c (elf_parse_notes): Check that the namedata is long enough
	for the string comparison that is about to be performed.
	(elf_read_notes): Zero-terminate the note buffer.
	* od-elf32_avr.c (elf32_avr_dump_mem_usage): Fix device initialization.
Don't sort ld -r relocs for mips

HI16/LO16 are deliberately put adjacent, which might mean relocs are
then not sorted by r_offset.  See tc-mips.c:mips_frob_file.  Don't undo
the HI16/LO16 sorting.

	PR 17666
	* elf-bfd.h (struct elf_backend_data): Add sort_relocs_p.
	* elfxx-target.h (elf_backend_sort_relocs_p): Define.
	(elfNN_bed): Init new field.
	* elflink.c (elf_link_adjust_relocs): Conditionally sort.
	(bfd_elf_final_link): Control sorting of relocs.
	* elfxx-mips.c (_bfd_mips_elf_sort_relocs_p): New function.
	* elfxx-mips.h (_bfd_mips_elf_sort_relocs_p): Declare.
	* elf32-mips.c (elf_backend_sort_relocs_p): Define.
	* elf64-mips.c (elf_backend_sort_relocs_p): Define.
Automatic date update in version.in
Don't access elf tdata in dwarf.c without first checking for an ELF bfd

_bfd_dwarf2_find_nearest_line may be called on a COFF bfd.

	* dwarf2.c (read_address): Check bfd_target_elf_flavour before
	calling get_elf_backend_data.
	(_bfd_dwarf2_find_nearest_line): Fix parens.
Don't return DW_AT_name for function name in C++

DW_AT_name for functions typically just contains the base function
name, so lacks namespace, class and parameter information.  It would
be possible to extract all these from the DWARF, but at a considerable
complication of the parser in dwarf2.c, and then you'd need to mangle
it all together.  Much simpler is to look up the actual symbol.  This
patch does that, avoiding the extra symbol lookup when the language
doesn't do name mangling.

	PR 17541
	* dwarf2.c (struct comp_unit): Add "lang".
	(non_mangled): New function.
	(struct funcinfo): Add "is_linkage".  Reorder for better packing.
	Make "name" a const char*.
	(lookup_address_in_function_table): Delete functionname_ptr param.
	(find_abstract_instance_name): Add is_linkage param.  Set if we
	have DW_AT_linkage_name or non_mangled DW_AT_name.
	(scan_unit_for_symbols): Similarly set func->is_linkage.
	(parse_comp_unit): Stash DW_AT_language.
	(comp_unit_find_nearest_line): Replace functionname_ptr param
	with function_ptr param.
	(_bfd_dwarf2_find_nearest_line): Adjust above calls.  Set
	functionname_ptr from function->name.  Call _bfd_elf_find_function
	to retrieve symbol for function if not linkage name.
	(_bfd_elf_find_function): Add bfd_target_elf_flavour test, moved from..
	* elf.c (elf_find_function): ..here.
	(_bfd_elf_find_nearest_line): Adjust calls.
	* elf-bfd.h (_bfd_elf_find_function): Declare.
Don't always build coffgen.o

Removes a bunch of unused functions from libbfd when building ELF or
AOUT.  Split off the bits we need externally when not building a COFF
target into coff-bfd.c and coff-bfd.h.

bfd/
	* Makefile.am (BFD32_LIBS, BFD32_LIBS_CFILES): Remove dwarf2
	and coffgen.  Add coff-bfd.  Sort.
	(BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add coffgen and dwarf2.
	* bfd-in.h (bfd_coff_get_syment, bfd_coff_get_auxent): Delete.
	(struct coff_comdat_info, bfd_coff_get_comdat_section): Delete.
	* coffgen.c (coff_symbol_from): Move to coff-bfd.h as macro,
	without unused param.  Update uses.
	(bfd_coff_get_comdat_section): Move to coff-bfd.h as macro.
	(bfd_coff_get_syment, bfd_coff_get_auxent): Move to coff-bfd.c.
	* libcoff-in.h: #include "coff-bfd.h".
	(struct coff_section_tdata, coff_section_data): Move to coff-bfd.h.
	(coff_symbol_from): Delete.
	* coff-bfd.c: New file.
	* coff-bfd.h: New file.
	* coff-i386.c: Update coff_symbol_from occurrences.
	* coff-i960.c: Likewise.
	* coff-m68k.c: Likewise.
	* coff-sh.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coffcode.h: Likewise.
	* pe-mips.c: Likewise.
	* configure.ac (elf): Add dwarf2.lo.
	(coffgen, coff, ecoff, xcoff): Define.  Use when mapping bfd
	target vectors to .o files.  Add dwarf2 for mach-o targets.
	Fix the sh target FIXME.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* bfd-in2.h: Regenerate.
	* libcoff.h: Regenerate.
binutils/
	* objdump.c: #include "coff-bfd.h".
ld/
	* ldmisc.c: #include "coff-bfd.h"
Restore terminal state in mi_thread_exit (PR gdb/17627)

When a thread exits, the terminal is left in mode "terminal_is_ours"
while the target executes.  This patch fixes that.

We need to manually restore the terminal setting in this particular
observer.  In the case of the other MI observers that call
target_terminal_ours, gdb will end up resuming the inferior later in the
execution and call target_terminal_inferior.  In the case of the thread
exit event, we still need to call target_terminal_ours to be able to
print something, but there is nothing that gdb will need to resume after
that. We therefore need to call target_terminal_inferior ourselves.

gdb/ChangeLog:

	PR gdb/17627
	* target.c (cleanup_restore_target_terminal): New function.
	(make_cleanup_restore_target_terminal): New function.
	* target.h (make_cleanup_restore_target_terminal): New
	declaration.
	* mi/mi-interp.c (mi_thread_exit): Use the new cleanup.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
cp_lookup_symbol_imports: Make static.

gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_imports): Make static.
	* cp-support.c (cp_lookup_symbol_imports): Delete.
cp-namespace.c (lookup_symbol_file): Move next to only caller.

gdb/ChangeLog:

	* cp-namespace.c (lookup_symbol_file): Move next to only caller.
cp_lookup_symbol_nonlocal: Move definition closer to its subroutines.

gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_nonlocal): Move definition,
	closer to its subroutines.