PR 17287, DT_NEEDED of unneeded libraries affects --as-needed

	PR 17287
bfd/
	* elflink.c (on_needed_list): Only consider libraries that have
	been loaded.
ld/
	* ld.texinfo (--as-needed): Clarify that references from libraries
	must be from needed libraries.
ld/testsuite/
	* ld-plugin/needed3.c: New file.
	* ld-elf/shared.exp: Add needed3 test.
PowerPC fix for ifunc broken by d1eca1e4

This probably could be fixed by making changes in relocate_section for
ifunc, but it's simpler to disable the optimisation for ifunc.

	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Don't attempt to
	use dynrelocs for ifunc.
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Similarly.
LTO plugin with older gcc

	* ld-plugin/lto.exp: Use gcc -print-file-name to find lto plugin.
Fix indentation level in ada-lang.c::ada_evaluate_subexp.

I just happen to notice that a lexical block was missing one
indentation level.

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Fix identation
        of lexical block.
avoid "if ... else if ... else" logic in ada-lang.c::ada_evaluate_subexp

The OP_VAR_VALUE branch in ada_evaluate_subexp is written with
multiple "if ... else if ... else if ... else ..." block. But
in practice, these blocks  all either goto out of that block of
code, or return.

This patch rewrites this code slightly by replacing the "else if"-s
by simple "if"s. This should better reflect the ideal processing
where we try to do a standard eval whenever possible, and only
do something else when the standard eval does not work. On a pratical
level, this patch makes it easier to fall through to the default
processing when none of the special situations are detected, thus
making it easier to add more handlers of those special situations;
or to remove them as they no longer become necessary!

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Slight code
        rewrite to avoid "else if" and "else" constructs.  Should be
        a no-op in practice.
ada_evaluate_subexp<OP_VAR_VALUE>: Avoid static fixing when possible.

Now that the OP_VAR_VALUE section of this function has been reorganized
a bit, we can fall-back on standard evaluation when static fixing is
not required. This patch does that, but being exclusive about when
static fixing has to be used, rather than doing it all the time when
noside is EVAL_AVOID_SIDE_EFFECTS.

This will pave the way for later when we want to evaluate entities
that have no GNAT encodings related to them but dynamic properties
instead. In that case, we expect the standard evaluation to resolve
those dynamic properties for us, even in no-side-effect mode.

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>:
        When noside is EVAL_AVOID_SIDE_EFFECTS, only return a statically
        fixed value for records and unions for which some GNAT encodings
        are present.
Add support for DW_OP_push_object_address.

gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs): Uncomment
        field "get_object_address".
        * dwarf2expr.c (execute_stack_op): Add handling for
        DW_OP_push_object_address.
        * dwarf2loc.h (dwarf2_evaluate_property): Add "address" field.
        * dwarf2loc.c (struct dwarf_expr_baton): Add field "obj_address".
        (dwarf_expr_push_dwarf_reg_entry_value): Set baton_local.obj_address.
        (dwarf_expr_get_obj_addr): New function.
        (dwarf_expr_ctx_funcs): Add get_object_address field.
        (dwarf2_evaluate_loc_desc_full): Set baton.obj_address.
        (dwarf2_locexpr_baton_eval): Add parameter "addr".  Use it.
        (dwarf2_evaluate_property): Add parameter "address".  Use it.
        (needs_get_obj_addr): New function.
        (needs_frame_ctx_funcs): Add get_object_address field.
        (dwarf2_compile_expr_to_ax): Add DW_OP_push_object_address handling.
        * gdbtypes.c (resolve_dynamic_range): Add "addr" field.  Use it.
        (resolve_dynamic_array): Likewise.
Add support for DW_AT_data_location.

gdb/ChangeLog:

        * gdbtypes.h (struct main_type): Add field "data_location".
        (TYPE_DATA_LOCATION, TYPE_DATA_LOCATION_BATON)
        (TYPE_DATA_LOCATION_ADDR, TYPE_DATA_LOCATION_KIND): New macros.
        * gdbtypes.c (is_dynamic_type): Return 1 if the type has
        a dynamic data location.
        (resolve_dynamic_type): Add DW_AT_data_location handling.
        (copy_recursive, copy_type): Copy the data_location information
        when present.
        * dwarf2read.c (set_die_type): Add DW_AT_data_location handling.
        * value.c (value_from_contents_and_address): Add
        DW_AT_data_location handling.
[Ada] "ptype" of array where bound value uses DW_OP_push_object_address

Consider an Ada array type where the DWARF debugging info for
at least one of the bounds involves an expression containing
a DW_OP_push_object_address operation. Trying to "ptype" that
type currently yields:

    (gdb) ptype foo.array_type
    type = array (Location address is not set.

This patch improves ada-typeprint by adding handling of the situation
where an array range type has dynamic bounds.  In that case, it prints
the array bounds using Ada's typical syntax for unbounded ranges "<>":

    (gdb) ptype array_type
    type = array (<>) of integer

gdb/ChangeLog:

        * ada-typeprint.c (type_is_full_subrange_of_target_type):
        Return 0 if TYPE is dynamic.
        (print_range): Add handling of dynamic ranges.
DW_AT_data_location and DW_OP_push_object_address testcase.

This testcase allows us to test the proper processing of both
DW_AT_data_location and DW_OP_push_object_address using a hand-crafted
testcase duplicating how we expect the Ada compiler to represent
unbounded arrays.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/data-loc.c, gdb.dwarf2/data-loc.exp: New files.
This fixes the processing of BFD_RELOC_RL78_DIFF fixups when the size is less
than 4.  This affects DWARF debug info generation in particular.

	* config/tc-rl78.c (md_apply_fix): Correct handling of small sized
	RELOC_RL78_DIFF fixups.
ada-typeprint.c (print_range): Initialize lo,hi for gcc -Wall.

	* ada-typeprint.c (print_range): Initialize lo,hi for gcc -Wall.
gdb.dwarf2/data-loc.exp: Remove second DW_AT_upper bound in array range.

The testcase generates an assembly file where a second DW_AT_upper_bound
attribute gets generated in the array range.  This was definitely
unintentional, and I only noticed this after pushing the testcase,
when dumping one more time the DWARF data using readelf.

This patch fixes it.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/data-loc.exp: Remove second DW_AT_upper bound
        attribute in array range.
boards/fission.exp: Explicitly pass -ggnu-pubnames for clang.

	* boards/fission.exp: Explicitly pass -ggnu-pubnames for clang.
daily update
Ensure internal_vproblem always prints the message

While working on internal_vproblem I noticed that the error/warning
message is suppressed if problem->should_quit is internal_problem_yes
or internal_problem_no.  This behaviour seems wrong.  This commit
modifies internal_vproblem to emit the message regardless of the
user's settings.

gdb/
2014-08-19  Gary Benson  <gbenson@redhat.com>

	* utils.c (internal_vproblem): Always print the message.
Introduce common/errors.h

This introduces common/errors.h.  This holds some error- and warning-
related declarations that can be used by the code in common, nat and
target.  Some of the declared functions must be provided by the client
as documented by the header file comments.

gdb/ChangeLog:

	* common/errors.h: New file.
	* common/errors.c: Likewise.
	* Makefile.in (SFILES): Add common/errors.c.
	(HFILES_NO_SRCDIR): Add common/errors.h.
	(COMMON_OBS): Add errors.o.
	(errors.o): New rule.
	* common/common-defs.h: Include errors.h.
	* utils.h (perror_with_name, error, verror, warning, vwarning):
	Don't declare.
	* common/common-utils.h: (malloc_failure, internal_error):
	Likewise.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/errors.c.
	(OBS): Add errors.o.
	(IPA_OBS): Add errors-ipa.o.
	(errors.o): New rule.
	(errors-ipa.o): Likewise.
	* utils.h (perror_with_name, error, warning): Don't declare.
	* utils.c (warning): Renamed and rewritten as...
	(vwarning): New function.
	(error): Renamed and rewritten as...
	(verror): New function.
	(internal_error): Renamed and rewritten as...
	(internal_verror): New function.
Introduce common-types.h

This introduces common-types.h.  This file defines various standard
types used by gdb and gdbserver.

Currently these types are conditionally defined based on GDBSERVER.
The long term goal is to remove all such tests; however, this is
difficult as currently gdb uses definitions from BFD.  In the meantime
this is still a step in the right direction.

gdb/ChangeLog:

	* common/common-types.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-types.h.
	* common/common-defs.h: Include common-types.h.
	* defs.h (gdb_byte, CORE_ADDR, CORE_ADDR_MAX, LONGEST)
	(ULONGEST): Remove.

gdb/gdbserver/ChangeLog:

	* server.h: Add static assertion.
	(gdb_byte, CORE_ADDR, LONGEST, ULONGEST): Remove.
Move print-utils.h to common-defs.h

This commit moves the inclusion of print-utils.h to common-defs.h
and removes all other inclusions.

gdb/ChangeLog:

	* common/common-defs.h: Include print-utils.h.
	* utils.h: Do not include print-utils.h.

gdb/gdbserver/ChangeLog:

	* utils.h: Do not include print-utils.h.
Introduce common-debug.h

This introduces common-debug.h.  This holds the functions debug_printf
and debug_vprintf, two functions that the common code can use to print
debugging messages.  Clients of the common code are expected to
implement debug_vprintf; a debug_vprintf function is written from
scratch for GDB, and gdbserver's existing debug_printf is repurposed
as debug_vprintf.

common/agent.c is changed to use debug_vprintf rather than
defining the macro DEBUG_AGENT depending on GDBSERVER.

nat/i386-dregs.c is changed to use the externally-implemented
debug_printf, rather than defining it itself.

gdb/ChangeLog:

	* common/common-debug.h: New file.
	* common/common-debug.c: Likewise.
	* debug.c: Likewise.
	* Makefile.in (SFILES): Add common/common-debug.c.
	(HFILES_NO_SRCDIR): Add common/common-debug.h.
	(COMMON_OBS): Add common-debug.o and debug.o.
	(common-debug.o): New rule.
	* common/common-defs.h: Include common-debug.h.
	* common/agent.c (debug_agent_printf): New function.
	(DEBUG_AGENT): Redefine.
	* nat/i386-dregs.c (debug_printf): Undefine.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/common-debug.c.
	(OBS): Add common-debug.o.
	(common-debug.o): New rule.
	* debug.h (debug_printf): Don't declare.
	* debug.c (debug_printf): Renamed and rewritten as...
	(debug_vprintf): New function.