Check branch displacement overflow in x86-64 PLT entry

Displacement of branch to PLT0 in x86-64 PLT entry is signed 32-bit.
This patch adds a sanity check.  We will only see the failure when PLT
size is > 2GB.

	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
	branch displacement overflow in PLT entry.
cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.

gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.
symtab.c: Comment and whitespace improvements.

gdb/ChangeLog:

	* symtab.c (lookup_symbol_in_objfile_from_linkage_name): Improve
	function comment.
	(search_symbols): Fix comments and whitespace.
Automatic date update in version.in
s/immediatly/immediately/ in sim/sh/ChangeLog entry.
sim/igen/: Change immediatly to immediately

sim/igen/ChangeLog:

        * igen/ld-cache.h, igen/table.h: Change immediatly to immediately.
sim/ppc/*: Change immediatly to immediately

sim/ppc/ChangeLog:

	* ChangeLog, ChangeLog.00, hw_com.c, ld-cache.h, ppc-instructions:
	Change immediatly to immediately.
Refine read_string

In read_string, we have this line

  chunksize = (len == -1 ? min (8, fetchlimit) : fetchlimit);

but chunksize is only used in the block that lne == -1, so IWBN to
move chunksize to the block in which it is used, and simplify the
condition setting chunksize.  This patch also moves 'found_nul' to
inner block.  This patch also splits a paragraph of comment into two,
and move them to different condition blocks (len > 0 and len == -1)
respectively.

gdb:

2014-11-23  Yao Qi  <yao@codesourcery.com>

	* valprint.c (read_string): Move local variables 'found_nul',
	'chunksize' and 'limit' to inner scope.  Update comments.
checkpoint: print index of new checkpoint in response message

This way the user can know the index of the latest checkpoint without
having to run "info checkpoints" afterwards.

gdb/ChangeLog:

	* linux-fork.c (checkpoint_command): Print index of new
	checkpoint in response message.
Fix the processing of Meta-key commands in TUI

This patch fixes the annoying bug where key sequences such as Alt_F or
Alt_B (go forward or backwards by a word) do not behave promptly in TUI.
You have to press a third key in order for the key sequence to register.

This is mostly ncurses' fault.  Calling wgetch() normally causes ncurses
to read only a single key from stdin.  However if the key read is the
start-sequence key (^[ a.k.a. ESC) then wgetch() reads TWO keys from
stdin, storing the 2nd key into an internal FIFO buffer and returning
the start-sequence key.  The extraneous read of the 2nd key makes us
miss its corresponding stdin event, so the event loop blocks until a
third key is pressed.  This explains why such key sequences do not
behave promptly in TUI.

To fix this issue, we must somehow compensate for the missed stdin event
corresponding to the 2nd byte of a key sequence.  This patch achieves
this by hacking  up the stdin event handler to conditionally execute the
readline callback multiple times in a row.  This is done via a new
global variable, call_stdin_event_handler_again_p, which is set from
tui_getc() when we receive a start-sequence key and notice extra pending
input in the ncurses buffer.

Tested on x86_64-unknown-linux-gnu.

gdb/ChangeLog:

	* event-top.h (call_stdin_event_handler_again_p): Declare.
	* event-top.c (call_stdin_event_handler_again_p): Define.
	(stdin_event_handler): Use it.
	* tui/tui-io.c (tui_getc): Prepare to call the stdin event
	handler again if there is pending input following a
	start sequence.
Specify SA_RESTART when registering the SIGWINCH signal handler

SA_RESTART allows system calls to be restarted across a signal handler.
By specifying this flag we fix the issue where if the user is being
prompted to answer yes or no, and the terminal gets resized in the
meantime, the prompt will think that the user sent an EOF and so it will
take the default action for that prompt (in the case of the quit prompt,
it will quit GDB).

gdb/ChangeLog:

	* tui/tui-win.c (tui_initialize_win): Specify SA_RESTART when
	registering the signal handler.
Always consider infcall breakpoints as non-permanent.

A recent change...

    commit 1a853c5224e2b8fedfac6d029365522b83080b40
    Date:   Wed Nov 12 10:10:49 2014 +0000
    Subject: make "permanent breakpoints" per location and disableable

... broke function calls on sparc-elf when running over QEMU. Any
function call should demonstrate the problem.

For instance, seen from the debugger:

    (gdb) call pn(1234)
    [Inferior 1 (Remote target) exited normally]
    The program being debugged exited while in a function called from GDB.
    Evaluation of the expression containing the function

And seen from QEMU:

    qemu: fatal: Trap 0x02 while interrupts disabled, Error state
    [register dump removed]

What happens in this case is that GDB sets the inferior function call
by not only creating the dummy frame, but also writing a breakpoint
instruction at the return address for our function call. See infcall.c:

        /* Write a legitimate instruction at the point where the infcall
           breakpoint is going to be inserted.  While this instruction
           is never going to be executed, a user investigating the
           memory from GDB would see this instruction instead of random
           uninitialized bytes.  We chose the breakpoint instruction
           as it may look as the most logical one to the user and also
           valgrind 3.7.0 needs it for proper vgdb inferior calls.

           If software breakpoints are unsupported for this target we
           leave the user visible memory content uninitialized.  */

        bp_addr_as_address = bp_addr;
        bp_bytes = gdbarch_breakpoint_from_pc (gdbarch, &bp_addr_as_address,
                                               &bp_size);
        if (bp_bytes != NULL)
          write_memory (bp_addr_as_address, bp_bytes, bp_size);

This instruction triggers a change introduced by the commit above,
where we consider bp locations as being permanent breakpoints
if there is already a breakpoint instruction at that address:

        +  if (bp_loc_is_permanent (loc))
        +    {
        +      loc->inserted = 1;
        +      loc->permanent = 1;
        +    }

As a result, when resuming the program's execution for the inferior
function call, GDB decides that it does not need to insert a breakpoint
at this address, expecting the target to just report a SIGTRAP when
trying to execute that instruction.

But unfortunately for us, at least some versions of QEMU for SPARC
just terminate the execution entirely instead of reporting a breakpoint,
thus producing the behavior reported here.

Although it appears like QEMU might be misbehaving and should therefore
be fixed (to be verified) from the user's point of view, the recent
change does introduce a regression. So this patch tries to mitigate
a bit the damage by handling such infcall breakpoints as special and
making sure that they are never considered permanent, thus restoring
the previous behavior specifically for those breakpoints.

The option of not writing the breakpoint instructions in the first
place was considered, and would probably work also. But the comment
associated to it seems to indicate that there is still reason to
keep it.

gdb/ChangeLog:

        * breakpoint.c (bp_loc_is_permanent): Return 0 if LOC corresponds
        to a bp_call_dummy breakpoint type.

Tested on x86_64-linux. Also testing on sparc-elf/QEMU using
AdaCore's testsuite.
Assert size of elf_x86_64_{bnd|legacy}_plt2_entry

Assert size of elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry
only in elf_x86_64_check_relocs.

	* elf64-x86-64.c (elf_x86_64_check_relocs): Assert size of
	elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry.
	(elf_x86_64_allocate_dynrelocs): Don't assert size of
	elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry.
Add myself as write-after-approval GDB maintainer

gdb/ChangeLog:
	* MAINTAINERS (Write After Approval): Add myself.
Automatic date update in version.in
PowerPC64 --plt-align

Alignment of plt stubs was broken, firstly because the option was
being dropped due to the alignment value not being set in the "params"
struct used in elf64-ppc.c, and secondly due to not calculating the
number of alignment boundary crossings correctly.

bfd/
	* elf64-ppc.c (plt_stub_pad): Correct.
ld/
	* ld.texinfo: Correct --plt-align documentation.
	* emultempl/ppc64elf.em (plt_stub_align): Delete.  Use and set
	params.plt_stub_align instead.
Fix dumping of function arguments.

gdb/ChangeLog:

	* gdbtypes.c (print_args): Renamed from print_arg_types.  Print arg
	number and name if present.  All callers updated.
	(dump_fn_fieldlists): Fix indentation of args.
[Hurd] Fix deallocation after proc_getprocinfo call

2014-11-24  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of
	elements pi_len by the size of the elements before calling
	vm_deallocate.
	(inf_validate_task_sc): Likewise, and properly deallocate the
	noise array.
[AArch64] Cortex-A53 Erratum 835769 -- sort maps

2014-11-24  Tejas Belagod  <tejas.belagod@arm.com>

  bfd/
    * elfnn-aarch64.c (elf_aarch64_compare_mapping): New.
    (erratum_835769_scan): Sort map list.
Reindent code (resolve_dynamic_type_internal).

gdb/ChangeLog
2014-11-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdbtypes.c (resolve_dynamic_type_internal): Reindent the code.