Fix memort access problems exposed by fuzzed binaries.

	PR binutils/17531
	* readelf.c (get_unwind_section_word): Skip reloc processing if
	there are no relocs associated with the section.
	(decode_tic6x_unwind_bytecode): Warn and return if the stack
	pointer adjustment falls off the end of the buffer.
[AArch64] Add xgene1.

The name xgene1 superceeds xgene-1.  We retain support for the
original xgene-1 for compatibility but drop it from documentation.
[AArch64] Add xgene2.
aarch64: allow adding/removing just feature flags via .arch_extension

Rather than requiring to always also set/change the base architecture,
allow just en-/disabling of architecture extensions, matching what ARM
has.
I caught a few mingw32-specific failures for some of the gdb.reverse
tests.

FAIL: gdb.reverse/consecutive-precsave.exp: reload precord save file
FAIL: gdb.reverse/finish-precsave.exp: reload precord save file
FAIL: gdb.reverse/until-precsave.exp: reload core file
FAIL: gdb.reverse/watch-precsave.exp: reload core file
FAIL: gdb.reverse/step-precsave.exp: reload core file
FAIL: gdb.reverse/break-precsave.exp: reload precord save file
FAIL: gdb.reverse/sigall-precsave.exp: reload precord save file

They happen for two reasons.

- mingw32 does not define SIGTRAP, so upon recording a core file, the
signal information will be missing, which in turn causes GDB to not
display the stopping signal when it loads the same core file.  An
earlier message warns about this:

"warning: Signal SIGTRAP does not exist on this system."

- The testcase is crafted in a way that expects a pattern of the
stopping signal message instead of a successful core file read message.

The following patch fixes this by changing the old pattern to a more
reasonable one, while still ignoring the fact that mingw32-based GDB
does not record a SIGTRAP in a core file because it does not define
it.

gdb/testsuite/

2014-11-18  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.reverse/break-precsave: Expect completion message for
	core file reads.
	* gdb.reverse/consecutive-precsave.exp: Likewise.
	* gdb.reverse/finish-precsave.exp: Likewise.
	* gdb.reverse/i386-precsave.exp: Likewise.
	* gdb.reverse/machinestate-precsave.exp: Likewise.
	* gdb.reverse/sigall-precsave.exp: Likewise.
	* gdb.reverse/solib-precsave.exp: Likewise.
	* gdb.reverse/step-precsave.exp: Likewise.
	* gdb.reverse/until-precsave.exp: Likewise.
	* gdb.reverse/watch-precsave.exp: Likewise.
Add -z bndplt to generate BND prefix in PLT entries

This patch adds "-z bndplt" option Linux/x86-64 linker to generate BND
prefix in PLT entries.  It also updated Linux/x86-64 assembler not to
generate R_X86_64_PLT32_BND nor R_X86_64_PC32_BND relocations.

bfd/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* elf64-x86-64.c (elf_x86_64_check_relocs): Enable MPX PLT only
	for -z bndplt.

gas/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* config/tc-i386-intel.c (i386_operator): Remove last argument
	from lex_got call.
	* config/tc-i386.c (reloc): Remove bnd_prefix from parameters'
	list.  Return always BFD_RELOC_32_PCREL.
	* (output_branch): Remove condition for BFD_RELOC_X86_64_PC32_BND.
	* (output_jump): Update call to reloc accordingly.
	* (output_interseg_jump): Likewise.
	* (output_disp): Likewise.
	* (output_imm): Likewise.
	* (x86_cons_fix_new): Likewise.
	* (lex_got): Remove bnd_prefix from parameters' list in macro and
	declarations. Don't use BFD_RELOC_X86_64_PLT32_BND.
	* (x86_cons): Update call to lex_got accordingly.
	* (i386_immediate): Likewise.
	* (i386_displacement): Likewise.
	* (md_apply_fix): Don't use BFD_RELOC_X86_64_PLT32_BND nor
	BFD_RELOC_X86_64_PC32_BND.
	* (tc_gen_reloc): Likewise.

include/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* bfdlink.h (struct bfd_link_info): Add bndplt.

ld/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* emulparams/elf_x86_64.sh (BNDPLT): Set to yes for x86_64.
	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle
	"-z bndplt" if BNDPLT is yes.
	(gld${EMULATION_NAME}_list_options): Add "-z bndplt" entry.
	* ld.texinfo: Add description for bndplt.

ld/testsuite/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* testsuite/ld-x86-64/bnd-ifunc-1.d: Add bndplt option.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.  Update dissassembly
	sections.
	* testsuite/ld-x86-64/mpx.exp: Handle mpx3 and mpx4 tests.
	* testsuite/ld-x86-64/mpx1a.rd: Remove _BND from relocation name.
	* testsuite/ld-x86-64/mpx1c.rd: Likewise.
	* testsuite/ld-x86-64/mpx2a.rd: Likewise.
	* testsuite/ld-x86-64/mpx2c.rd: Likewise.
	* testsuite/ld-x86-64/mpx3.dd: New file.
	* testsuite/ld-x86-64/mpx3a.s: Likewise.
	* testsuite/ld-x86-64/mpx3b.s: Likewise.
	* testsuite/ld-x86-64/mpx4.dd: Likewise.
	* testsuite/ld-x86-64/mpx4a.s: Likewise.
	* testsuite/ld-x86-64/mpx4b.s: Likewise.
Always run mpx3 and mpx4 tests in 64-bit

	* ld-x86-64/mpx.exp: Always run mpx3 and mpx4 tests in 64-bit.
More fixes for illegal memory accesses exposed by fuzzed binaries.

	PR binutils/17512
	* peXXIgen.c (pe_print_pdata): Fail if the section's virtual size
	is larger than its real size.
	(rsrc_print_section): Fix off-by-one error checking for overflow.
	* pei-x86_64.c (pex64_bfd_print_pdata): Handle empty unwind
	sections.

	* dwarf.c (get_encoded_value): Warn and return if the encoded
	value is more than 64-bits long.
	(SAFE_BYTE_GET): Do not attempt to read more than 64-bits.
	(process_extended_line_op): Add more range checks.
	(decode_location_expression): Use the return value from
	display_block.  Add more range checks.
	(read_debug_line_header): Add range check.
	(display_debug_lines_raw): Add range checks.
	(display_debug_frames): Silently skip multiple zero terminators.
	Add range checks.
	(process_cu_tu_index): Check for non-existant or empty sections.
	Use SAFE_BYTE_GET instead of byte_get.
The result of symtab expansion is always a primary symtab.

gdb/ChangeLog:

	* dwarf2read.c (dw2_instantiate_symtab): Add assert.
	(dw2_lookup_symbol): Remove unnecessary test for primary symbol table.
	* psymtab.c (lookup_symbol_aux_psymtabs): Ditto.
	(psymtab_to_symtab): Add comment and assert.
	(map_matching_symbols_psymtab): Remove unnecessary test for
	non-primary symtab.
Split up end_symtab_from_static_block into two.

This patch is conceptually quite simple.
If you look at end_symtab_from_static_block you'll see
that the static_block == NULL case is completely different
than the non-NULL case.

There's a lot of complexity to handle the NULL case but it seems
entirely unnecessary.  For example, whether blockvector is NULL
is decided at the start, before this for loop:

  for (subfile = subfiles; subfile; subfile = nextsub)

Secondly, after the for loop, we test symtab for non-NULL here:

  /* Set this for the main source file.  */
  if (symtab)

but symtab will only ever be non-NULL if blockvector was non-NULL.
And if blockvector was non_NULL so will symtab.

The other case to consider is these lines of code executed before
the for loop:

  /* Read the line table if it has to be read separately.
     This is only used by xcoffread.c.  */
  if (objfile->sf->sym_read_linetable != NULL)
    objfile->sf->sym_read_linetable (objfile);

  /* Handle the case where the debug info specifies a different path
     for the main source file.  It can cause us to lose track of its
     line number information.  */
  watch_main_source_file_lossage ();

From my reading of the code, neither of these is useful
in the static_block == NULL case.

Thus we can make the code more readable by splitting these two cases up,
which is what this patch does.

gdb/ChangeLog:

	* buildsym.c (main_subfile): New static global.
	(free_subfiles_list): New function.
	(start_symtab): Set main_subfile.
	(restart_symtab): Replace init of subfiles, current_subfile with
	call to free_subfiles_list.
	(watch_main_source_file_lossage): Use main_subfile.
	(reset_symtab_globals): Replace init of current_subfile with call
	to free_subfiles_list.
	(end_symtab_without_blockvector, end_symtab_with_blockvector): New
	functions, split out from ...
	(end_symtab_from_static_block): ... here.  Rewrite to call them.
Use SYMBOL_OBJFILE more.

gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Use
	SYMBOL_OBJFILE.
	* findvar.c (default_read_var_value): Ditto.
	* jv-lang.c (add_class_symtab_symbol): Ditto.
	* parse.c (operator_check_standard): Ditto.
	* printcmd.c (address_info): Ditto.
	* symtab.c (fixup_symbol_section): Ditto.
	(skip_prologue_sal): Ditto.
	* tracepoint.c (scope_info): Ditto.
	* valops.c (find_function_in_inferior): Ditto.
	* guile/scm-symbol.c (syscm_eq_symbol_smob): Ditto.
	* python/py-symbol.c (set_symbol): Ditto.
Fix memory leak in watch_main_source_file_lossage.

gdb/ChangeLog:

	* buildsym.c (watch_main_source_file_lossage): Fix memory leak.
SYMTAB_OBJFILE: New macro.

gdb/ChangeLog:

	* symtab.h (SYMTAB_OBJFILE): New macro.  All uses of member
	symtab.objfile updated to use it.
SYMTAB_DIRNAME: New macro.

gdb/ChangeLog:

	* symtab.h (SYMTAB_DIRNAME): New macro.  All uses of member
	symtab.dirname updated to use it.
symtab.h (SYMTAB_LINETABLE): Renamed from LINETABLE.  All uses updated.

gdb/ChangeLog:

	* symtab.h (SYMTAB_LINETABLE): Renamed from LINETABLE.  All uses
	updated.
Fixes a seg-fault when displaying the time data for a corrupt archive.

	PR binutuls/17605
	* bucomm.c (print_arelt_descr): Check for ctime returning NULL.
buildsym API cleanup

gdb/ChangeLog:

	* buildsym.c (buildsym_objfile): New static global.
	(buildsym_comp_dir): New static global.
	(finish_block_internal): Delete arg objfile.  All callers updated.
	(finish_block): Delete arg objfile.  All callers updated.
	(start_subfile): Delete arg dirname.  All callers updated.
	(patch_subfile_names): Update buildsym_comp_dir.
	(get_macro_table): Delete arg objfile.  All callers updated.
	(start_symtab): New arg objfile.  All callers updated.
	Rename arg dirname to comp_dir.
	(reset_symtab_globals): Initialize buildsym_objfile, buildsym_comp_dir.
	(end_symtab_get_static_block): Delete arg objfile.  All callers
	updated.
	(end_symtab_without_blockvector): Ditto.
	(end_symtab_with_blockvector): Ditto.
	(end_symtab_from_static_block): Ditto.
	(end_symtab): Ditto.
	(end_expandable_symtab): Ditto.
	(augment_type_symtab): Ditto.
	* coffread.c (coff_start_symtab): New arg objfile.  All callers
	updated.
symtab.h (SYMTAB_BLOCKVECTOR): Renamed from BLOCKVECTOR.  All uses updated.

gdb/ChangeLog:

	* symtab.h (SYMTAB_BLOCKVECTOR): Renamed from BLOCKVECTOR.  All uses
	updated.
Check PC-relative offset overflow in PLT entry

This patch checks PC-relative offset overflow in pushq instruction in
x86-64 PLT entry.

bfd/

	PR ld/17618
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
	PC-relative offset overflow in PLT entry.

ld/testsuite/

	PR ld/17618
	* ld-x86-64/x86-64.exp: Run pr17618 for Linux target.

	* ld-x86-64/pr17618.d: New file.
	* ld-x86-64/pr17618.s: Likewise.
Automatic date update in version.in