This patch adds a default manifest in to the final links performed by the Cygwin and MinGW targets.
The manifest is necessary in order for the linked binaries to be executed in a Windows 8 environment.

The manifest is added using a linker script so that this feature will be compiler-neutral.  The resource
merging code in the linker means that if an application provides its own manifest then the default
manifest will be ignored.

	* configure.in (all_emul_extra_binaries): New variable.  Populated
	by invoking configure.tgt.
	(EMUL_EXTRA_BINARIES): New substitution.
	* configure: Regenerate.
	* configure.tgt (target_extra_binaries): New variable.  Set to
	default-manifest.o for Cygwin and MinGW targets.
	* Makefile.am (EMUL_EXTRA_BINARIES): New variable.  Initialised
	by the configure script.
	(ALL_EMUL_EXTRA_BINARIES): New variable.
	(default-manifest.o): New rule to build the default manifest.
	(ld_new_DEPENDENCIES): Add EMUL_EXTRA_BINARIES.
	(install-data-local): Add EMUL_EXTRA_BINARIES.
	* Makefile.in: Regenerate.
	* ld.texinfo: Document default manifest support.
	* emulparams/i386pe.sh (DEFAULT_MANIFEST): Define.
	* emulparams/i386pep.sh (DEFAULT_MANIFEST): Define.
	* emultempl/default-manifest.rc: New file.
	* scripttempl/pe.sc (R_RSRC): Include DEFAULT_MANIFEST, if defined.
	* scripttempl/pep.sc (R_RSRC): Likewise.

	* ld-pe/longsecn-1.d: Allow for extra sections.
	* ld-pe/longsecn-2.d: Likewise.
	* ld-pe/longsecn.d: Likewise.
	* ld-pe/secrel.d: Likewise.
Move ptid_match to common/ptid.c.

So that gdbserver can use it too.

gdb/
2014-02-27  Hui Zhu  <hui@codesourcery.com>

	PR 12702
	* infrun.c (ptid_match): Move ...
	* common/ptid.c (ptid_match): ... here.
	* inferior.h (ptid_match): Move ...
	* common/ptid.h (ptid_match): ... here.
Move linux-nat.c:status_to_str to nat/linux-waitpid.c.

So that gdbserver's Linux backend can use it too.

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

	PR 12702
	* linux-nat.c (status_to_str): Moved to nat/linux-waitpid.c.
	* nat/linux-waitpid.c: Include string.h.
	(status_to_str): Moved here and made extern.
	* nat/linux-waitpid.h (status_to_str): New declaration.
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED).

GDBserver currently hangs forever in waitpid if the leader thread
exits before other threads, or if all resumed threads exit - e.g.,
next over a thread exit with sched-locking on.  This is exposed by
leader-exit.exp.  leader-exit.exp is part of a series of tests for a
set of related problems.  See
<http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>:

 "
 To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the
 leader thread until all other threads in the group are reaped.  When
 the leader exits, it goes zombie, but waitpid will not return an exit
 status until the other threads are gone.  This is presently exercised
 by the gdb.threads/leader-exit.exp test.  The fix for that test, in
 linux-nat.c:wait_lwp, handles the case where we see the leader gone
 when we're stopping all threads to report an event to some other
 thread to the core.

 (...)

 The latter bit about not blocking if there no resumed threads in the
 process also applies to some other thread exiting, not just the main
 thread.  E.g., this test starts a thread, and runs to a breakpoint in
 that thread:

 ...
 (gdb) c
 Continuing.
 [New Thread 0x7ffff75a4700 (LWP 23397)]
 [Switching to Thread 0x7ffff75a4700 (LWP 23397)]

 Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28
 28        return 0; /* break-here */
 (gdb) info threads
 * 2 Thread 0x7ffff75a4700 (LWP 23397)  thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28
   1 Thread 0x7ffff7fcb720 (LWP 23391)  0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89

 The thread will exit as soon as we resume it.  But if we only resume
 that thread, leaving the rest of the threads stopped:

 (gdb) set scheduler-locking on
 (gdb) c
 Continuing.
 ^C^C^C^C^C^C^C^C
 "

This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED
on GDBserver, similarly to what the patch above did for native
Linux GDB.

gdb.threads/leader-exit.exp now passes.

gdb.threads/no-unwaited-for-left.exp now at least errors out instead
of hanging:

 continue
 Continuing.
 warning: Remote failure reply: E.No unwaited-for children left.

 [Thread 15454] #1 stopped.
 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93
 93          lll_wait_tid (pd->tid);
 (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits

The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver
unfortunately doesn't support fork/exec yet, but I'm confident this
fixes the related issues.

I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a
separate pass.

(BTW, in case of error in response to a vCont, it would be better for
GDB to query the target for the current thread, or re-select one,
instead of assuming current inferior_ptid is still the selected
thread.)

This implementation is a little different from GDB's, because I'm
avoiding bringing in more of this broken use of waitpid(PID) into
GDBserver.  Specifically, this avoids waitpid(PID) when stopping all
threads.  There's really no need for wait_for_sigstop to wait for each
LWP in turn.  Instead, with some refactoring, we make it reuse
linux_wait_for_event.

gdb/gdbserver/
2014-02-27  Pedro Alves  <palves@redhat.com>

	PR 12702
	* inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New
	macros.
	* linux-low.c (delete_lwp, handle_extended_wait): Add debug
	output.
	(last_thread_of_process_p): Take a PID argument instead of a
	thread pointer.
	(linux_wait_for_lwp): Delete.
	(num_lwps, check_zombie_leaders, not_stopped_callback): New
	functions.
	(linux_low_filter_event): New function, party factored out from
	linux_wait_for_event.
	(linux_wait_for_event): Rename to ...
	(linux_wait_for_event_filtered): ... this.  Add new filter ptid
	argument.  Partly rewrite.  Always use waitpid(-1, WNOHANG) and
	sigsuspend.  Check for zombie leaders.
	(linux_wait_for_event): Reimplement as wrapper around
	linux_wait_for_event_filtered.
	(linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED.  Assume that if
	a normal or signal exit is seen, it's the whole process exiting.
	(wait_for_sigstop): No longer a for_each_inferior callback.
	Rewrite on top of linux_wait_for_event_filtered.
	(stop_all_lwps): Call wait_for_sigstop directly.
	* server.c (resume, handle_target_event): Handle
	TARGET_WAITKIND_NO_RESUMED.
This patch adds support for ARM PLT entries that support a full 32-bit offset range.
Enabled via the use of a new linker command line option: --long-plt.

	* bfd-in.h: Add export of bfd_elf32_arm_use_long_plt.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (elf32_arm_plt_entry_long): New array.
	(elf32_arm_link_hash_table_create): Set plt_entry_size to 16 if
	using long PLT entries.
	(bfd_elf32_arm_use_long_plt): New function.
	(elf32_arm_populate_plt_entry): Add support for long PLT entries.

	* emultempl/armelf.em (OPTION_LONG_PLT): Define.
	(PARSE_AND_LIST_LONGOPTS): Add long-plt.
	(PARSE_AND_LIST_OPTIONS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle long-plt.
	* ld.texinfo: Document --long-plt.

	* ld-arm/long-plt-format.s: New test case.
	* ld-arm/long-plt-format.d: Expected disassembly.
	* ld-arm/arm-elf.exp: Run the new test.
Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch sigprocmask.

Just a small optimization.  No need to block/unblock signals if we're
not going to call sigsuspend.

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

	* nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG
	isn't set.
opcodes/

	* aarch64-opc.c (print_register_offset_address): Call
	get_int_reg_name to prepare the register name.

gas/testsuite/

	* gas/aarch64/ldst-reg-reg-offset.s: Add tests.
	* gas/aarch64/ldst-reg-reg-offset.d: Update.