Fix problem with optimization of .eh_frame section and --sort-section option.

When --sort-section=name is used, gold will sort the linker-generated contents
of .eh_frame (after optimization) after the endcap provided by crtendS.o.
This causes two problems: the .eh_frame_hdr section is generated assuming that
the optimized .eh_frame contents will be placed at the very beginning of the
section, and the endcap no longer appears at the end of the section.

This patch fixes the first problem by adjusting FDE offsets to take into account
the actual starting offset within the output section, and fixes the second
problem by sorting linker-generated (Output_section_data) sections based on the
name of the output section.

gold/
	PR gold/17005
	* ehframe.cc (Fde::write): Add output_offset parameter.
	(Cie::write): Likewise.
	(Eh_frame::set_final_data_size): Account for offset within output
	section.
	(Eh_frame::do_sized_write): Likewise.
	* ehframe.h (Fde::write): Add output_offset parameter.
	(Cie::write): Likewise.
	* output.cc (Output_section::Input_section_sort_entry): Remove
	section_has_name_; add output_section_name parameter. Use
	output section name for non-input sections.
	(Output_section::Input_section_sort_entry::section_has_name): Remove.
	(Output_section::Input_section_sort_entry::section_has_name_): Remove.
	(Output_section::Input_section_sort_compare): Remove logic for
	sections without names.
	(Output_section::Input_section_sort_init_fini_compare): Likewise.
	(Output_section::Input_section_sort_section_prefix_special_ordering_compare):
	Likewise.
	(Output_section::Input_section_sort_section_name_compare): Likewise.
Make Elf_file::section_name() a const function, so that it can be used in
places where we have only a const Elf_file*.

elfcpp/
	* elfcpp_file.h (Elf_file::shnum): New const function.
	(Elf_file::shstrndx): New const function.
	(Elf_file::large_shndx_offset): New const function.
	(Elf_file::section_name): Add const attribute.
	(Elf_file::section_header_offset): Likewise.

gold/
	* dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute.
	* dynobj.h (Sized_dynobj::do_section_name): Likewise.
	* incremental.cc (Sized_relobj_incr::do_section_name): Likewise.
	(Sized_incr_dynobj::do_section_name): Likewise.
	* incremental.h (Sized_relobj_incr::do_section_name): Likewise.
	(Sized_incr_dynobj::do_section_name): Likewise.
	* object.h (Object::section_name): Likewise.
	(Object::do_section_name): Likewise.
	(Sized_relobj_file::do_section_name): Likewise.
	* plugin.cc (Sized_pluginobj::do_section_name): Likewise.
	* plugin.h (Sized_pluginobj::do_section_name): Likewise.
typeprint.c (find_global_typedef): Fix comment.

gdb/ChangeLog:

	* typeprint.c (find_global_typedef): Fix comment.
daily update
Fix dwarf2loc.h::dwarf2_evaluate_property function description.

gdb/ChangeLog:

        * dwarf2loc.h (dwarf2_evaluate_property): Minor function
        description fix.
x86 debug address register clarifications

The loop macro ALL_DEBUG_REGISTERS does not iterate over the status or
control registers, so its name is misleading.  This commit renames it
as ALL_DEBUG_ADDRESS_REGISTERS and updates all uses.  This commit also
updates its loop conditions to an equivalent but better form, and
makes two functions use it that had previously hardwired the loop.
A comment on a related field in the x86_debug_reg_state structure is
also updated to reflect that the field refers specifically to address
registers only.

gdb/ChangeLog:

	* nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as...
	(ALL_DEBUG_ADDRESS_REGISTERS): New macro.  All uses updated.
	Loop conditions	changed to equivalent form.
	(struct x86_debug_reg_state): Updated dr_ref_count comment.
	* x86-linux-nat.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.
Introduce show_debug_regs

This commit adds a new global flag show_debug_regs to common-debug.h
to replace the flag debug_hw_points used by gdbserver and by the
Linux x86 and AArch64 ports, and to replace the flag maint_show_dr
used by the Linux MIPS port.

gdb/ChangeLog:

	* common/common-debug.h (show_debug_regs): Declare.
	* common/common-debug.c (show_debug_regs): Define.
	* aarch64-linux-nat.c (debug_hw_points): Don't define.  Replace
	all uses with show_debug_regs.  Replace all uses that considered
	debug_hw_points as a multi-value integer with straight boolean
	uses.
	* x86-nat.c (debug_hw_points): Don't define.  Replace all uses
	with show_debug_regs.
	* nat/x86-dregs.c (debug_hw_points): Don't declare.  Replace
	all uses with show_debug_regs.
	* mips-linux-nat.c (maint_show_dr): Don't define.  Replace all
	uses with show_debug_regs.

gdb/gdbserver/ChangeLog:

	* server.h (debug_hw_points): Don't declare.
	* server.c (debug_hw_points): Don't define.  Replace all uses
	with show_debug_regs.
	* linux-aarch64-low.c (debug_hw_points): Don't define.  Replace
	all uses with show_debug_regs.
Introduce target/target.h

This introduces target/target.h.  This file declares some functions
that the shared code can use and that clients must implement.  It also
changes some shared code to use these functions.

gdb/ChangeLog:

	* target/target.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add target/target.h.
	* target.h: Include target/target.h.
	(target_read_memory, target_write_memory): Don't declare.
	* target.c (target_read_uint32): New function.
	* common/agent.c: Include target/target.h.
	[!GDBSERVER]: Don't include target.h.
	(helper_thread_id): Type changed to uint32_t.
	(agent_get_helper_thread_id): Use target_read_uint32.
	(agent_run_command): Always use target_read_memory and
	target_write_memory.
	(agent_capability): Type changed to uint32_t.
	(agent_capability_check): Use target_read_uint32.

gdb/gdbserver/ChangeLog:

	* target.h: Include target/target.h.
	* target.c (target_read_memory, target_read_uint32)
	(target_write_memory): New functions.
Introduce target_{stop,continue}_ptid

This commit introduces two new functions to stop and restart target
processes that shared code can use and that clients must implement.
It also changes some shared code to use these functions.

gdb/ChangeLog:

	* target/target.h (target_stop_ptid, target_continue_ptid):
	Declare.
	* target.c (target_stop_ptid, target_continue_ptid): New
	functions.
	* common/agent.c [!GDBSERVER]: Don't include infrun.h.
	(agent_run_command): Always use target_stop_ptid and
	target_continue_ptid.

gdb/gdbserver/ChangeLog:

	* target.c (target_stop_ptid, target_continue_ptid): New
	functions.
Introduce target/symbol.h

This introduces target/symbol.h.  This file declares a function that
the shared code can use and that the clients must implement.  It also
changes some shared code to use these functions.

gdb/ChangeLog:

	* target/symbol.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add target/symbol.h.
	* target.h: Include target/symbol.h.
	* minsyms.c (find_minimal_symbol_address): New function.
	* common/agent.c: Include target/symbol.h.
	[!GDBSERVER]: Don't include objfiles.h.
	(agent_look_up_symbols): Use find_minimal_symbol_address.

gdb/gdbserver/ChangeLog:

	* symbol.c: New file.
	* Makefile.in (SFILES): Add symbol.c.
	(OBS): Add symbol.o.
Introduce common-regcache.h

This introduces common-regcache.h.  This contains two functions that
allow nat/linux-btrace.c to be simplified.  A better long term
solution would be unify the regcache code, but this is sufficient for
now.

gdb/ChangeLog:

	* common/common-regcache.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-regcache.h.
	* regcache.h: Include common-regcache.h.
	(regcache_read_pc): Don't declare.
	* regcache.c (get_thread_regcache_for_ptid): New function.
	* nat/linux-btrace.c: Don't include regcache.h.
	Include common-regcache.h.
	(perf_event_read_bts): Use get_thread_regcache_for_ptid.

gdb/gdbserver/ChangeLog:

	* regcache.h: Include common-regcache.h.
	(regcache_read_pc): Don't declare.
	* regcache.c (get_thread_regcache_for_ptid): New function.
Include common-defs.h instead of defs.h/server.h in shared code

This commit makes 19 of the 22 shared .c files in common, nat and
target include common-defs.h instead of defs.h/server.h.  The
remaining three files need slight extra work and are dealt with
in separate commits.

gdb/ChangeLog:

	* common/agent.c: Include common-defs.h.
	Don't include defs.h or server.h.
	* common/buffer.c: Likewise.
	* common/common-debug.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/errors.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/format.c: Likewise.
	* common/gdb_vecs.c: Likewise.
	* common/print-utils.c: Likewise.
	* common/ptid.c: Likewise.
	* common/rsp-low.c: Likewise.
	* common/signals.c: Likewise.
	* common/vec.c: Likewise.
	* common/xml-utils.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* target/waitstatus.c: Likewise.
Remove GDBSERVER uses from linux-btrace.c

This commit makes nat/linux-btrace.c include common-defs.h rather
than defs.h or server.h.  A couple of minor changes were required
to support this change.

gdb/ChangeLog:

	* nat/linux-btrace.c: Include common-defs.h.
	Don't include defs.h, server.h or gdbthread.h.
	* nat/linux-btrace.h (struct target_ops): New forward declaration.
Remove GDBSERVER uses from x86-dregs.c

This commit makes nat/x86-dregs.c include common-defs.h rather than
defs.h or server.h.  An extra header required including in order to
support this change.

gdb/ChangeLog:

	* nat/x86-dregs.c: Include common-defs.h and break-common.h.
	Don't include defs.h or server.h.
Remove one GDBSERVER use from linux-waitpid.c

This commit makes nat/linux-waitpid.c include common-defs.h rather
than defs.h or server.h.  Some debug code previously only built for
gdbserver is now also built for GDB, and a use of GDBSERVER has had
to remain in order to select the variable used to determine whether
debug printing should be enabled.

gdb/ChangeLog:

	* linux-nat.c (debug_linux_nat): Make nonstatic.
	* nat/linux-waitpid.c: Include common-defs.h.
	Don't include defs.h, server.h or signal.h.
	(debug_linux_waitpid): New macro and extern.
	(linux_debug): Use debug_linux_waitpid and debug_vprintf.
New (empty) files
Introduce current_inferior_ptid
Use current_inferior_ptid
Minor tweak to make GDB's x86_linux_prepare_to_resume closer to gdbservers
Introduce and use x86_debug_reg_state in gdbserver