Ensure ld testsuite gcc -B options precede $CC -B options

Various ld-elf/shared.exp and ld-plugin/lto.exp tests simply appended
the testsuite -B options intended to force gcc use the linker under test.
This fails if $CC itself has -B options, as when setting CC to run gcc
out of a build directory.  Net result is that tests were run using
the gcc build dir collect-ld.

	* config/default.exp: Don't make tmpdir/gas.  Put as symlink into
	tmpdir/ld.
	(gcc_gas_flag, gcc_ld_flag): Delete.
	(gcc_B_opt, ld_L_opt): New globals.
	ld-elf/shared.exp: Remove all refs to gcc_gas_flag and gcc_ld_flag.
	ld-plugin/lto.exp: Likewise.
	lib/ld-lib.exp (run_host_cmd): Add gcc_B_opt and ld_L_opt here.
	(ld_simple_link): Remove -B handling now that this is done in
	run_host_cmd.  Simplify.
	(default_ld_compile): Simplify.
	(check_lto_available): Use run_host_cmd_yesno.
	(check_lto_shared_available): Likewise.
This patch prevents a linker testsuite error if the checks are run with a
toolchain that just contains the binutils - ie without a compiler.

	* lib/ld-lib.exp (check_lto_available): Check that a compiler is
	available before testing for LTO support.
Reinstate compiler check

	* lib/ld-lib.exp (check_lto_shared_available): Reinstate compiler
	check here too.
convert to_get_thread_local_address to use target delegation

This converts to_get_thread_local_address to use
TARGET_DEFAULT_NORETURN.  One possible oddity is that this changes the
text of the kind of exception thrown in some cases.  This doesn't seem
to be a problem; in fact perhaps the final call to 'error' in
target_translate_tls_address should be changed to call
generic_tls_error.

2014-07-07  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_get_thread_local_address>: Use
	TARGET_DEFAULT_NORETURN.
	* target.c (generic_tls_error): New function.
	(target_translate_tls_address): Don't search target stack.
	* target-delegates.c: Rebuild.
	* ppc-linux-tdep.c (ppc_linux_spe_context): Don't search target
	stack.
	* linux-thread-db.c (thread_db_get_thread_local_address):
	Unconditionally call beneath target.
change to_info_record to use target delegation

This changes to_info_record to use target delegation.
Also, target_info_record was unused, so this patch removes it.

2014-07-07  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_info_record): Remove.
	* record.c (info_record_command): Unconditionally call
	to_info_record.
	* target.h (struct target_ops) <to_info_record>: Use
	TARGET_DEFAULT_IGNORE.
	(target_info_record): Remove.
Adds support for writing values to AVR system I/O registers.

	* elf32-avr.c: Handle R_AVR_PORT5 and R_AVR_PORT6.
	* reloc.c: Add BFD_RELOC_AVR_PORT5 and BFD_RELOC_AVR_PORT6.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

	* avr.h: Add R_AVR_PORT5 and R_AVR_PORT6.

	* config/tc-avr.c (avr_operand): Permit referring to r26-r31 by
	name as [xyz][hl].  Permit using a symbol whoes name begins with
	`r' to refer to a register.
	Allow arbitrary expressions for the P and p operators.
	(md_apply_fix): Check the BFD_RELOC_AVR_PORT5 and
	BFD_RELOC_AVR_PORT6 relocations.
Remove an accidental commit.

	* readelf.c (get_symbol_type): Revert accidental change to
	detection of thumb function symbols.
PR gdb/17096: async support breaks remote debugging on Windows

On Windows, with "maint set target-async on" (the default since
a09dd441), Ctrl-C fails to stop a remote target.

With maint target-async on, the SIGINT signal handler doesn't send the
remote interrupt request immediately.  Instead, it marks an async
handler as ready, and then the main event loop wakes up and notices
that the SIGINT async signal handler token was set, and calls the
corresponding event handler, which sends the remote interrupt request.

On POSIX-like systems, the SIGINT signal makes the select/poll in the
main event loop wake up / return with EINTR.  However, on Windows,
signal handlers run on a separate thread, and Windows doesn't really
have a concept of EINTR.  So, just marking the async handler
(effectively just setting a flag) does not wake up gdb_select.
Instead, we need to call gdb_call_async_signal_handler from the signal
handler.  The Windows version (in mingw-hdep.c) sets a Windows event
that gdb_select's WaitForMultipleObjects is waiting for.

Confirmed that with this, Ctrl-C interrupts the remote target on
Windows.  Also regression tested on x86_64 Fedora 20 against
GDBserver.

gdb/
2014-07-07  Pedro Alves  <palves@redhat.com>

	* remote.c (async_handle_remote_sigint)
	(async_handle_remote_sigint_twice): Call
	gdb_call_async_signal_handler instead of
	mark_async_signal_handler.
Mention PR gdb/17096 in ChangeLog
daily update
Run ar with --plugin for LTO 11 test

Objects built with -fno-fat-lto-objects (the default for gcc-4.9) have
no normal symbols, except things like __gnu_lto_slim.  These useless
symbols are the ones put into the archive index, and of course nothing
references them so no objects are extracted by the linker.  Running
ar with --plugin changes ar behaviour to put the lto symbols into the
archive index.

	PR 17112
	* ld-plugin/lto.exp: When building liblti-11.a, pass
	--plugin path_to_gcc/liblto_plugin.so to ar.
reverse-finish: turn internal error into normal error

The reverse-finish command results in an internal error if it cannot determine
the current function.

  (gdb) c
  Continuing.

  Program received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()
  (gdb) reverse-finish
  Run back to call of #0  0x0000000000000000 in ?? ()
  gdb/infcmd.c:1576: internal-error: Finish: couldn't find function.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) y

This is not an internal error case since the command may be used in scenarios
where there is no function at the current PC, e.g. after calling through a bad
function pointer.

Turn this into a normal error.

gdb/
	* infcmd.c (finish_backward): Turn internal error into normal error.

testsuite/
	* gdb.btrace/segv.c: New.
	* gdb.btrace/segv.exp: New.
Enable elf_backend_rela_normal for AArch64

  If we are generating non-relocatable object and --emit-relocs specified,
  aarch64 ld is actually generating wrong addend for rela entry when
  relocate against local symbol.

  for example, for simple testcase

  foo.c
  ===

  const char * const a = "foo";

  const char *
  foo ()
  {
    return a;
  }

  bar.c
  ===

  const char * const b = "bar";

  const char * bar ()
  {
    return b;
  }

  aarch64-none-linux-gnu-ld --emit-relocs -o x.o  foo.o bar.o
  aarch64-none-linux-gnu-readelf -r x.o

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0

   while it should be:

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 10
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 10

   bfd generic code could actually handle this properly, but only when
   elf_backend_rela_normal set to '1'.

   this patch enable this and remove those target specific hack.

    bfd/
      * elfnn-aarch64.c (elf_backend_rela_normal): Set to 1.
      (elfNN_aarch64_relocate_section): Remove duplicated addend adjustment
      when info->relocatable be true.

    ld/testsuite/
      * ld-aarch64/emit-relocs-local-addend-bar.s: * New source file.
      * ld-aarch64/emit-relocs-local-addend-foo.s: * Likewise.
      * ld-aarch64/emit-relocs-local-addend.d: * New testcase.
      * ld-aarch64/local-addend-r.d: Likewise.
Fix gdb.trace/entry-values.exp for thumb mode

We see some fails in gdb.trace/entry-values.exp in thumb mode
(-mthumb -march={armv4t,armv7-a}).

In thumb mode, the lsb of references to 'foo' and 'bar' in the assembly
(produced by dwarf assember) is set, so the generated debug
information is incorrect.

This patch copies the approach used by

  [PATCH 4/4] Fix dw2-ifort-parameter.exp on PPC64
  https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html

to introduce new labels 'foo_start' and 'bar_start' which are about
the correct function address (without lsb set).  This patch fixes
these fails we've seen.

gdb/testsuite:

2014-07-08  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/entry-values.c: Define labels 'foo_start' and
	'bar_start' at the beginning of functions 'foo' and 'bar'
	respectively.
	* gdb.trace/entry-values.exp: Use 'foo_start' and 'bar_start'
	instead of 'foo' and 'bar'.
Copy st_other for linker script symbol assignments

This fixes a problem seen on powerpc64le ELFv2 when creating a
function symbol alias with ld --defsym.  st_other needs to be copied
from the source symbol to the alias in order to set up the local entry
offset for the alias.  I decided to make this change in the generic
ELF code rather than in elf64-ppc.c since it looks like other targets
that use st_other bits might benefit too.

bfd/
	* elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other
	bits from source to dest.
	* linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment.
	* targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>):
	Likewise.
	* bfd-in2.h: Regenerate.
ld/testsuite/
	* ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
	* ld-powerpc/powerpc.exp: Run it.
Fix PR 16722 by adding support for 8-byte vector constants.

 * config/tc-arm.c (literal_pool): New field "alignment".
  (find_or_make_literal_pool): Initialize "alignment" to 2.
  (s_ltorg): Align the pool using value of "alignment"
  (parse_big_immediate): New parameter "in_exp". Return
  parsed expression if "in_exp" is not null.
  (parse_address_main): Invoke "parse_big_immediate" for
  constant parameter.
  (add_to_lit_pool): Add one parameter 'nbytes'.
  Split 8 byte entry into two 4 byte entry.
  Add padding to align 8 byte entry to 8 byte boundary.
  (encode_arm_cp_address): Generate literal pool entry if possible.
  (move_or_literal_pool): Generate entry for vldr case.
  (enum lit_type): New enum type.
  (do_ldst): Use new enum type.
  (do_ldstv4): Likewise.
  (do_t_ldst): Likewise.
  (neon_write_immbits): Support Thumb-2 mode.

  * gas/arm/ldconst.s: Add test cases for symbol literal.
  * gas/arm/ldconst.d: Likewise.
  * gas/arm/vldconst.s: Add test cases for vldr.
  * gas/arm/thumb2_vpool.s: Likewise.
  * gas/arm/vldconst.d: New pattern for little-endian.
  * gas/arm/thumb2_vpool.d: Likewise.
  * gas/arm/vldconst_be.d: New pattern for big-endian.
  * gas/arm/thumb2_vpool_be.d: Likewise.
ld/ARM: Increase maximum page size to 64kB

Increase the maximum page size to 64kB and align the TEXT_START_ADDR
to a 64kB boundary. This brings AArch32 in line with AArch64 and
improves compatability under certain conditions.

bfd/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* elf32-arm.c (ELF_MAXPAGESIZE): Increase the default
	value to 64kB and remove custom setting for NaCl.

ld/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* emulparams/armelf_linux.sh (TEXT_START_ADDR): Increase
	alignment to 64kB boundary.

ld/testsuite/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* ld-arm/arm-lib.ld: Increase MAXPAGESIZE value to
	match bfd.
	* ld-arm/cortex-a8-fix-bl-rel-plt.d: Update offsets to
	take into account increased segment alignment.
	* ld-arm/ifunc-gdesc.r: Likewise.
	* ld-arm/tls-lib.d: Likewise.
Fix disasm of vmovsd/vmovss with different length values.

gas/testsuite

	* gas/i386/evex-lig256-intel.d: Updated.
	* gas/i386/evex-lig256.d: Updated.
	* gas/i386/evex-lig512-intel.d: Updated.
	* gas/i386/evex-lig512-intel.d: Updated.
	* gas/i386/x86-64-evex-lig256-intel.d: Updated.
	* gas/i386/x86-64-evex-lig256.d: Updated.
	* gas/i386/x86-64-evex-lig512-intel.d: Updated.
	* gas/i386/x86-64-evex-lig512-intel.d: Updated.

opcodes

	* i386-dis-evex.h (EVEX_W_0F10_P_1_M_1): Fix vmovss.
	(EVEX_W_0F10_P_3_M_1): Fix vmovsd.
This fixes PR 17110 which shows that the SH section relocation code can be called
for input BFDs as well as output BFDs.

	PR ld/17110
	* elf32-sh.c (sh_elf_osec_to_segment): Do not look for output
	segments in input bfds.
	* scripttempl/avr.sc: Remove KEEP for .data and
	force .bss VMA to end of .data VMA.