Commit Graph

88174 Commits

Author SHA1 Message Date
Alan Modra afe002dd66 [GOLD] Add debug output for powerpc section grouping
* debug.h (DEBUG_TARGET): New.
	(DEBUG_ALL): Add DEBUG_TARGET.
	(gold_debug): Delete FORMAT param.
	* powerpc.cc (Stub_control::can_add_to_stub_group): Print debug ourput.
2016-08-31 12:34:36 +09:30
GDB Administrator 6c95c84110 Automatic date update in version.in 2016-08-31 00:00:20 +00:00
Cupertino Miranda 7763838e99 Fixed issue with NULL pointer access on header var.
Variable "header" in function is set conditionally, but was accessed without
verifying if pointer was NULL.

opcodes/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>
	* opcodes/arc-dis.c (print_insn_arc): Changed.
2016-08-30 18:21:13 +02:00
Andreas Arnez 5af962df4d Fix order of inferiors in "thread apply all"
This inserts missing parentheses in the calculation of the comparison
result between two different inferior numbers.  The problem was found by
Philipp Rudo.

gdb/ChangeLog:

	* thread.c (tp_array_compar): Insert missing parentheses.

gdb/testsuite/ChangeLog:

	* gdb.multi/tids.exp: Test "thread apply all".
2016-08-30 17:03:55 +02:00
Cupertino Miranda b2b383620e Made tests to XFAIL for arc*-*-elf*.
ld/ChangeLog:
    Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-arc/tls_gs-01.d: Set to XFAIL on arc*-*-elf*.
	* testsuite/ld-arc/tls_ie-01.d: Likewise.
2016-08-30 16:02:25 +02:00
Nick Clifton c616591359 Partially revert previous delta - move limit testing code to first scan over symbol file.
PR gprof/20499
	* corefile.c (num_of_syms_in): Return an unsigned int.
	Fail if the count exceeds the maximum possible allocatable size.
	(core_create_syms_from): Exit early if num_of_syms_in returns a
	failure code.
2016-08-30 13:51:43 +01:00
Nick Clifton 0092723307 Fix more potential seg-faults in gprof.
PR gprof/20499
	* corefile.c (num_of_syms_in): Return an unsigned int.
	(core_create_syms_from): Catch a possible integer overflow
	computing the argument to xmalloc.  Also allow for the possibility
	that an integer overflow in num_of_syms_in means that less space
	has been allocated than expected.
2016-08-30 13:38:54 +01:00
Alan Modra 8941017bc0 ppc apuinfo for spe parsed incorrectly
apuinfo saying SPE resulted in mach = bfd_mach_ppc_vle due to a
missing break.

	PR 20531
	* elf32-ppc.c (_bfd_elf_ppc_set_arch): Add missing "break".
2016-08-30 21:04:44 +09:30
Alan Modra 57f6d32dea [GOLD] correct grouping of stubs
This patch rewrites the rather obscure can_add_to_stub_group, fixing
a problem with the handling of sections containing conditional
external branches.  When a section group contains any such section,
the group size needs to be limited to a much smaller size than groups
with only non-conditional external branches.

	PR 20523
	* powerpc.cc (class Stub_control): Add has14_.  Comment owner_.
	(Stub_control::can_add_to_stub_group): Correct grouping of
	sections containing 14-bit external branches.  When returning
	false, set state_ to reflect the fact that we have one section
	for the next group.  Rewrite most of function for clarity.
	Add and expand comments.
	(Target_powerpc::do_relax): Print stub group size retry in hex.
2016-08-30 12:20:27 +09:30
GDB Administrator 7229b687db Automatic date update in version.in 2016-08-30 00:00:21 +00:00
H.J. Lu 3c4f32287f Run PR ld/19784 tests only if ifunc attribute works
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/19784 tests only
	if ifunc attribute works.
2016-08-29 09:09:14 -07:00
H.J. Lu f53be9779b Check the external compression header size
Since the internal compression header size can be bigger than the
external compression header size, we should check the external
compression header size.

	* readelf.c (load_specific_debug_section): Check the external
	compression header size.
2016-08-29 08:49:20 -07:00
H.J. Lu 74437ea28f i386: Issue an error on non-PIC call to IFUNC in PIC object
On i386, IFUNC function must be called via PLT.  Since PLT in PIC
object uses EBX register, R_386_PLT32 relocation must be used to
call IFUNC function even when IFUNC function is defined locally.
Linker should issue an error when R_386_PC32 relocation is used
to call IFUNC function.

Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC
function, they are moved to the x86-64 test directory.

bfd/

	PR ld/14961
	PR ld/20515
	* elf32-i386.c (elf_i386_check_relocs): Issue an error when
	R_386_PC32 relocation is used to call IFUNC function in PIC
	object.

ld/

	PR ld/14961
	PR ld/20515
	* testsuite/ld-i386/i386.exp: Run pr20515.
	* testsuite/ld-i386/pr20515.d: New file.
	* testsuite/ld-i386/pr20515.s: Likewise.
	* testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC
	function.
	* testsuite/ld-ifunc/ifunc-14c.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ...
	* testsuite/ld-x86-64/x86-64.exp: Here.
	* testsuite/ld-ifunc/pr19784a.c: Moved to ...
	* testsuite/ld-x86-64/pr19784a.c: Here.
	* testsuite/ld-ifunc/pr19784b.c: Moved to ...
	* testsuite/ld-x86-64/pr19784b.c: Here.
	* testsuite/ld-ifunc/pr19784c.c: Moved to ...
	* testsuite/ld-x86-64/pr19784c.c: Here.
2016-08-29 08:14:45 -07:00
Jan Kratochvil 7fac69100a gdb.base/default.exp regression
tty^M
(gdb) FAIL: gdb.base/default.exp: tty

gdb/testsuite/ChangeLog
2016-08-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/default.exp (tty): Remove.
2016-08-29 15:20:04 +02:00
GDB Administrator 1cc90bb7ed Automatic date update in version.in 2016-08-29 00:00:18 +00:00
Han Shen 6395d38b7f PR gold/20529 - relaxing loop never ends.
gold/ChangeLog

2016-08-26  Han Shen  <shenhan@google.com>

	* powerpc.cc (Stub_table::min_size_threshold_): New member to
	limit size.
	(Stub_table::set_min_size_threshold): New member function.
	(Stub_table::set_address_and_size): Add code to only allow size
	increase.
	(Target_powerpc::do_relax): Add code to record last size.
2016-08-28 14:17:31 -07:00
GDB Administrator 8b2f3453b7 Automatic date update in version.in 2016-08-28 00:00:19 +00:00
Alan Modra 53720c495c Lack of SHF_GROUP sections result in ld segfault
PR 20520
	* elf.c (_bfd_elf_setup_sections): Check that SHT_GROUP sections
	have corresponding SHF_GROUP sections.
	(bfd_elf_set_group_contents): Comment.
2016-08-27 09:44:22 +09:30
Alan Modra 8a9e8e72fe Fix commit 980aa3e6
Commit 980aa3e6 was supposed to cure dyn_reloc counting problems, but
did the opposite.  For PIC we count two types of dyn_reloc, those on
pc-relative relocs, and the total.  If a sym needs pc-relative dyn
relocs then all the relocs are dynamic.  If not, then only those that
are must_be_dyn_reloc are dynamic.

	PR 20519
	* elf64-ppc.c (pc_dynrelocs): New function.
	(ppc64_elf_relocate_section): Use it and must_be_dyn_reloc to
	handle pic dynamic relocs.
2016-08-27 09:42:09 +09:30
GDB Administrator e55c2fc0ef Automatic date update in version.in 2016-08-27 00:00:20 +00:00
Jose E. Marchesi 1b8b65328f opcodes, gas: fix mnemonic of sparc camellia_fl
This patch fixes a typo in the mnemonic of the camellia_fl
instruction, which was implemented before as camellia_fi.

gas/ChangeLog:

2016-08-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/sparc/crypto.d: Rename invalid opcode camellia_fi
	to camellia_fl.
	* testsuite/gas/sparc/crypto.s: Likewise.

opcodes/ChangeLog:

2016-08-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc-opc.c (sparc_opcodes): Fix typo in opcode, camellia_fi ->
	camellia_fl.
2016-08-26 07:31:31 -07:00
Thomas Preud'homme 68c3989217 Reduce parameter list in bfd_elf32_arm_target_relocs
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (struct elf32_arm_params): Define.
	(bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Use a struct
	elf32_arm_params to pass all parameters but the bfd and bfd_link_info.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Pass all values via a struct
	elf32_arm_params rather than as individual parameters.

ld/
	* emultempl/armelf.em (params): New static variable.
	(thumb_entry_symbol, byteswap_code, target1_is_rel, target2_type,
	fix_v4bx, use_blx, vfp11_denorm_fix, stm32l4xx_fix, fix_cortex_a8,
	no_enum_size_warning, no_wchar_size_warning, pic_veneer,
	merge_exidx_entries, fix_arm1176, cmse_implib): move as part of the
	above new structure.
	(arm_elf_before_allocation): Access static variable from the params
	structure.
	(gld${EMULATION_NAME}_finish): Likewise.
	(arm_elf_create_output_section_statements): Likewise and pass the
	address of that structure to bfd_elf32_arm_set_target_relocs instead
	of the static variables.
	(PARSE_AND_LIST_ARGS_CASES): Access static variable from the params
	structure.
2016-08-26 14:00:39 +01:00
Thomas Preud'homme c2abbbebcc 2016-08-26 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* elf32-arm.c (elf32_arm_get_stub_entry): Assert that we don't access
	passed the end of htab->stub_group array.
	(elf32_arm_create_or_find_stub_sec): Likewise.
	(elf32_arm_create_stub): Likewise.
2016-08-26 12:01:47 +01:00
Thomas Preud'homme 1a336194b7 Add missing ARMv8-M special registers
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
	* config/tc-arm.c (v7m_psrs): Add MSPLIM, PSPLIM, MSPLIM_NS,
	PSPLIM_NS, PRIMASK_NS, BASEPRI_NS, FAULTMASK_NS, CONTROL_NS, SP_NS and
	their lowecase counterpart special registers.  Write register
	identifier in hex.
	* testsuite/gas/arm/archv8m-cmse-msr.s: Reorganize tests per
	operation, special register and then case.  Use different register for
	each operation.  Add tests for new special registers.
	* testsuite/gas/arm/archv8m-cmse-msr-base.d: Adapt expected result
	accordingly.
	* testsuite/gas/arm/archv8m-cmse-msr-main.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-4.d: Likewise.

opcodes/
	* arm-dis.c (psr_name): Use hex as case labels.  Add detection for
	MSPLIM, PSPLIM, MSPLIM_NS, PSPLIM_NS, PRIMASK_NS, BASEPRI_NS,
	FAULTMASK_NS, CONTROL_NS and SP_NS special registers.
2016-08-26 11:53:30 +01:00
Cupertino Miranda 980aa3e6df Dynamic TLS GOT entries would not be relocated.
Forgot to set should_relocate to TRUE in case of GOT and TLS relocations of
undefined symbols for shared libraries.
In dynamic libraries if symbol is not known the instruction relocation would
not be resolved to point to the respective .got entry.
A test was created to detect similar future mistakes.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (elf_arc_relocate_section): Changed. Set should_relocate
	to TRUE for GOT and TLS relocs.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* ld/testsuite/ld-arc/tls_gd-01.s: Added a testcase for this patch.
	* ld/testsuite/ld-arc/tls_gd-01.d: Likewise.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 65b94e9097 Fixed -init, -fini linker options.
ARC was overloading this options by forcing DT_INIT AND DT_FINI
to always point to _init and _fini, respectively.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synospsys.com>

	* elf32-arc.c (elf_arc_finish_dynamic_sections): Changed.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 8a36df4dcf Several fixes related to ARC PIE support.
Fixed conditions related to dynamic relocs relative offset patching.
Added arc_link_hash_table to be able to always generate and track
.rela.bss section.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* elf-bfd.h: Added ARC_ELF_DATA to enum elf_target_id.
	* elf32-arc.c (struct elf_arc_link_hash_entry): Added.
	(struct elf_arc_link_hash_table): Likewise.
	(elf_arc_link_hash_newfunc): Likewise.
	(elf_arc_link_hash_table_free): Likewise.
	(arc_elf_link_hash_table_create): Likewise.
	(elf_arc_relocate_section): Fixed conditions related to dynamic
	(elf_arc_check_relocs): Likewise.
	(arc_elf_create_dynamic_sections): Added
	(elf_arc_adjust_dynamic_symbol): Changed access to .rela.bss to be done
	through the hash table.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 4dd72ffdfe Content for TLS_IE_GOT not written to .got.
When no dynamic relocation was generated the .got content would not be
updated for the TLS_IE_GOT relocation addresses.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* arc-got.h (relocate_fix_got_relocs_for_got_info): Fixed addresses in
	debug comments. Fixed address in .got related to TLS_IE_GOT dynamic
	relocation.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-arc/tls_ie-01.s: Added to verify associated fix.
	* testsuite/ld-arc/tls_ie-01.d: Likewise
2016-08-26 12:09:17 +02:00
Cupertino Miranda a87aa054a6 Fixes to legacy ARC relocations.
Added support for ARC_SDA_12 reloc.
Fixed ARC_N32_ME.
Added ME (middle-endian) to ARC_SDA_12 reloc.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>
	* reloc.c: Fixed type in ARC_SECTOFF relocations. Added ARC_SDA_12
	relocation.
	* bfd-in2.h: Regenerated from the previous changes.
	* libbfd.h: Regenerated from the previous changes.

include/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>
	* elf/arc-reloc.def: Fixed relocation formula for N*, SDA, SDA_12,
	SDA_16_LD*, S13_PCREL, N32_ME, SECTOFF_* relocations.
	* opcode/arc-func.h (replace_disp12s): Added. Used for SDA_12 relocation.
2016-08-26 12:09:17 +02:00
Thomas Preud'homme 0955507f6e Add support for stable secure gateway veneers addresses
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add a new parameter for
	the input import library bfd.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (struct elf32_arm_link_hash_table): New in_implib_bfd
	and new_cmse_stub_offset fields.
	(stub_hash_newfunc): Initialize stub_offset and stub_template_size to
	-1.
	(elf32_arm_add_stub): Likewise for stub_offset.
	(arm_new_stubs_start_offset_ptr): New function.
	(arm_build_one_stub): Only allocate a stub_offset if it is -1.  Allow
	empty SG veneers to have zero relocations.
	(arm_size_one_stub): Only initialize stub size and template
	information for non empty veneers.  Do not update veneer section size
	if veneer already has an offset.
	(elf32_arm_create_stub): Return the stub entry pointer or NULL instead
	of a boolean indicating success or failure.
	(cmse_scan): Change stub_changed parameter into an integer pointer
	parameter cmse_stub_created to count the number of stub created and
	adapt to change of return value in elf32_arm_create_stub.
	(cmse_entry_fct_p): New function.
	(arm_list_new_cmse_stub): Likewise.
	(set_cmse_veneer_addr_from_implib): Likewise.
	(elf32_arm_size_stubs): Define cmse_stub_created, pass its address to
	cmse_scan instead of that of cmse_stub_changed to compute the number
	of stub created and use it to initialize stub_changed.  Call
	set_cmse_veneer_addr_from_implib after all cmse_scan.  Adapt to change
	of return value in elf32_arm_create_stub.  Use
	arm_stub_section_start_offset () if not NULL to initialize size of
	secure gateway veneers section.  Initialize stub_offset of Cortex-A8
	erratum fix to -1.  Use ret to hold return value.
	(elf32_arm_build_stubs): Use arm_stub_section_start_offset () if not
	NULL to initialize size of secure gateway veneers section.  Adapt
	comment to stress the importance of zeroing veneer section content.
	(bfd_elf32_arm_set_target_relocs): Add new in_implib_bfd parameter to
	initialize eponymous field in struct elf32_arm_link_hash_table.

ld/
	* emultempl/armelf.em (in_implib_filename): Declare and initialize new
	variable.
	(arm_elf_create_output_section_statements): Open import input library
	file for writing and pass resulting in_implib_bfd to
	bfd_elf32_arm_set_target_relocs.
	(PARSE_AND_LIST_PROLOGUE): Define OPTION_IN_IMPLIB option.
	(PARSE_AND_LIST_LONGOPTS): Define --in-implib option.
	(PARSE_AND_LIST_OPTIONS): Add help message for --in-implib option.
	(PARSE_AND_LIST_ARGS_CASES): Handle new OPTION_IN_IMPLIB case.
	* ld.texinfo (--cmse-implib): Update to mention --in-implib.
	(--in-implib): Document new option.
	* NEWS: Likewise.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway import library generation): add --defsym VER=1 to gas
	CLI.
	(Secure gateway import library generation: errors): Likewise.
	(Input secure gateway import library): New test.
	(Input secure gateway import library: no output import library):
	Likewise.
	(Input secure gateway import library: not an SG input import library):
	Likewise.
	(Input secure gateway import library: earlier stub section base):
	Likewise.
	(Input secure gateway import library: later stub section base):
	Likewise.
	(Input secure gateway import library: veneer comeback): Likewise.
	(Input secure gateway import library: entry function change):
	Likewise.
	* testsuite/ld-arm/cmse-implib.s: Add input import library testing.
	* testsuite/ld-arm/cmse-implib.rd: Update accordingly.
	* testsuite/ld-arm/cmse-new-implib.out: New file.
	* testsuite/ld-arm/cmse-new-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-implib-no-output.out: Likewise.
	* testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-earlier-later-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-comeback-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-wrong-implib.out: Likewise.
2016-08-26 11:00:36 +01:00
GDB Administrator 4edcc97c1a Automatic date update in version.in 2016-08-26 00:00:21 +00:00
Andreas Arnez e3e9290d6c S390: Add support for core dump NOTE sections
This enhances the 32-bit and 64-bit s390 ELF backends with support for
reading and writing the core dump note sections NT_PRSTATUS and
NT_PRPSINFO.  Byte swapping is done as appropriate, such that core files
can now be processed correctly on non-s390 platforms.

bfd/ChangeLog:

	* elf32-s390.c (stdarg.h): New include.
	(elf_s390_grok_psinfo): New function.
	(elf_s390_write_core_note): New function.
	(elf_backend_grok_psinfo): Declare backend hook.
	(elf_backend_write_core_note): Likewise.
	* elf64-s390.c (stdarg.h): New include.
	(elf_s390_grok_prstatus): New function.
	(elf_s390_grok_psinfo): New function.
	(elf_s390_write_core_note): New function.
	(elf_backend_grok_prstatus): Declare backend hook.
	(elf_backend_grok_psinfo): Likewise.
	(elf_backend_write_core_note): Likewise.
2016-08-25 19:13:57 +02:00
Andreas Arnez ceada89664 S390: Indentation fixes in elf32/64-s390.c
Some indentation fixes in elf32-s390.c and elf64-s390.c.  Whitespace
changes only.

bfd/ChangeLog:

	* elf32-s390.c (allocate_dynrelocs): Fix indentation.
	(elf_s390_finish_ifunc_symbol): Likewise.
	(elf_s390_finish_dynamic_symbol): Likewise.
	(elf_s390_finish_dynamic_sections): Likewise.
	(elf_s390_grok_prstatus): Likewise.
	* elf64-s390.c (elf_s390_hash_table): Fix indentation.
	(elf_s390_finish_dynamic_symbol): Likewise.
2016-08-25 19:13:57 +02:00
Andreas Arnez ae68ff9f28 xtensa: Avoid designated inits, for C++ compliance
C++ does not officially support designators in initializer lists.  Thus
some compilers may issue errors when encountering them.  Modern versions
of GCC seem to allow them by default, as a GCC extension, even though
the GCC documentation explicitly states otherwise: "[...] This extension
is not implemented in GNU C++."  But some older GCC versions (like
4.4.7) did indeed emit an error instead, like this:

  .../gdb/xtensa-config.c:219: error: expected primary-expression before
			       ‘.’ token

This patch removes the only such instance I've seen when building with
'--enable-targets=all'.

gdb/ChangeLog:

	* xtensa-tdep.h (XTENSA_GDBARCH_TDEP_INSTANTIATE): Replace
	designated initializer list by plain initializer list, for C++
	compliance.
2016-08-25 19:13:57 +02:00
Alan Modra 4811ccb48f powerpc ld configure
This fixes a few problems in the powerpc ld configury.
1) Using powerpc*le-* to test for powerpcle and powerpc64le would
   incorrectly match a target triple like powerpc-apple-elf.
2) In the same vein, *64* could match 64 in the user supplied MANUF-OS
   part of the target triple.
3) tooldir vars were missing, and some target aliases would result in
   ridiculous values for those tdir_* vars given.
4) Since 2016-04-25, BE support was added automatically when asking
   for an LE target.  If that is a good idea, then so is adding LE
   support when asking for BE.

	* configure.tgt (powerpc*-*-linux* et al): Rewrite, adding LE
	support for BE.  First output all target endian configury
	values, then opposite endian.  Handle more tooldirs.  Fix
	bogus matches with strings in MANUF-OS part of target triple.
2016-08-25 23:41:11 +09:30
Thomas Preud'homme c4dd0ba27f Remove _S version of ARM MSR/MRS special registers
2016-08-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* config/tc-arm.c (v7m_psrs): Remove msp_s, MSP_S, psp_s and PSP_S
	special registers.
	* testsuite/gas/arm/archv8m-cmse-msr.s: Remove test for above special
	registers.
	* testsuite/gas/arm/archv8m-cmse-msr-base.d: Likewise.
	* testsuite/gas/arm/archv8m-cmse-msr-main.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-4.d: Likewise.
2016-08-25 09:44:55 +01:00
Adhemerval Zanella 754653a7c0 Sync proc_service definition with GLIBC
GLIBC BZ#20311 [1] proc_service.h install patch also remove 'const'
attributes from ps_get_thread_area and comment #15 discuss why to remove
the const attribute (basically since it a callback with the struct
ps_prochandle owned by the client it should be able to modify it if
it the case).

On default build this is not the issue and current g++ does not trigger
any issue with this mismatch declaration.  However, on some bootstrap
build configuration where gdbserver is build with gcc instead this
triggers:

error: conflicting types for 'ps_get_thread_area'

This patch fixes it by syncing the declaration with GLIBC.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=20311

gdb/ChangeLog:

2016-08-25  Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	* aarch64-linux-nat.c (ps_get_thread_area): Remove const from
	struct ps_prochandle.
	* amd64-linux-nat.c (ps_get_thread_area): Likewise.
	* arm-linux-nat.c (ps_get_thread_area): Likewise.
	* gdb_proc_service.h (ps_get_thread_area): Likewise.
	* i386-linux-nat.c (ps_get_thread_area): Likewise.
	* m68klinux-nat.c (ps_get_thread_area): Likewise.
	* mips-linux-nat.c (ps_get_thread_area): Likewise.
	* nat/aarch64-linux.c (aarch64_ps_get_thread_area): Likewise.
	* nat/aarch64-linux.h (aarch64_ps_get_thread_area): Likewise.
	* xtensa-linux-nat.c (ps_get_thread_area): Likewise.

gdb/gdbserver/ChangeLog:

2016-08-25  Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	PR server/20491
	* gdb_proc_service.h (ps_get_thread_area): Remove const from struct
	ps_prochandle.
	* linux-aarch64-low.c (ps_get_thread_area): Likewise.
	* linux-arm-low.c (ps_get_thread_area): Likewise.
	* linux-crisv32-low.c (ps_get_thread_area): Likewise.
	* linux-m68k-low.c (ps_get_thread_area): Likewise.
	* linux-mips-low.c (ps_get_thread_area): Likewise.
	* linux-nios2-low.c (ps_get_thread_area): Likewise.
	* linux-tic6x-low.c (ps_get_thread_area): Likewise.
	* linux-x86-low.c (ps_get_thread_area): Likewise.
	* linux-xtensa-low.c (ps_get_thread_area): Likewise.
2016-08-25 08:42:03 +01:00
GDB Administrator 4a64c29a55 Automatic date update in version.in 2016-08-25 00:00:19 +00:00
H.J. Lu 6b40c46231 X86: Add ptwrite instruction
Implement ptwrite instruction defined in Intel64 and IA-32 Architectures
Software Developer’s Manual, June 2016.

gas/

	* config/tc-i386.c (cpu_arch): Add .ptwrite.
	* doc/c-i386.texi: Document ptwrite and .ptwrite.
	* testsuite/gas/i386/i386.exp: Run ptwrite, ptwrite-intel,
	x86-64-ptwrite and x86-64-ptwrite-intel.
	* testsuite/gas/i386/ptwrite-intel.d: New file.
	* testsuite/gas/i386/ptwrite.d: Likewise.
	* testsuite/gas/i386/ptwrite.s: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite-intel.d: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite.d: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite.s: Likewise.

opcodes/

	* i386-dis.c (PREFIX_MOD_0_0FAE_REG_4): New.
	(PREFIX_MOD_3_0FAE_REG_4): Likewise.
	(prefix_table): Add PREFIX_MOD_0_0FAE_REG_4 and
	PREFIX_MOD_3_0FAE_REG_4.
	(mod_table): Use PREFIX_MOD_0_0FAE_REG_4 and
	PREFIX_MOD_3_0FAE_REG_4.
	* i386-gen.c (cpu_flag_init): Add CPU_PTWRITE_FLAGS.
	(cpu_flags): Add CpuPTWRITE.
	* i386-opc.h (CpuPTWRITE): New.
	(i386_cpu_flags): Add cpuptwrite.
	* i386-opc.tbl: Add ptwrite instruction.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2016-08-24 15:29:39 -07:00
Kevin Buettner bb1fe4acb8 Test case to detect recursive unwinding in Python-based unwinders.
This test case verifies that GDB will not attempt to invoke a python
unwinder recursively.

At the moment, the behavior exhibited by GDB looks like this:

    (gdb) source py-recurse-unwind.py
    Python script imported
    (gdb) b ccc
    Breakpoint 1 at 0x4004bd: file py-recurse-unwind.c, line 23.
    (gdb) run
    Starting program: py-recurse-unwind
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.

    Breakpoint 1, ccc (arg=<unavailable>) at py-recurse-unwind.c:23
    23      }
    (gdb) bt
    #-1 ccc (arg=<unavailable>) at py-recurse-unwind.c:23
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

[I've shortened pathnames for easier reading.]

The desired / expected behavior looks like this:

    (gdb) source py-recurse-unwind.py
    Python script imported
    (gdb) b ccc
    Breakpoint 1 at 0x4004bd: file py-recurse-unwind.c, line 23.
    (gdb) run
    Starting program: py-recurse-unwind

    Breakpoint 1, ccc (arg=789) at py-recurse-unwind.c:23
    23      }
    (gdb) bt
    #0  ccc (arg=789) at py-recurse-unwind.c:23
    #1  0x00000000004004d5 in bbb (arg=456) at py-recurse-unwind.c:28
    #2  0x00000000004004ed in aaa (arg=123) at py-recurse-unwind.c:34
    #3  0x00000000004004fe in main () at py-recurse-unwind.c:40

Note that GDB's problems go well beyond the fact that it invokes the
unwinder recursively.  In the process it messes up some internal state
(the frame stash) leading to display of (only) the sentinel frame in
the backtrace.

gdb/testsuite/ChangeLog:

	* gdb.python/py-recurse-unwind.c: New file.
	* gdb.python/py-recurse-unwind.py: New file.
	* gdb.python/py-recurse-unwind.exp: New file.
2016-08-24 14:22:30 -07:00
Simon Marchi 0a1ddfa6b6 Allow resetting an empty inferior-tty
This patch allows the user to set the inferior-tty to "empty", in order
to come back to the default behaviour of using the same tty as gdb is
using.

This is already supported in MI (and tested in gdb.mi/mi-basics.exp).

I added a new test, set-inferior-tty.exp, where I test only the setting
and unsetting of the parameter.  It would be nice to actually test that
the inferior output properly goes to the separate tty, but that will be
for another day.

gdb/ChangeLog:

	* infcmd.c (set_inferior_io_terminal): Set inferior terminal to
	NULL if terminal_name is an empty string.
	(_initialize_infcmd): Make the argument of "set inferior-tty"
	optional, mention it in the help doc.

gdb/doc/ChangeLog:

	* gdb.texinfo (Input/Output): Mention possibility to unset
	inferior-tty.

gdb/testsuite/ChangeLog:

	* gdb.base/set-inferior-tty.exp: New file.
	* gdb.base/set-inferior-tty.c: New file.
2016-08-24 13:10:08 -04:00
Carl E. Love bdd78711b4 Fix for gdb.base/pc-fp.exp.
It is my understanding that GDB used to require each architecture to
define a Frame Pointer (fp).  However, this functionality was deprecated
some time ago so the call to setup the fp_reg was changed to deprecated
(set_gdbarch_deprecated_fp_regnum).  It should have been removed from the
Power code.

That said, the code "set_gdbarch_deprecated_fp_regnum
(gdbarch, PPC_R0_REGNUM + 1);" sets up register r1 as the frame pointer.
Register r1 is no longer used to hold the frame pointer on Power.  By
removing the fp definition for Power in GDB, it causes GDB to fall back
to the call get_frame_base_address (frame) which returns the correct value
depending on the specific senario but most of the time is the DWARF
canonical frame address.

gdb/ChangeLog

2016-08-24  Carl Love  <cel@us.ibm.com>

	* rs6000-tdep.c (rs6000_gdbarch_init): Remove call
        set_gdbarch_deprecated_fp_regnum() from initialization function.
2016-08-24 08:08:58 -07:00
Anton Kolesov ab548d2db9 [ARC] C++ compatibility for arc-dis.h
opcodes/
2016-08-24  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* arc-dis.h: Wrap around in extern "C".

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2016-08-24 14:23:00 +02:00
Anton Kolesov 47f7f636bc [ARC] Parse NOTE section in core dump files
This patch adds function elf32_arc_grok_parse to parse NOTE section of core
dump files. GDB requires this to work properly with core dumps.

bfd/
2016-08-24  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* elf32-arc.c (elf32_arc_grok_prstatus): New function.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2016-08-24 13:56:32 +02:00
Roland McGrath 1130c90ed7 [gold] Implement -z stack-size option
gold/
	* options.h (General_options): Grok -z stack-size.
	* output.h (Output_segment::set_size): New method.
	* layout.cc (Layout::create_executable_stack_info): Renamed to ...
	(Layout::create_stack_segment): ... this.  Always create the
	segment if -z stack-size was used.
	(Layout::set_segment_offsets): Don't call ->set_offset on the
	PT_GNU_STACK segment.
2016-08-23 17:15:53 -07:00
GDB Administrator 4ba25152ff Automatic date update in version.in 2016-08-24 00:00:20 +00:00
Bharathi Seshadri 9f84726cd5 Add --be8 option to gold.
gold/
	* options.h (General_options): Add --be8 option.
	* arm.cc (Arm_relobj::do_relocate_sections): Add code to swap for be8.
	(Output_data_plt_arm_standard::do_fill_first_plt_entry): Likewise.
	(Output_data_plt_arm_short::do_fill_plt_entry): Likewise.
	(Output_data_plt_arm_long::do_fill_plt_entry): Likewise.
	(Target_arm::do_adjust_elf_header): Do EF_ARM_BE8 adjustment.
2016-08-23 14:50:48 -07:00
Simon Marchi 34f81801be Fix typo in comment
gdb/ChangeLog:

	* stack.c (parse_frame_specification): Fix typo in comment.
2016-08-23 13:49:56 -04:00
Pedro Alves d9de1fe3d5 Fix PR20494 - User input stops being echoed in CLI
This patch fixes a problem that problem triggers if you start an
inferior, e.g., with the "start" command, in a UI created with the
new-ui command, and then run a foreground execution command in the
main UI.  Once the program stops for the latter command, typing in the
main UI no longer echoes back to the user.

The problem revolves around this:

- gdb_has_a_terminal computes its result lazily, on first call.

  that is what saves gdb's initial main UI terminal state (the UI
  associated with stdin):

          our_terminal_info.ttystate = serial_get_tty_state (stdin_serial);

  This is the state that target_terminal_ours() restores.

- In this scenario, the gdb_has_a_terminal function happens to be
  first ever called from within the target_terminal_init call in
  startup_inferior:

      (top-gdb) bt
      #0  gdb_has_a_terminal () at src/gdb/inflow.c:157
      #1  0x000000000079db22 in child_terminal_init_with_pgrp () at src/gdb/inflow.c:217
       [...]
      #4  0x000000000065bacb in target_terminal_init () at src/gdb/target.c:456
      #5  0x00000000004676d2 in startup_inferior () at src/gdb/fork-child.c:531
       [...]
      #7  0x000000000046b168 in linux_nat_create_inferior () at src/gdb/linux-nat.c:1112
       [...]
      #9  0x00000000005f20c9 in start_command (args=0x0, from_tty=1) at src/gdb/infcmd.c:657

If the command to start the inferior is issued on the main UI, then
readline will have deprepped the terminal when we reach the above, and
the problem doesn't appear.

If however the command is issued on a non-main UI, then when we reach
that gdb_has_a_terminal call, the main UI's terminal state is still
set to whatever readline has sets it to in rl_prep_terminal, which
happens to have echo disabled.  Later, when the following synchronous
execution command finishes, we'll call target_terminal_ours to restore
gdb's the main UI's terminal settings, and that restores the terminal
state with echo disabled...

Conceptually, the fix is to move the gdb_has_a_terminal call earlier,
to someplace during GDB initialization, before readline/ncurses have
had a chance to change terminal settings.  Turns out that
"set_initial_gdb_ttystate" is exactly such a place.

I say conceptually, because the fix actually inlines the
gdb_has_a_terminal part that saves the terminal state in
set_initial_gdb_ttystate and then simplifies gdb_has_a_terminal, since
there's no point in making gdb_has_a_terminal do lazy computation.

gdb/ChangeLog:
2016-08-23  Pedro Alves  <palves@redhat.com>

	PR gdb/20494
	* inflow.c (our_terminal_info, initial_gdb_ttystate): Update
	comments.
	(enum gdb_has_a_terminal_flag_enum, gdb_has_a_terminal_flag):
	Delete.
	(set_initial_gdb_ttystate): Record our_terminal_info here too,
	instead of ...
	(gdb_has_a_terminal): ... here.  Reimplement in terms of
	initial_gdb_ttystate.  Make static.
	* terminal.h (gdb_has_a_terminal): Delete declaration.
	(set_initial_gdb_ttystate): Add comment.
	* top.c (show_interactive_mode): Use input_interactive_p instead
	of gdb_has_a_terminal.

gdb/testsuite/ChangeLog:
2016-08-23  Pedro Alves  <palves@redhat.com>

	PR gdb/20494
	* gdb.base/new-ui-echo.c: New file.
	* gdb.base/new-ui-echo.exp: New file.
2016-08-23 16:03:28 +01:00
Nick Clifton 38334d6de4 Better fix for PR 20499, including preventing strlen from being called on an uninitialised name field.
PR gprof/20499
	* corefile.c (BUFSIZE): Define.
	(STR_BUFSIZE): Define.
	(read_function_mappings): Use BUFSIZE and STR)BUFSIZE.
	(num_of_syms_in): Move buf, address and name arrays out of
	function and declare as static BUFSIZE arrays.
	Use STR_BUFSIZE when scanning for name and address.
	(core_create_syms_from): Revert previous delta.  Instead
	short circuit the parsing of a symbol if all three fields
	could not be found.
2016-08-23 15:41:01 +01:00