Commit Graph

93405 Commits

Author SHA1 Message Date
Henry Wong d2159fdc0f MIPS: Fix encoding for MIPSr6 sigrie instruction.
The instruction encoding for the MIPS r6 sigrie instruction seems to be
incorrect.  It's currently 0x4170xxxx (which overlaps with ei, di, evp,
and dvp), but should be 0x0417xxxx.  See ISA reference[1][2].

References:

[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
    Instruction Set Manual", Imagination Technologies, Inc., Document
    Number: MD00086, Revision 6.06, December 15, 2016, Table A.4 "MIPS32
    REGIMM Encoding of rt Field", p. 452

[2] "MIPS Architecture For Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Imagination Technologies, Inc.,
    Document Number: MD00087, Revision 6.06, December 15, 2016, Table
    A.4 "MIPS64 REGIMM Encoding of rt Field", p. 581

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Correct "sigrie" encoding.

	gas/
	* testsuite/gas/mips/r6.d: Update for "sigrie" encoding fix.
	* testsuite/gas/mips/r6-n32.d: Likewise.
	* testsuite/gas/mips/r6-n64.d: Likewise.
2018-02-12 14:50:42 +00:00
Zebediah Figura 830db0485e Add support for reading msdos MZ executables.
See email thread starting here:  https://www.sourceware.org/ml/binutils/2018-01/msg00001.html

include	* coff/msdos.h: New header.
	* coff/pe.h: Move common defines to msdos.h.
	* coff/powerpc.h: Likewise.

bfd	* i386msdos.c (msdos_mkobject); New function.
	(msdos_object_p): New function.
	(i386_msdos_vec): Use msdos_object_p as the check_format
	function.
	* peicode.h: Rename external_PEI_DOS_hdr, DOSMAGIC, and
	NT_SIGNATURE to external_DOS_hdr, IMAGE_DOS_SIGNATURE, and
	IMAGE_NT_SIGNATURE.
	* peXXigen.c: Likewise.
	* coff-ia64.c: Likewise.
2018-02-12 13:15:56 +00:00
Nick Clifton 7e784da543 Update Russian translation for the gas/ sub-directory. 2018-02-12 12:10:50 +00:00
Nick Clifton 0b8683b7eb Fix compile time warning: bfd/elf32-arc.c:1537]: (warning) Redundant assignment of 'rel->r_offset' to itself.
* elf32-arc.c (elf_arc_relocate_section):  Remove redundant
	assignment.
2018-02-12 11:57:41 +00:00
Nick Clifton 6444b19b24 oops - actually remove the assignment this time: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself. 2018-02-12 11:54:48 +00:00
Nick Clifton 94fe5757db Fix compile time warning: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself.
* elf32-nds32.c (nds32_elf_relax_longjump3): Remove redundant
	assignment.
2018-02-12 11:51:56 +00:00
GDB Administrator 7eb84119d8 Automatic date update in version.in 2018-02-12 00:00:35 +00:00
GDB Administrator e5bc5e207b Automatic date update in version.in 2018-02-11 00:01:01 +00:00
Eric Botcazou d805612e38 Fix commit date. 2018-02-10 02:37:32 +01:00
Eric Botcazou a8735c82b8 Fix GOT relocation overflow on SPARC.
There are 2 failures left in the linker testsuite on SPARC64/Linux and
they are caused by 2 different issues leading to the same end effect:
the overflow of the relocation section for the GOT, i.e. the linker
generates too many dynamic relocations for the GOT wrt the size of the
relocation section, leading to memory corruption and missing relocations
in the final binary.

The first issue was introduced by:
  https://sourceware.org/ml/binutils/2017-06/msg00368.html
which makes the linker generate more R_SPARC_RELATIVE relocations for
the GOT without adjusting the size of the relocation section.  This is
fixed by (1) preventively adjusting this size in allocate_dynrelocs and
(2) generating R_SPARC_NONE if needed when R_SPARC_GOTDATA_OP is relaxed.

The second issue is that we generate a GOT relocation for an undefined
weak symbol with non-default visibility in a PIC binary without accounting
for that  in the size of the relocation section.  Since the address of the
symbol should resolve to 0 at run time, it is fixed by not generating the
relocation at all, i.e. leaving the GOT entry zeroed.

bfd/
	* elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Reorder conditions.
	(sparc_elf_append_rela): Assert that there is enough room in section.
	(_bfd_sparc_elf_copy_indirect_symbol): Fix formatting.
	(_bfd_sparc_elf_adjust_dynamic_symbol): Minor tweak.
	(allocate_dynrelocs): Remove outdated comments and reorder conditions.
	For a symbol subject to a GOT relocation, reserve a slot in the
	relocation section if the symbol isn't dynamic and we are in PIC mode.
	(_bfd_sparc_elf_relocate_section) <R_SPARC_GOTDATA_OP>: If relocation
	is relaxed and a slot was reserved, generate a R_SPARC_NONE relocation.
	<R_SPARC_GOTDATA_OP_HIX22>: Adjust comments.
	<R_SPARC_PC10>: Reorder conditions.  Remove always-false assertion.
	(_bfd_sparc_elf_finish_dynamic_symbol): Rename local_undefweak into
	resolved_to_zero.  Do not generate a dynamic GOT relocation for an
	undefined weak symbol with non-default visibility.  Remove superfluous
	'else' and fix formatting.
2018-02-10 02:30:25 +01:00
GDB Administrator 5d0fb5ffdf Automatic date update in version.in 2018-02-10 00:00:34 +00:00
H.J. Lu 3b4c384407 x86: Add is_solaris to elf_x86_target_os
Add is_solaris to elf_x86_target_os since Solaris is quite different.

	* elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle
	is_solaris.
	(i386_elf32_sol2_vec): Don't declare.
	(elf_i386_link_setup_gnu_properties): Also handle is_solaris.
	Don't set need_global_offset_table.
	(elf_i386_solaris_arch_bed): New.
	(elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for
	Solaris.
	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check
	target_os != is_nacl instead of target_os == is_normal.
	(x86_64_elf64_sol2_vec): Don't declare.
	(elf_x86_64_link_setup_gnu_properties): Check target_os !=
	is_nacl instead of target_os == is_normal.  Don't set
	need_global_offset_table.
	(elf_x86_64_solaris_arch_bed): New.
	(elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for
	Solaris.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep
	_GLOBAL_OFFSET_TABLE_ for Solaris.
	(_bfd_x86_elf_link_setup_gnu_properties): Don't copy
	need_global_offset_table.
	* elfxx-x86.h (elf_x86_target_os): Add is_solaris.
	(elf_x86_link_hash_table): Remove need_global_offset_table.
	(elf_x86_init_table): Likewise.
2018-02-09 08:45:07 -08:00
Tom Tromey 9c3630e983 Don't reference past the end of the vector
An earlier change made find_source_lines read:

    end = &data[size];

However, since 'size' is the size of the vector, this seems fishy.
More obviously ok is to compute the end of the data directly:

    end = data.data () + size;

2018-02-09  Tom Tromey  <tom@tromey.com>

	* source.c (find_source_lines): Don't reference past the end of
	the vector.
2018-02-09 06:46:11 -07:00
Markus Metzger c4e1263132 btrace: reword error messages
Reword some btrace error messages to align with the format discussed in
https://sourceware.org/ml/gdb-patches/2018-02/msg00135.html.

gdb/
	* remote.c (remote_btrace_maybe_reopen): Change error message.
	* btrace.c (btrace_enable): Likewise.
	(parse_xml_btrace): Likewise.
	(parse_xml_btrace_conf): Likewise.

testsuite/
	* lib/gdb.exp (skip_btrace_pt_tests): Update expected error message.
	Fix test name.
2018-02-09 14:03:22 +01:00
Markus Metzger 88711fbfea btrace: check perf_event_paranoid
One recurring error on Debian systems is that the default perf_event_paranoid
setting disables the perf_event interface for user-space.

Check the current level and point the user to the file.

gdb/
	* nat/linux-btrace.c (diagnose_perf_event_open_fail): New.
	(linux_enable_pt, linux_enable_bts): Call
	diagnose_perf_event_open_fail.
2018-02-09 14:03:21 +01:00
Markus Metzger 17ad2a4f46 btrace: improve enable error messages
Improve the error message when GDB fails to start recording branch trace.

This patch also removes a zero buffer size check for PT to align with BTS.  The
buffer size can not be configured to be zero.

gdb/
	* nat/linux-btrace.c (perf_event_pt_event_type): Improve error message.
	Remove parameter and change return type.  Update callers.  Move it.
	(linux_enable_bts, linux_enable_pt): Improve error message.
	(linux_enable_pt): Remove zero buffer size check.
	(linux_enable_btrace): Improve error messages.  Remove NULL return
	check.
2018-02-09 14:03:20 +01:00
Markus Metzger de6242d307 btrace, gdbserver: remove the to_supports_btrace target method
Remove the to_supports_btrace target method and instead rely on detecting errors
when trying to enable recording.  This will also provide a suitable error
message explaining why recording is not possible.

For remote debugging, gdbserver will now always advertise branch tracing related
packets.  When talking to an older GDB, this will cause GDB to try to enable
branch tracing and gdbserver to report a suitable error message every time.

An older gdbserver will not advertise branch tracing related packets if the
one-time check failed, so a newer GDB with this patch will fail to enable branch
tracing at remote_enable_btrace() rather than at btrace_enable().  The error
message is the same in both cases so there should be no user-visible change.

gdb/
	* btrace.c (btrace_enable): Remove target_supports_btrace call.
	* nat/linux-btrace.c (perf_event_pt_event_type): Move.
	(kernel_supports_bts, kernel_supports_pt, linux_supports_bts)
	(linux_supports_pt, linux_supports_btrace): Remove.
	(linux_enable_bts): Call cpu_supports_bts.
	* nat/linux-btrace.h (linux_supports_btrace): Remove.
	* remote.c (remote_supports_btrace): Remove.
	(init_remote_ops): Remove remote_supports_btrace.
	* target-delegates.c: Regenerated.
	* target.c (target_supports_btrace): Remove.
	* target.h (target_ops) <to_supports_btrace>: Remove
	(target_supports_btrace): Remove.
	* x86-linux-nat.c (x86_linux_create_target): Remove
	linux_supports_btrace.

gdbserver/
	* linux-low.c (linux_target_ops): Remove linux_supports_btrace.
	* nto-low.c (nto_target_ops): Remove NULL for supports_btrace.
	* spu-low.c (spu_target_ops): Likewise.
	* win32-low.c (win32_target_ops): Likewise.
	* server.c (supported_btrace_packets): Report packets unconditionally.
	* target.h (target_ops) <supports_btrace>: Remove.
	(target_supports_btrace): Remove.
2018-02-09 14:03:20 +01:00
Markus Metzger 9ee23a853c btrace, gdbserver: use exceptions to convey btrace enable/disable errors
Change error reporting to use exceptions and be prepared to catch them in
gdbserver.  We use the exception message in our error reply to GDB.

This may remove some detail from the error message in the native case since
errno is no longer printed.  Later patches will improve that.

We're still using error strings on the RSP level.  This patch does not affect
the interoperability of older/newer GDB/gdbserver.

gdbserver/
	* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt)
	(handle_btrace_disable): Change return type to void.  Use exceptions
	to report errors.
	(handle_btrace_general_set): Catch exception and copy message to
	return message.

gdb/
	* nat/linux-btrace.c (linux_enable_btrace): Throw exception if enabling
	btrace failed.
	* x86-linux-nat.c (x86_linux_enable_btrace): Catch btrace enabling
	exception and use message in own exception.
2018-02-09 14:03:19 +01:00
Markus Metzger 5c3284c1ec btrace: prepare for throwing exceptions when enabling btrace
We indicate success or failure for enabling branch tracing via the pointer
return value.  Depending on the type of error, errno may provide additional
information.

Prepare for using exceptions with more descriptive error messages by using smart
pointers and objects with automatic destruction to hold intermediate results.

gdb/
	* nat/linux-btrace.c: Include scoped_fd.h and scoped_mmap.h.
	(perf_event_pt_event_type): Use gdb_file_up.
	(linux_enable_bts, linux_enable_pt): Use gdb::unique_xmalloc_ptr,
	scoped_fd, and scoped_mmap.
2018-02-09 14:03:19 +01:00
Markus Metzger 84696f37ae common: add scoped_mmap
Add a simple helper to automatically unmap a memory mapping.

gdb/
	* common/scoped_mmap.h: New.
	* unittests/scoped_mmap-selftest.c: New.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/scoped_mmap-selftest.c.
2018-02-09 14:03:19 +01:00
Markus Metzger ea4a088812 common: add scoped_fd
Add a simple helper to automatically close a file descriptor.

gdb/
	* common/scoped_fd.h: New.
	* unittests/scoped_fd-selftest.c: New.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/scoped_fd-selftest.c.
2018-02-09 14:03:18 +01:00
Tom Tromey 869e8290ea Use gdb::unique_xmalloc_ptr in auto_load_section_scripts
This changes auto_load_section_scripts to use gdb::unique_xmalloc_ptr,
allowing the removal of a cleanup.

2018-02-09  Tom Tromey  <tom@tromey.com>

	* auto-load.c (auto_load_section_scripts): Use
	gdb::unique_xmalloc_ptr.
2018-02-09 05:53:22 -07:00
Tom Tromey a37a2ae708 Use std::string in execute_script_contents
This changes execute_script_contents to use a std::string, allowing
the removal of a cleanup.

2018-02-09  Tom Tromey  <tom@tromey.com>

	* auto-load.c (execute_script_contents): Use std::string.
2018-02-09 05:53:21 -07:00
Joel Brobecker 4e72534799 gdb/NEWS: Clarify the news entry for "rbreak" in GDB 8.1
gdb/ChangeLog:

        * NEWS <Changes in GDB 8.1>: Clarify that "rbreak" is a new
        Python function, rather than a new command.
2018-02-09 16:04:38 +04:00
H.J. Lu 15b23f3612 x86: Set need_global_offset_table with info->output_bfd->xvec
* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
	Remove prototype.
	(i386_elf32_sol2_vec): Declared.
	(elf_i386_link_setup_gnu_properties): Set
	need_global_offset_table with info->output_bfd->xvec.
	* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
	Remove prototype.
	(x86_64_elf64_sol2_vec): Declared.
	(elf_x86_64_link_setup_gnu_properties): Set
	need_global_offset_table with info->output_bfd->xvec.
2018-02-08 16:30:55 -08:00
GDB Administrator 4d6945e70a Automatic date update in version.in 2018-02-09 00:00:25 +00:00
H.J. Lu dc11dea212 x86: Keep the unused _GLOBAL_OFFSET_TABLE_ for Solaris
Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it isn't used.
This patch detects Solaris target and keeps _GLOBAL_OFFSET_TABLE_ for
Solaris.

	* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
	New prototype.
	(elf_i386_link_setup_gnu_properties): Set need_global_offset_table
	for Solaris.
	* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
	New prototype.
	(elf_x86_64_link_setup_gnu_properties): Set
	need_global_offset_table for Solaris.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep the
	unused _GLOBAL_OFFSET_TABLE_ for Solaris.
	(_bfd_x86_elf_link_setup_gnu_properties): Copy
	need_global_offset_table.
	* elfxx-x86.h (elf_x86_link_hash_table): Add
	need_global_offset_table.
	(elf_x86_init_table): Likewise.
2018-02-08 13:52:22 -08:00
Jim Wilson 3f48fe4a95 RISC-V: Add comment for previous change.
bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous
	change.
2018-02-08 13:15:10 -08:00
Tom Tromey 9a897d43f0 Remove cleanups from solib.c
This removes a couple of cleanups from solib.c, replacing one with
std::string and another with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* solib.c (solib_find_1): Use std::string.
	(solib_bfd_fopen): Use unique_xmalloc_ptr.
2018-02-08 11:46:57 -07:00
Tom Tromey 58ef3771fb Use unique_xmalloc_ptr in build_id_to_debug_bfd
This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr,
removing a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr.
2018-02-08 11:46:57 -07:00
Tom Tromey a9abc43451 Use gdb::def_vector in find_source_lines
This replaces an explicit malloc and a cleanup with a gdb::def_vector.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* source.c (find_source_lines): Use gdb::def_vector.
2018-02-08 11:46:57 -07:00
Tom Tromey 84f27c6fcb Remove cleanups from macro_define_command
This removes cleanups from macro_define_command, by introducing a new
struct temporary_macro_definition that cleans up after itself.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macrocmd.c (struct temporary_macro_definition): New.
	(macro_define_command): Use temporary_macro_definition.  Remove
	cleanups.
	(free_macro_definition_ptr): Remove.
2018-02-08 11:46:56 -07:00
Tom Tromey 0354904bda Use std::string in maybe_expand
This patch changes maybe_expand to use std::string rather than an
explicit malloc and a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macroexp.c (maybe_expand): Use std::string.
2018-02-08 11:46:56 -07:00
Tom Tromey 1739cf248f Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members.  Then this is
used to remove various cleanups in macroexp.c.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macroexp.c (struct macro_buffer): Add initializers for some
	members.
	(init_buffer, init_shared_buffer, free_buffer)
	(free_buffer_return_text): Remove.
	(macro_buffer): New constructors.
	(~macro_buffer): New destructor.
	(macro_buffer::set_shared): New method.
	(macro_buffer::resize_buffer, macro_buffer::appendc)
	(macro_buffer::appendmem): Now methods, not free functions.
	(set_token, append_tokens_without_splicing, stringify)
	(macro_stringify): Update.
	(gather_arguments): Change return type.  Remove argc_p argument,
	add args_ptr argument.  Use std::vector.
	(substitute_args): Remove argc argument.  Accept std::vector.
	(expand): Update.  Use std::vector.
	(scan, macro_expand, macro_expand_next): Update.
2018-02-08 11:46:56 -07:00
Tom Tromey f6c2623eb8 Return unique_xmalloc_ptr from macro scope functions
This changes the macro scope functions (sal_macro_scope,
user_macro_scope, and default_macro_scope) to return a
unique_xmalloc_ptr, then fixes up the users.  This allowed for the
removal of several cleanups.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* symtab.c (default_collect_symbol_completion_matches_break_on):
	Use unique_xmalloc_ptr.
	* macroscope.h: (sal_macro_scope, user_macro_scope)
	(default_macro_scope): Return unique_xmalloc_ptr.
	* macroscope.c (sal_macro_scope, user_macro_scope)
	(default_macro_scope): Return unique_xmalloc_ptr.
	* macroexp.h (macro_expand, macro_expand_once): Return
	unique_xmalloc_ptr.
	* macroexp.c (macro_expand, macro_expand_once): Return
	unique_xmalloc_ptr.
	* macrocmd.c (macro_expand_command, macro_expand_once_command)
	(info_macro_command, info_macros_command): Use
	unique_xmalloc_ptr.
	* compile/compile-c-support.c (write_macro_definitions): Use
	unique_xmalloc_ptr.
	* c-exp.y (c_parse): Use unique_xmalloc_ptr.
2018-02-08 11:46:55 -07:00
Tom Tromey 8ce47547b3 Remove make_cleanup_restore_current_thread from gdbserver
This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* linux-low.c (install_software_single_step_breakpoints): Use
	make_scoped_restore.
	* inferiors.c (make_cleanup_restore_current_thread): Remove.
	(do_restore_current_thread_cleanup): Remove.
	* gdbthread.h (make_cleanup_restore_current_thread): Don't
	declare.
2018-02-08 11:46:55 -07:00
Tom Tromey 45dd3607e2 Remove a cleanup from gdbserver
This removes a cleanup from gdbserver's set_raw_breakpoint_at,
replacing it with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* mem-break.c (set_raw_breakpoint_at): Use
	gdb::unique_xmalloc_ptr.
2018-02-08 11:46:55 -07:00
Nick Clifton 8de3a6e2af Speed up readelf and objdump by not looking for DWO links unless the user has requested that they be displayed/followed.
PR 22802
	* dwarf.c (load_separate_debug_file): Return early if the user is
	not interested in debug links.
2018-02-08 12:29:07 +00:00
Nick Clifton ef135d4314 Fix a seg-fault in the ELF note parser when a note with an excessively large alignment is encountered.
PR 22788
	* elf.c (elf_parse_notes): Reject notes with excessuively large
	alignments.
2018-02-08 10:28:25 +00:00
Alan Modra a9479dc051 PR22819, powerpc gas "instruction address is not a multiple of 4"
Checks for insn alignment were hopelessly confused when misaligned
data starts a new frag.  The real-world testcase happened to run out
of frag space in the middle of emitting a trace-back table via
something like:
	.byte 0		/* VERSION=0 */
 	.byte 9		/* LANG=C++ */
	.byte 34	/* Bits on: has_tboff, fp_present */
	.byte 64	/* Bits on: name_present */
	.byte 128	/* Bits on: stores_bc, FP_SAVED=0 */
	.byte 0		/* Bits on: GP_SAVED=0 */
	.byte 2		/* FIXEDPARMS=2 */
	.byte 1		/* FLOATPARMS=0, parmsonstk */
	.long 0
	.long 768	/* tb_offset: 0x300 */
	.hword 45	/* Function name length: 45 */
 	.long 0x334e5a5f
	.long 0x31766f70
	.long 0x65744932
	.long 0x69746172
	.long 0x7a5f6e6f
	.long 0x64504533
	.long 0x5f534e50
	.long 0x72463431
	.long 0x61746361
	.long 0x74535f6c
	.long 0x74637572
	.byte 0x45
	.byte 0
The trigger being those misaligned .long's output for the function
name.  A most horrible way to output a string, especially considering
endian issues..

	PR 22819
	* config/tc-ppc.c (md_assemble): Rewrite insn alignment checking.
	(ppc_frag_check): Likewise.
	* testsuite/gas/ppc/misalign.d,
	* testsuite/gas/ppc/misalign.l,
	* testsuite/gas/ppc/misalign.s: New test.
	* testsuite/gas/ppc/misalign2.d,
	* testsuite/gas/ppc/misalign2.s: New test.
	* testsuite/gas/ppc/ppc.exp: Run them.
2018-02-08 13:56:29 +10:30
GDB Administrator 02ecce62be Automatic date update in version.in 2018-02-08 00:00:32 +00:00
Simon Marchi c2e0e465f9 Fix type of values representing optimized out static members
As reported here:

  https://sourceware.org/ml/gdb/2018-02/msg00019.html

the type of values representing static members that are optimized out is
wrong.  It currently assigns the type of the containing class rather
than the type of the field.  This patch fixes that.

I found a place in m-static.exp already dealing with optimized out
static members, so I just added some gdb_test there.

gdb/ChangeLog:

	* value.c (value_static_field): Assign field type instead of
	containing type when returning an optimized out value.

gdb/testsuite/ChangeLog:

	* gdb.cp/m-static.exp: Check type of optimized out static
	member.
2018-02-07 08:49:56 -05:00
Alan Modra 407aa07cee Revert "PowerPC PLT speculative execution barriers"
This reverts most of commit 1be5d8d3bb.
Left in place are addition of --no-plt-align to some ppc32 ld tests
and the ld.texinfo --no-plt-thread-safe fix.
2018-02-07 14:23:08 +10:30
Jim Wilson ed01220cc8 RISC-V: Eliminate spurious error w/ reloc truncated message
bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used
	callback to report an error.
2018-02-06 16:53:41 -08:00
GDB Administrator f3342ae030 Automatic date update in version.in 2018-02-07 00:00:39 +00:00
Yao Qi 3f8c94b478 Remove some $ARCH_read_pc and $ARCH_write_pc
Nowadays, gdbarch_read_pc is called in this way,

  if (gdbarch_read_pc_p (gdbarch))
    pc_val = gdbarch_read_pc (gdbarch, regcache);
  /* Else use per-frame method on get_current_frame.  */
  else if (gdbarch_pc_regnum (gdbarch) >= 0)
    {
      ULONGEST raw_val;

      if (regcache_cooked_read_unsigned (regcache,
					 gdbarch_pc_regnum (gdbarch),
					 &raw_val) == REG_UNAVAILABLE)

some ports don't have to define its own gdbarch read_pc method if the
pc value is simply a unsigned value from "pc" register.  The same rule
applies to regcache_write_pc.  This patch removes these $ARCH_read_pc
and $ARCH_write_pc functions.

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

	* ft32-tdep.c (ft32_read_pc): Remove.
	(ft32_write_pc): Remove.
	(ft32_gdbarch_init): Update.
	* m32r-tdep.c (m32r_read_pc): Remove.
	(m32r_gdbarch_init): Update.
	* mep-tdep.c (mep_read_pc): Remove.
	(mep_gdbarch_init): Update.
	* microblaze-tdep.c (microblaze_write_pc): Remove.
	(microblaze_gdbarch_init): Update.
	* mn10300-tdep.c (mn10300_read_pc): Remove.
	(mn10300_write_pc): Remove.
	(mn10300_gdbarch_init): Update.
	* moxie-tdep.c (moxie_read_pc): Remove.
	(moxie_write_pc): Remove.
	(moxie_gdbarch_init): Update.
2018-02-06 17:31:33 +00:00
Eric Botcazou c20c30f615 Fix PR ld/22263 on SPARC.
This is -fpie -pie generating dynamic relocations in the text section,
simply because no TLS transitions are applied in PIE mode.  The meat
of the patch is to turn calls to bfd_link_pic (info) in TLS-related code
into !bfd_link_executable (info) and there are quite a lot of them...

bfd/
	* elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic
	into call to !bfd_link_executable and tidy up.
	(_bfd_sparc_elf_check_relocs): Fix formatting and tidy up.
	<R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_TLS_IE_HI22>: Likewise.
	<GOT relocations>: Remove useless code, tidy and merge blocks.
	<R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_WPLT30>: Tidy up.
	(_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call
	to !bfd_link_executable.
	(allocate_dynrelocs): Likewise.
	(_bfd_sparc_elf_relocate_section): Fix formatting and tidy up.
	<R_SPARC_TLS_GD_HI22>: Merge into...
	<R_SPARC_TLS_GD_LO10>: ...this.  Adjust 4th argument in call to
	sparc_elf_tls_transition and remove redundant code.
	<R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_TLS_LDO_HIX22>: Likewise.
	<R_SPARC_TLS_LE_HIX22>: Likewise.  Tidy up.
	<R_SPARC_TLS_LDM_CALL>: Likewise.
	<R_SPARC_TLS_GD_CALL>: Likewise.  Tidy up.
	<R_SPARC_TLS_GD_ADD>: Likewise.
	<R_SPARC_TLS_LDM_ADD>: Likewise.
	<R_SPARC_TLS_LDO_ADD>: Likewise.
	<R_SPARC_TLS_IE_LD>: Likewise.
ld/
	* testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC.
	(pr22263-1): Pass AFLAGS_PIC to the assembler.
	* testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions.
	* testsuite/ld-sparc/tlspie32.dd: Adjust to above.
	* testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions.
	* testsuite/ld-sparc/tlspie64.dd: Adjust to above.
2018-02-06 18:17:39 +01:00
Yao Qi bca65a2394 Treat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL
When I debug some fortran expression parsing, I got

(gdb) set debug expression 1
(gdb) p intvla(5,5,5)
Dump of expression @ 0x205fa80, before conversion to prefix form:
	Language fortran, 19 elements, 16 bytes each.
	Index                Opcode         Hex Value  String Value
	    0          OP_VAR_VALUE  40  (...............
	    1    <unknown 31863232>  31863232  .1..............
....
	   14             BINOP_REM  5  ................
	   15               OP_LONG  38  &...............
	   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
	   17             BINOP_MUL  3  ................
	   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x205fa80, after conversion to prefix form:
Expression: `Invalid expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This patch fixes this problem by handling OP_F77_UNDETERMINED_ARGLIST in
the same way as handling OP_FUNCALL.  With this patch applied, the output
looks better,

(gdb) p intvla (5,5,5)
Dump of expression @ 0x2d75590, before conversion to prefix form:
	Language fortran, 19 elements, 16 bytes each.
	Index                Opcode         Hex Value  String Value
	    0          OP_VAR_VALUE  40  (...............
....
	   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
	   17             BINOP_MUL  3  ................
	   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x2d75590, after conversion to prefix form:
Expression: `vla_primitives::intvla (5, 5, 5)'
	Language fortran, 19 elements, 16 bytes each.

	    0  OP_F77_UNDETERMINED_ARGLIST  Number of args: 3
	    3    OP_VAR_VALUE          Block @0x297e1c0, symbol @0x297cd50 (intvla)
	    7    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
	   11    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
	   15    OP_LONG               Type @0x2976900 (int), value 5 (0x5)

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

	* expprint.c (print_subexp_standard): Handle
	OP_F77_UNDETERMINED_ARGLIST.
	(dump_subexp_body_standard): Likewise.
2018-02-06 17:12:12 +00:00
Yao Qi 583e3f9061 Fix up one ChangeLog entry date
The patch was committed on 5th Feb, and the first line of ChangeLog
entry is too long.  The max line length is 74.
https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog
2018-02-06 17:08:47 +00:00
Nick Clifton 46d09186d3 Improve the find_nearest_line function for the MIPS target so that it tries harder to find a function name.
PR 22789
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf
	functions failed to find the function name, try the generic elf
	find function instead.
2018-02-06 17:00:25 +00:00