daily update
Fix ALIGN_WITH_INPUT

ld/

2014-02-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* ld/ld.texinfo: Change ALIGN_WITH_INPUT documentation.
	* ld/ldlang.c (lang_size_sections_1): Add dotdelta
	variable which reflects the VMA change due to alignment
	requirements.  Use dotdelta do change the LMA if
	ALIGN_WITH_INPUT is requested.

ld/testsuite/ChangeLog

2014-02-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* ld-scripts/rgn-at9.d: New file.
	* ld-scripts/rgn-at9.t: Likewise.
	* ld-scripts/rgn-at10.d: Likewise.
	* ld-scripts/rgn-at10.s: Likewise.
	* ld-scripts/rgn-at10.t: Likewise.
	* ld-scripts/rgn-at11.d: Likewise.
	* ld-scripts/rgn-at11.t: Likewise.
Correct Nios II GOT pointer initialization.

2014-02-02  Sandra Loosemore  <sandra@codesourcery.com>

	bfd/
	* elf32-nios2.c (struct elf32_nios2_link_hash_table): Add
	h_gp_got field.
	(nios2_elf32_relocate_section): Use got_base to adjust
	GOT-pointer-relative relocations relative to _gp_got.
	(create_got_section): Create _gp_got symbol.
	(nios2_elf32_finish_dynamic_symbol): Make _gp_got absolute.
	(nios2_elf32_size_dynamic_sections): Set _gp_got offset.
daily update
ppc476 icache bug workaround

This implements a work-around for an icache bug on 476 that can cause
execution of stale instructions when control falls through from one
page to the next.  The idea is to prevent such fall-through by
replacing the last instruction on a page with a branch to a patch
area containing the instruction, then branch to the next page.

The patch also fixes a number of bugs in the existing support for long
branch trampolines.

bfd/
	* elf32-ppc.c (struct ppc_elf_link_hash_table): Add params.
	Delete emit_stub_syms, no_tls_get_addr_opt.  Update all uses.
	(ppc_elf_link_params): New function.
	(ppc_elf_create_glink): Align .glink to 64 bytes for ppc476
	workaround.
	(ppc_elf_select_plt_layout): Remove plt_style and emit_stub_syms
	parameters.  Use htab->params instead.
	(ppc_elf_tls_setup): Remove no_tls_get_addr_opt parameter.
	(ppc_elf_size_dynamic_sections): Align __glink_PLTresolve to
	64 bytes for ppc476 workaround.
	(struct ppc_elf_relax_info): New.
	(ppc_elf_relax_section): Exclude linker created sections and
	those too small to hold one instruction.  Don't add another
	branch 	around trampolines on later relax passes.  Don't
	generate trampolines for undefined symbols when !relocatable,
	nor for plugin symbols.  Allocate space for ppc476 workaround
	patch area.  Free fixups on error return path.
	(ppc_elf_relocate_section): Handle ppc476 workaround patching.
	* elf32-ppc.h (struct ppc_elf_params): New.
	(ppc_elf_select_plt_layout, ppc_elf_tls_setup): Update prototype.
	(ppc_elf_link_params): Declare.
	* section.c (SEC_INFO_TYPE_TARGET): Define.
	* bfd-in2.h: Regenerate.
ld/
	* emultempl/ppc32elf.em (no_tls_get_addr_opt, emit_stub_syms)
	plt_style): Delete.  Adjust all refs to instead use..
	(params): ..this.  New variable.
	(ppc_after_open_output): New function.  Tweak params and pass to
	ppc_elf_link_params.
	(ppc_after_open): Adjust ppc_elf_select_plt_layout call.
	(ppc_before_allocation): Adjust ppc_elf_tls_setup call.  Enable
	relaxation for ppc476 workaround.
	(PARSE_AND_LIST_*): Add --{no-,}ppc476-workaround support.
	(LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): Define.
Fix build on OpenBSD/sparc64.

gdb/ChangeLog:

        * sparc64nbsd-nat.c (sparc64nbsd_supply_fpregset): Fix prototype.
Fix build on recent versions of OpenBSD.

gdb/ChangeLog:

        * bsd-kvm.c: Include <sys/param.h>
Nios II large-GOT relocations

2014-02-03  Sandra Loosemore  <sandra@codesourcery.com>

	include/elf/
	* nios2.h (R_NIOS2_GOT_LO, R_NIOS2_GOT_HA): New.
	(R_NIOS2_CALL_LO, R_NIOS2_CALL_HA): New.
	(R_NIOS2_ILLEGAL): Adjust.

	gas/
	* config/tc-nios2.c (md_apply_fix): Test for new relocs.
	(nios2_special_reloc): Add %call_lo, %call_hiadj, %got_lo,
	%got_hiadj relocation operators.  Sort table and add comment
	to explain ordering.
	(nios2_fix_adjustable): Test for new relocs.
	* doc/c-nios2.texi (Nios II Relocations): Document new relocation
	operators.

	bfd/
	* reloc.c (BFD_RELOC_NIOS2_GOT_LO, BFD_RELOC_NIOS2_GOT_HA): New.
	(BFD_RELOC_NIOS2_CALL_LO, BFD_RELOC_NIOS2_CALL_HA): New.
	* libbfd.h: Regenerated.
	* bfd-in2.h: Regenerated.
	* elf32-nios2.c (elf_nios2_howto_table_rel): Add new relocations.
	(nios2_reloc_map): Likewise.
	(GOT_USED, CALL_USED): Renamed from GOT16_USED and CALL16_USED.
	Fixed all references.
	(nios2_elf32_relocate_section): Add new relocations.
	(nios2_elf32_check_relocs): Likewise.
	(nios2_elf32_gc_sweep_hook): Likewise.
daily update
Update mn10300 dwarf register map

This change updates the mn10300 dwarf register map.  It reduces the
failure count when doing simulator testing against the default
multilib from 788 to 99.

gdb/ChangeLog:

	* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Rewrite
	dwarf2_to_gdb[] table using symbolic constants.  Adjust
	penultimate entry from number representing the PC register
	to symbolic constant representing the MDR register.  Add
	constant for the PC register to the end of the table.
Add support for ELF core files on OpenBSD/sparc64.

gdb/ChangeLog:

        * sparc64obsd-tdep.c (sparc64obsd_gregset): New variable.
        (sparc64obsd_supply_gregset): Handle registers sets used in ELF
        core dumps.
        (sparc64obsd_init_abi): Adjust minimum size of the general purpose
        register set used in ELF core dumps.  Add floating-point register set.
Document support for powerpc64le-*-linux* target

gdb/ChangeLog:

	* NEWS: Document new target powerpc64le-*-linux*.
Refactor ppc64 function call and return value handling

This patch refactors the ppc64 function call and return value handling code
in ppc-sysv-tdep.c.  The main problem to be addressed by this refactoring
is the code duplication caused by certain aggregate types:

According to the ABI, some types are to be decomposed into component types
for parameter and return value handling.  For example, complex types are
to be passed as if the real and imaginary component were separate arguments.
Similarly, certain OpenCL vector types are passed as if they were multiple
separate arguments of the vector element type.  With the new ELFv2 ABI,
there is another case: "homogeneous aggregates" (e.g. a struct containing
4 floats) are passed in multiple floating point registers as well.

Unfortunately, the current code is not structured to easily model these
ABI properties.  For example, code to pass complex values re-implements
code to pass the underlying (floating-point) type.  This has already
led to some unfortunate code duplication, and with the addition of
ELFv2 ABI support, I would have had to add yet more such duplication.

To avoid that, I've decided to refactor the code in order to re-use
subroutines that handle the "base" types when handling those aggregate
types.  This was not intended to cause any difference on current
(ELFv1) ABI code, but in fact it fixes a bug:

FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3, fc4)

This was caused by the old code in ppc64_sysv_abi_push_float incorrectly
handling floating-point arguments to vararg routines, which just happens
to work out correctly automatically in the refactored code ...

gdb/ChangeLog:

	* ppc-sysv-tdep.c (get_decimal_float_return_value): Update comment.
	(struct ppc64_sysv_argpos): New data structure.
	(ppc64_sysv_abi_push_float): Remove.
	(ppc64_sysv_abi_push_val): New function.
	(ppc64_sysv_abi_push_integer): Likewise.
	(ppc64_sysv_abi_push_freg): Likewise.
	(ppc64_sysv_abi_push_vreg): Likewise.
	(ppc64_sysv_abi_push_param): Likewise.
	(ppc64_sysv_abi_push_dummy_call): Refactor to use those new routines.
	(ppc64_sysv_abi_return_value_base): New function.
	(ppc64_sysv_abi_return_value): Refactor to use it.
PowerPC64 little-endian fixes: structure passing

When passing a small structure in a GPR, the ABI specifies that it
should be passed in the least-significant bytes of the register
(or stack slot).  On big-endian systems, this means the value
needs to be stored at an offset, which is what current code does.

However, on little-endian systems, the least-significant bytes are
addresses with offset 0.  This patch fixes that.

gdb/ChangeLog:

	* ppc-sysv-tdep.c (ppc64_sysv_abi_push_val): Use correct
	offset on little-endian when passing small structures.
PowerPC64 little-endian fixes: AltiVec tests

A couple of AltiVec tests fail spuriously on powerpc64le-linux, because
they compare against an incorrect pattern.  Note that those tests already
contain little-endian variants of the patterns, but those seem to have
bit-rotted a bit: when outputting a vector, GDB no longer omits trailing
zero elements (as it used to do in the past).

This patch updates the pattern to the new GDB output behavior.

In addition, the patch updates the endian test to use the new
gdb_test_multiple logic instead of gdb_expect.

gdb/testsuite/ChangeLog:

	* gdb.arch/altivec-regs.exp: Use gdb_test_multiple for endian test.
	(decimal_vector): Fix for little-endian.
PowerPC64 little-endian fixes: VSX tests and pseudo-regs

Many VSX test were failing on powerpc64le-linux, since -as opposed to the
AltiVec tests- there never were little-endian versions of the test patterns.

This patch adds such patterns, along the lines of altivec-regs.exp.

In addition, there is an actual code change required: For those VSX
registers that overlap a floating-point register, the FP register
overlaps the most-significant half of the VSX register both on big-
and little-endian systems.  However, on little-endian systems, that
half is stored at an offset of 8 bytes (not 0).  This works already
for the "real" FP registers, but current code gets it wrong for
the "extended" pseudo FP register GDB generates for the second
half of the VSX register bank.

This patch updates the corresponding pseudo read/write routines
to take the appropriate offset into consideration.

gdb/ChangeLog:

	* rs6000-tdep.c (efpr_pseudo_register_read): Use correct offset
	of the overlapped FP register within the VSX register on little-
	endian platforms.
	(efpr_pseudo_register_write): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.arch/vsx-regs.exp: Check target endianness.  Provide variants
	of the test patterns for use on little-endian systems.
PowerPC64 little-endian fixes: 32-bit DFP parameters

Passing a 32-bit DFP in register needs to use the least-significant part
of the register.  Like with a previous patch that addressed the same
issue for small structs, this patch makes sure the appropriate offset
is used on little-endian systems.

gdb/ChangeLog:

	* ppc-sysv-tdep.c (ppc64_sysv_abi_push_freg): Use correct
	offset on little-endian when passing _Decimal32.
	(ppc64_sysv_abi_return_value_base): Likewise for return values.
PowerPC64 little-endian fixes: 128-bit DFP parameters / registers

The powerpc64le-linux ABI specifies that when a 128-bit DFP value is
passed in a pair of floating-point registers, the first register holds
the most-significant part of the value.  This is as opposed to the
usual rule on little-endian systems, where the first register would
hold the least-significant part.

This affects two places in GDB, the read/write routines for the
128-bit DFP pseudo-registers, and the function call / return
sequence.  For the former, current code already distinguishes
between big- and little-endian targets, but gets the latter
wrong.  This is presumably because *GCC* also got it wrong,
and GDB matches the old GCC behavior.  But GCC is now fixed:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02145.html
so GDB needs to be fixed too.  (Old code shouldn't really be
an issue since there is no code "out there" so far that uses
dfp128 on little-endian ...)

gdb/ChangeLog:

	* ppc-sysv-tdep.c (ppc64_sysv_abi_push_freg): Use correct order
	within a register pair holding a DFP 128-bit value on little-endian.
	(ppc64_sysv_abi_return_value_base): Likewise.
	* rs6000-tdep.c (dfp_pseudo_register_read): Likewise.
	(dfp_pseudo_register_write): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.arch/powerpc-d128-regs.exp: Enable on powerpc64*-*.
PowerPC64 ELFv2 ABI: base support

This is the first patch of a series to implement support for the
PowerPC ELFv2 ABI.  While powerpc64le-linux will use ELFv2, and
the existing powerpc64-linux code will continue to use ELFv1,
in theory ELFv2 is also defined for big-endian systems (and
ELFv1 was also defined for little-endian systems).

Therefore this patch adds a new tdep->elf_abi variable to decide
which ABI version to use.  This is detected from the ELF header
e_flags value; if this is not present, we default to ELFv2 on
little-endian and ELFv1 otherwise.

This patch does not yet introduce any actual difference in GDB's
handling of the two ABIs.  Those will be added by the remainder
of this patch series.

For an overview of the changes in ELFv2, have a look at the
comments in the patch series that added ELFv2 to GCC, starting at:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01144.html

gdb/ChangeLog:

	* ppc-tdep.h (enum powerpc_elf_abi): New data type.
	(struct gdbarch_tdep): New member elf_abi.

	* rs6000-tdep.c: Include "elf/ppc64.h".
	(rs6000_gdbarch_init): Detect ELF ABI version.
PowerPC64 ELFv2 ABI: no function descriptors

This implements the most significant difference with the ELFv2 ABI:
we no longer use function descriptors.  The patch consists mostly
of switching off code to deal with descriptors :-)

In addition, when calling an inferior function, we no longer need
to provide its TOC in r2.  Instead, ELFv2 code expects to be called
with r12 pointing to the code address itself.

gdb/ChangeLog:

	* ppc-linux-tdep.c (ppc_linux_init_abi): Only call
	set_gdbarch_convert_from_func_ptr_addr and
	set_gdbarch_elf_make_msymbol_special for ELFv1.
	* ppc-sysv-tdep.c (ppc64_sysv_abi_push_param): Only handle
	function descriptors on ELFv1.
	(ppc64_sysv_abi_push_dummy_call): Likewise.  On ELFv2,
	set up r12 at function entry.