Commit Graph

90150 Commits

Author SHA1 Message Date
Pedro Alves 53e710acd2 Fix PR c++/21323: GDB thinks char16_t and char32_t are signed in C++
While the C++ standard says that char16_t and char32_t are unsigned types:

 Types char16_t and char32_t denote distinct types with the same size,
 signedness, and alignment as uint_least16_t and uint_least32_t,
 respectively, in <cstdint>, called the underlying types.

... gdb treats them as signed currently:

 (gdb) p (char16_t)-1
 $1 = -1 u'\xffff'

There are actually two places in gdb that hardcode these types:

- gdbtypes.c:gdbtypes_post_init, when creating the built-in types,
  seemingly used by the "x /s" command (judging from commit 9a22f0d0).

- dwarf2read.c, when reading base types with DW_ATE_UTF encoding
  (which is what is used for these types, when compiling for C++11 and
  up).  Despite the comment, the type created does end up used.

Both places need fixing.  But since I couldn't tell why dwarf2read.c
needs to create a new type, I've made it use the per-arch built-in
types instead, so that the types are only created once per arch
instead of once per objfile.  That seems to work fine.

While writting the test, I noticed that the C++ language parser isn't
actually aware of these built-in types, so if you try to use them
without a program that uses them, you get:

 (gdb) set language c++
 (gdb) ptype char16_t
 No symbol table is loaded.  Use the "file" command.
 (gdb) ptype u"hello"
 No type named char16_t.
 (gdb) p u"hello"
 No type named char16_t.

That's fixed by simply adding a couple entries to C++'s built-in types
array in c-lang.c.  With that, we get the expected:

 (gdb) ptype char16_t
 type = char16_t
 (gdb) ptype u"hello"
 type = char16_t [6]
 (gdb) p u"hello"
 $1 = u"hello"

gdb/ChangeLog:
2017-04-12  Pedro Alves  <palves@redhat.com>

	PR c++/21323
	* c-lang.c (cplus_primitive_types) <cplus_primitive_type_char16_t,
	cplus_primitive_type_char32_t>: New enum values.
	(cplus_language_arch_info): Register cplus_primitive_type_char16_t
	and cplus_primitive_type_char32_t.
	* dwarf2read.c (read_base_type) <DW_ATE_UTF>: If bit size is 16 or
	32, use the archtecture's built-in type for char16_t and char32_t,
	respectively.  Otherwise, fallback to init_integer_type as before,
	but make the type unsigned, and issue a complaint.
	* gdbtypes.c (gdbtypes_post_init): Make char16_t and char32_t unsigned.

gdb/testsuite/ChangeLog:
2017-04-12  Pedro Alves  <palves@redhat.com>

	PR c++/21323
	* gdb.cp/wide_char_types.c: New file.
	* gdb.cp/wide_char_types.exp: New file.
2017-04-12 14:00:49 +01:00
Alan Hayward 5e0e042213 Fix Changelog for ab0538b875 2017-04-12 09:51:28 +01:00
Alan Hayward ab0538b875 Add M32R_ARG_REGISTER_SIZE
gdb/
	* m32r-tdep.c M32R_ARG_REGISTER_SIZE: Added.
	(m32r_push_dummy_call): Use M32R_ARG_REGISTER_SIZE.
2017-04-12 09:19:55 +01:00
Sergio Durigan Junior 5430098f18 Fix build breakage from last commit (window-nat.c:windows_create_inferior)
Forgot to declare the variable 'toexec' (from
window-nat.c:windows_create_inferior) as 'const char *', which caused
a build breakage.

gdb/ChangeLog:
2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>

	* windows-nat.c (windows_create_inferior): Declare 'toexec' as
	'const char *'.
2017-04-12 01:16:50 -04:00
Sergio Durigan Junior 7c5ded6a00 C++-fy and prepare for sharing fork_inferior
As a preparation for the next patch, which will move fork_inferior
from GDB to common/ (and therefore share it with gdbserver), it is
interesting to convert a few functions to C++.

This patch touches functions related to parsing command-line arguments
to the inferior (see gdb/fork-child.c:breakup_args), the way the
arguments are stored on fork_inferior (using std::vector instead of
char **), and the code responsible for dealing with argv also on
gdbserver.

I've taken this opportunity and decided to constify a few arguments to
fork_inferior/create_inferior as well, in order to make the code
cleaner.  And now, on gdbserver, we're using xstrdup everywhere and
aren't checking for memory allocation failures anymore, as requested
by Pedro:

  <https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html>
  Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com>

  Pedro Alves wrote:

  > On the "== NULL" check: IIUC, the old NULL check was there to
  > handle strdup returning NULL due to out-of-memory.
  > See NULL checks and comments further above in this function.
  > Now that you're using a std::vector, that doesn't work or make
  > sense any longer, since if push_back fails to allocate space for
  > its internal buffer (with operator new), our operator new replacement
  > (common/new-op.c) calls malloc_failure, which aborts gdbserver.
  >
  > Not sure it makes sense to handle out-of-memory specially in
  > the gdb/rsp-facing functions nowadays (maybe git blame/log/patch
  > submission for that code shows some guidelines).  Maybe (or, probably)
  > it's OK to stop caring about it, but then we should consistently remove
  > left over code, by using xstrdup instead and remove the NULL checks.

IMO this refactoring was very good to increase the readability of the
code as well, because some parts of the argument handling were
unnecessarily confusing before.

gdb/ChangeLog:
2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>

	* common/common-utils.c (free_vector_argv): New function.
	* common/common-utils.h: Include <vector>.
	(free_vector_argv): New prototype.
	* darwin-nat.c (darwin_create_inferior): Rewrite function
	prototype in order to constify "exec_file" and accept a
	"std::string" for "allargs".
	* fork-child.c: Include <vector>.
	(breakup_args): Rewrite function, using C++.
	(fork_inferior): Rewrite function header, constify "exec_file_arg"
	and accept "std::string" for "allargs".  Update the code to
	calculate "argv" based on "allargs".  Update calls to "exec_fun"
	and "execvp".
	* gnu-nat.c (gnu_create_inferior): Rewrite function prototype in
	order to constify "exec_file" and accept a "std::string" for
	"allargs".
	* go32-nat.c (go32_create_inferior): Likewise.
	* inf-ptrace.c (inf_ptrace_create_inferior): Likewise.
	* infcmd.c (run_command_1): Constify "exec_file".  Use
	"std::string" for inferior arguments.
	* inferior.h (fork_inferior): Update prototype.
	* linux-nat.c (linux_nat_create_inferior): Rewrite function
	prototype in order to constify "exec_file" and accept a
	"std::string" for "allargs".
	* nto-procfs.c (procfs_create_inferior): Likewise.
	* procfs.c (procfs_create_inferior): Likewise.
	* remote-sim.c (gdbsim_create_inferior): Likewise.
	* remote.c (extended_remote_run): Update code to accept
	"std::string" as argument.
	(extended_remote_create_inferior): Rewrite function prototype in
	order to constify "exec_file" and accept a "std::string" for
	"allargs".
	* rs6000-nat.c (super_create_inferior): Likewise.
	(rs6000_create_inferior): Likewise.
	* target.h (struct target_ops) <to_create_inferior>: Likewise.
	* windows-nat.c (windows_create_inferior): Likewise.

gdb/gdbserver/ChangeLog:
2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>

	* server.c: Include <vector>.
	<program_argv, wrapper_argv>: Convert to std::vector.
	(start_inferior): Rewrite function to use C++.
	(handle_v_run): Likewise.  Update code that calculates the argv
	based on the vRun packet; use C++.
	(captured_main): Likewise.
2017-04-12 01:02:03 -04:00
GDB Administrator ef6a5ae7bd Automatic date update in version.in 2017-04-12 00:00:43 +00:00
H.J. Lu e4097f5ee5 Remove the extra `\n' in warning/error messages
* elf-properties.c (_bfd_elf_parse_gnu_properties): Remove the
	extra `\n' in warning/error messages.
	* elf32-i386.c (elf_i386_parse_gnu_properties): Likewise.
	* elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise.
2017-04-11 15:41:00 -07:00
H.J. Lu 537616aaeb Ignore processor-specific GNU program properties
Skip processor-specific GNU program properties with generic ELF target
vector.  They should be handled by the matching ELF target vector.

	* elf-properties.c (_bfd_elf_parse_gnu_properties): Ignore
	processor-specific properties with generic ELF target vector.
2017-04-11 15:07:55 -07:00
Pedro Alves ae0eee4282 gdb/thread.c: Fix whitespace throughout
gdb/ChangeLog:
2017-04-11  Pedro Alves  <palves@redhat.com>

	* thread.c: Fix whitespace throughout.
2017-04-11 14:31:34 +01:00
Philipp Rudo a6acac0611 Fix read after xfree in linux-nat.c:linux_nat_detach
At the end of linux_nat_detach the main_lwp is deleted (delete_lwp).
This is problematic as during detach (detach_one_lwp and
linux_fork_detach) main_lwp already gets freed.  Thus calling
delete_lwp causes a read after free.  Fix it by removing the
unnecessary delete_lwp.

gdb/ChangeLog:
2017-04-11  Philipp Rudo  <prudo@linux.vnet.ibm.com>

	* linux-nat.c (linux_nat_detach): Remove delete_lwp call.
2017-04-11 14:28:51 +01:00
Alan Hayward 64403bd183 Remove MAX_REGISTER_SIZE from arm-tdep.c
gdb/
	* arm-tdep.c (arm_store_return_value): Use FP_REGISTER_SIZE
2017-04-11 13:51:58 +01:00
Alan Modra fbea15088d PR 21274, ld segfaults linking PE DLL
Don't use fixed size buffers for symbol names.

	PR 21274
	PR 18466
	* emultempl/pe.em (pe_find_data_imports): Don't use fixed size
	symbol buffer.  Instead, xmalloc max size needed with space for
	prefix.  Wrap overlong lines.  Formatting.  Pass symbol buffer
	copy of name to pe_walk_relocs_of_symbol.
	(make_inport_fixup): Add "name" param, pass to pe_create_import_fixup.
	* emultempl/pe.em (pep_find_data_imports): As for pe_find_data_imports.
	(make_import_fixup): Add "name" param, pass to pep_create_import_fixup.
	Use bfd_get_signed_* and remove unnecessary casts.  Formatting.
	* pe-dll.c (pe_walk_relocs_of_symbol): Add "name" param.  Pass to
	callback.
	(make_import_fixup_mark): Add "name" param.  Make use of prefix
	space rather than xmalloc here.
	(pe_create_import_fixup): Likewise.
	* pe-dll.h (pe_walk_relocs_of_symbol): Update prototype.
	(pe_create_import_fixup): Likewise.
	* pep-dll.h (pep_walk_relocs_of_symbol): Likewise.
	(pep_create_import_fixup): Likewise.
2017-04-11 19:49:13 +09:30
GDB Administrator b43c520dba Automatic date update in version.in 2017-04-11 00:00:28 +00:00
Alan Modra c03dc33b60 Reorder PPC_OPCODE_* and set PPC_OPCODE_TMR for e6500
PPC_OPCODE_* renumbered to fill the gaps left by previous patches,
and reordered chronologically just because.  I kept PPC_OPCODE_TMR
because presumably it might be used in future APUinfo for e6500.

include/
	* opcode/ppc.h (PPC_OPCODE_*): Renumber and order chronologically.
	(PPC_OPCODE_SPE): Comment on this and other bits used for APUinfo.
opcodes/
	* ppc-dis.c (ppc_opts): Formatting.  Set PPC_OPCODE_TMR for e6500.
	* ppc-opc.c (powerpc_opcodes <mftmr, mttmr>): Remove now
	unnecessary E6500.
2017-04-11 07:43:21 +09:30
Alan Modra ef85eab0ec Bye bye PPC_OPCODE_HTM and -mhtm
The -mhtm option is fairly useless too.

include/
	* opcode/ppc.h (PPC_OPCODE_HTM): Delete.
gas/
	* config/tc-ppc.c (md_show_usage): Delete mention of -mhtm.
	* testsuite/gas/ppc/htm.d: Pass -mpower8 and -Mpower8.
opcodes/
	* ppc-dis.c (ppc_opts): Remove PPC_OPCODE_HTM and "htm".
	* ppc-opc.c (PPCHTM): Define as PPC_OPCODE_POWER8.
2017-04-11 07:40:24 +09:30
Alan Modra 9570835e55 Bye Bye PPC_OPCODE_VSX3
This bit is also useless as it can be replaced with PPC_OPCODE_POWER9.
Defining the VSX2 and VSX3 selection based on cpu bits also lets the
assembler/disassembler distinguish between the power7 VSX opcodes and
the power8 ones.  Note that this change means -mvsx now reverts back
to just adding the power7 VSX insns.

include/
	* opcode/ppc.h (PPC_OPCODE_VSX3): Delete.
opcodes/
	* ppc-dis.c (ppc_opts): Remove PPC_OPCODE_VSX3.
	* ppc-opc.c (PPCVSX2): Define as PPC_OPCODE_POWER8.
	(PPCVSX3): Define as PPC_OPCODE_POWER9.
2017-04-11 07:36:43 +09:30
Alan Modra 9a85b496ac Bye bye PPC_OPCODE_ALTIVEC2
This bit is worse than useless.  Using it prevents the assembler and
disassembler distinguishing between opcodes added for power8 and those
added for power9.

include/
	* opcode/ppc.h (PPC_OPCODE_ALTIVEC2): Delete.
opcodes/
	* ppc-dis.c (ppc_opts): Remove PPC_OPCODE_ALTIVEC2.
	* ppc-opc.c (PPCVEC2): Define as PPC_OPCODE_POWER8|PPC_OPCODE_E6500.
	(PPCVEC3): Define as PPC_OPCODE_POWER9.
2017-04-11 07:33:50 +09:30
Sergio Durigan Junior a5bef50fdb Fix PR gdb/21364: Dead code due to an unreachable condition in osdata.c
Pedro's recent commits enabling -Wwrite-strings has changed a bit the
logic of info_osdata.  Now, 'type' is always non-NULL, so we have to
check if it's an empty string instead of NULL.  One of the checks was
fixed, but there is another that was left behind.  This commit fixes
it.

gdb/ChangeLog:
2017-04-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR gdb/21364
	* osdata.c (info_osdata): Check if 'type' is an empty string
	instead of NULL.
2017-04-10 12:43:44 -04:00
John Delsignor 28d909e539 Prevent a bigus warning from readelf about a gdb-index table being too big.
PR binutils/21319
	* dwarf.c (display_gdb_index): Correct test for a corrupt address
	table size.
2017-04-10 16:27:05 +01:00
Nick Clifton a70f34c01c Document undocumented linker command line options.
ld 	* ld.texinfo (--strip-discarded): Document.
	(--embedded-relocs): Document.
	(--spare-dynamic-tags): Document.
	(--task-link): Document.
2017-04-10 15:59:59 +01:00
Pedro Alves 9295a5a95d thread.c: ptid_equal -> operator==
gdb/ChangeLog:
2017-04-10  Pedro Alves  <palves@redhat.com>

	* thread.c (add_thread_silent, delete_thread_1, find_thread_ptid)
	(ptid_to_global_thread_id, in_thread_list)
	(do_captured_list_thread_ids, set_resumed, set_running)
	(set_executing, set_stop_requested, finish_thread_state)
	(validate_registers_access, can_access_registers_ptid)
	(print_thread_info_1, switch_to_thread)
	(do_restore_current_thread_cleanup)
	(make_cleanup_restore_current_thread, thread_command)
	(thread_name_command): Use operator== instead of ptid_equal.
2017-04-10 15:54:57 +01:00
Pedro Alves 996812e3d4 GC gdb/thread.c:current_thread_cleanup_chain
Commit 803bdfe430 ("Don't delete
thread_info if refcount isn't zero") eliminated
restore_current_thread_ptid_changed, so current_thread_cleanup_chain
is no longer necessary either.

gdb/ChangeLog:
2017-04-10  Pedro Alves  <palves@redhat.com>

	* thread.c (struct current_thread_cleanup) <next>: Delete field.
	(current_thread_cleanup_chain): Delete.
	(restore_current_thread_cleanup_dtor)
	(make_cleanup_restore_current_thread): Remove references to
	current_thread_cleanup_chain.
2017-04-10 15:18:49 +01:00
Alan Hayward 845b344fd5 msp430: Don't use REG_UNKNOWN
gdb/
	* msp430-tdep.c (msp430_pseudo_register_read): Never return
	REG_UNKNOWN.
2017-04-10 15:01:53 +01:00
Yao Qi 803bdfe430 Don't delete thread_info if refcount isn't zero
I build GDB with asan, and run test case hook-stop.exp, and threadapply.exp,
I got the following asan error,

=================================================================^M
^[[1m^[[31m==2291==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000999c4 at pc 0x000000826022 bp 0x7ffd28a8ff70 sp 0x7ffd28a8ff60^M
^[[1m^[[0m^[[1m^[[34mREAD of size 4 at 0x6160000999c4 thread T0^[[1m^[[0m^M
    #0 0x826021 in release_stop_context_cleanup ../../binutils-gdb/gdb/infrun.c:8203^M
    #1 0x72798a in do_my_cleanups ../../binutils-gdb/gdb/common/cleanups.c:154^M
    #2 0x727a32 in do_cleanups(cleanup*) ../../binutils-gdb/gdb/common/cleanups.c:176^M
    #3 0x826895 in normal_stop() ../../binutils-gdb/gdb/infrun.c:8381^M
    #4 0x815208 in fetch_inferior_event(void*) ../../binutils-gdb/gdb/infrun.c:4011^M
    #5 0x868aca in inferior_event_handler(inferior_event_type, void*) ../../binutils-gdb/gdb/inf-loop.c:44^M
....
^[[1m^[[32m0x6160000999c4 is located 68 bytes inside of 568-byte region [0x616000099980,0x616000099bb8)^M
^[[1m^[[0m^[[1m^[[35mfreed by thread T0 here:^[[1m^[[0m^M
    #0 0x7fb0bc1312ca in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x982ca)^M
    #1 0xb8c62f in xfree(void*) ../../binutils-gdb/gdb/common/common-utils.c:100^M
    #2 0x83df67 in free_thread ../../binutils-gdb/gdb/thread.c:207^M
    #3 0x83dfd2 in init_thread_list() ../../binutils-gdb/gdb/thread.c:223^M
    #4 0x805494 in kill_command ../../binutils-gdb/gdb/infcmd.c:2595^M
....

Detaching from program: /home/yao.qi/SourceCode/gnu/build-with-asan/gdb/testsuite/outputs/gdb.threads/threadapply/threadapply, process 2399^M
=================================================================^M
^[[1m^[[31m==2387==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000a98c0 at pc 0x00000083fd28 bp 0x7ffd401c3110 sp 0x7ffd401c3100^M
^[[1m^[[0m^[[1m^[[34mREAD of size 4 at 0x6160000a98c0 thread T0^[[1m^[[0m^M
    #0 0x83fd27 in thread_alive ../../binutils-gdb/gdb/thread.c:741^M
    #1 0x844277 in thread_apply_all_command ../../binutils-gdb/gdb/thread.c:1804^M
....
^M
^[[1m^[[32m0x6160000a98c0 is located 64 bytes inside of 568-byte region [0x6160000a9880,0x6160000a9ab8)^M
^[[1m^[[0m^[[1m^[[35mfreed by thread T0 here:^[[1m^[[0m^M
    #0 0x7f59a7e322ca in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x982ca)^M
    #1 0xb8c62f in xfree(void*) ../../binutils-gdb/gdb/common/common-utils.c:100^M
    #2 0x83df67 in free_thread ../../binutils-gdb/gdb/thread.c:207^M
    #3 0x83dfd2 in init_thread_list() ../../binutils-gdb/gdb/thread.c:223^M

This patch fixes the issue by deleting thread_info object if it is
deletable, otherwise, mark it as exited (by set_thread_exited).
Function set_thread_exited is shared from delete_thread_1.  This patch
also moves field "refcount" to private and methods incref and
decref.  Additionally, we stop using "ptid_t" in
"struct current_thread_cleanup" to reference threads, instead we use
"thread_info" directly.  Due to this change, we don't need
restore_current_thread_ptid_changed anymore.

gdb:

2017-04-10  Yao Qi  <yao.qi@linaro.org>

	PR gdb/19942
	* gdbthread.h (thread_info::deletable): New method.
	(thread_info::incref): New method.
	(thread_info::decref): New method.
	(thread_info::refcount): Move it to private.
	* infrun.c (save_stop_context): Call inc_refcount.
	(release_stop_context_cleanup): Likewise.
	* thread.c (set_thread_exited): New function.
	(init_thread_list): Delete "tp" only it is deletable, otherwise
	call set_thread_exited.
	(delete_thread_1): Call set_thread_exited.
	(current_thread_cleanup) <inferior_pid>: Remove.
	<thread>: New field.
	(restore_current_thread_ptid_changed): Removed.
	(do_restore_current_thread_cleanup): Adjust.
	(restore_current_thread_cleanup_dtor): Don't call
	find_thread_ptid.
	(set_thread_refcount): Use dec_refcount.
	(make_cleanup_restore_current_thread): Adjust.
	(thread_apply_all_command): Call inc_refcount.
	(_initialize_thread): Don't call
	observer_attach_thread_ptid_changed.
2017-04-10 14:39:41 +01:00
Yao Qi 8c25b49760 Hoist code on marking thread as exited
This patch hoists code on marking thread as exited, so more code is shared
for two different paths (thread_info is deleted or is not deleted).

gdb:

2017-04-10  Yao Qi  <yao.qi@linaro.org>

	* thread.c (delete_thread_1): Hoist code on marking thread as
	exited.
2017-04-10 14:39:41 +01:00
Max Filippov 947fa91414 gas: xtensa: fix incorrect code generated with auto litpools
* config/tc-xtensa.c (xtensa_maybe_create_literal_pool_frag):
	Initialize lps->frag_count with auto_litpool_limit.
	(xg_promote_candidate_litpool): New function.
	(xtensa_move_literals): Extract candidate litpool promotion code
	into separate function. Call it for all possible found
	candidates.
	(xtensa_switch_to_literal_fragment): Drop 'recursive' flag and
	call to xtensa_mark_literal_pool_location that it guards.
	Replace it with call to xtensa_maybe_create_literal_pool_frag.
	Initialize pool_location with created literal pool candidate.
	* testsuite/gas/xtensa/all.exp: Add new tests.
	* testsuite/gas/xtensa/auto-litpools-first1.d: New test results.
	* testsuite/gas/xtensa/auto-litpools-first1.s: New test.
	* testsuite/gas/xtensa/auto-litpools-first2.d: New test results.
	* testsuite/gas/xtensa/auto-litpools-first2.s: New test.
	* testsuite/gas/xtensa/auto-litpools.d: Fix offsets changed due
	to additional jump instruction.
2017-04-10 13:12:52 +01:00
Qing Zhao bb1dd176fb Port the bug fix for PR 19704 (Missing dynamic relocation against undefined weak symbol) to the SPARC architecture.
* elf32-sparc.c (elf_backend_fixup_symbol): New.
        * elf64-sparc.c (elf_backend_fixup_symbol): New.
        * elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): New.
        (_bfd_sparc_elf_link_hash_entry): Add has_got_reloc and
        has_non_got_reloc.
        (link_hash_newfunc): Initialize has_got_reloc and
	has_non_got_reloc.
        (_bfd_sparc_elf_size_dynamic_sections): Set interp to .interp
        section.
        (_bfd_sparc_elf_copy_indirect_symbol): Copy has_got_reloc and
        has_non_got_reloc.
        (_bfd_sparc_elf_check_relocs): Set has_got_reloc and
        has_non_got_reloc.
        (_bfd_sparc_elf_fixup_symbol): New function.
        (allocate_dynrelocs): Don't allocate space for dynamic
        relocations and discard relocations against resolved undefined
        weak symbols in executable.  Don't make resolved undefined weak
        symbols in executable dynamic.  Keep dynamic non-GOT/non-PLT
        relocation against undefined weak symbols in PIE.
        (_bfd_sparc_elf_relocate_section): Don't generate dynamic
        relocations against resolved undefined weak symbols in PIE
        (_bfd_sparc_elf_finish_dynamic_symbol): Keep PLT/GOT entries
        without ynamic PLT/GOT relocations for resolved undefined weak
        symbols.
        Don't generate dynamic relocation against resolved undefined
        weak symbol in executable.
        (pie_finish_undefweak_symbol): New function.
        (_bfd_sparc_elf_finish_dynamic_sections): Call
        pie_finish_undefweak_symbol on all symbols in PIE.
        * elfxx-sparc.h (_bfd_sparc_elf_link_hash_table): Add interp.
        (_bfd_sparc_elf_fixup_symbol): New function.
2017-04-10 12:46:30 +01:00
Nick Clifton d236cfd444 Remove the ns32k target from the obsolete list.
* config.bfd: Remove ns32k from obsolete list.
2017-04-10 11:38:21 +01:00
Alan Modra 62adc51030 Tidy ppc476 opcodes
PPC_OPCODE_440 being set for ppc476 meant that many opcodes needed to
be deprecated for ppc476.  There are far fewer to add specially for
ppc476 if PPC_OPCODE_440 is not set for ppc476.

	* ppc-dis.c (ppc_opts <476>): Remove PPC_OPCODE_440.
	* ppc-opc.c (MULHW): Add PPC_OPCODE_476.
	(powerpc_opcodes): Adjust PPC440, PPC464 and PPC476 insns to suit
	removal of PPC_OPCODE_440 from ppc476 cpu selection bits.
2017-04-10 15:35:11 +09:30
Alan Modra 6f9dbcd42f PR21287, Inconsistent section type for .init_array and .init_array.42
PR21287 notes that .init_array is correctly given a type of
SHT_INIT_ARRAY while .init_array.nnn gets SHT_PROGBITS.  This patch
fixes that problem, and properly drops warnings from the compiler that
would cause the testsuite to fail.  My a44d0bd78 change to check
ld_compile status, necessary to pick up compile errors, also meant
warnings were not ignored.

bfd/
	PR 21287
	* elf.c (special_sections_f): Match .fini_array and .fini_array.*.
	(special_sections_i): Likewise for .init_array.
	(special_sections_p): Likewise for .preinit_array.
ld/
	PR 21287
	* testsuite/ld-elf/init-fini-arrays.d: Match INIT_ARRAY and FINI_ARRAY.
	* testsuite/ld-elf/init-fini-arrays.s: Use %init_array and %fini_array
	section types.
	* testsuite/lib/ld-lib.exp (default_ld_compile): Trim assembler
	warnings about "ignoring incorrect section type".
	(run_ld_link_exec_tests, run_cc_link_tests): Delete old comment.
2017-04-10 15:11:35 +09:30
Alan Modra 37095d07b4 Clean elfvsb files left over from previous runs
My mips-linux and mips64-linux testsuite runs have been failing a
bunch of visibility tests, seemingly randomly.  It turns out the
problem occurs when object files are left over in ld/tmpdir from a
previous run.

	* testsuite/ld-elfvsb/elfvsb.exp (visibility_run): Delete
	sh1p.o, sh2p.o, sh1np.o and sh2np.o before compiling.  Use
	remote_file host exists rather than file exists.
2017-04-10 15:10:58 +09:30
Pip Cet aa80870703 WebAssembly disassembler support
* wasm32-dis.c (print_insn_wasm32): Avoid DECIMAL_DIG, specify
	appropriate floating-point precision directly.
2017-04-10 13:51:45 +09:30
Simon Marchi 8473b4472d windows-nat.c: Fix bad initialization of ptid
When trying to build for x86_64-w64-mingw32:

/home/simark/src/binutils-gdb/gdb/windows-nat.c: In function ‘void windows_detach(target_ops*, const char*, int)’:
/home/simark/src/binutils-gdb/gdb/windows-nat.c:1915:20: error: converting to ‘ptid_t’ from initializer list would use explicit constructor ‘constexpr ptid_t::ptid_t(int, long int, long int)’
   ptid_t ptid = {-1};
                    ^
Fixed by initializing ptid with the minus_one_ptid variable.

gdb/ChangeLog:

	* windows-nat.c (windows_detach): Initialize ptid with
	minus_one_ptid.
2017-04-09 23:14:57 -04:00
GDB Administrator 4a44171e07 Automatic date update in version.in 2017-04-10 00:00:37 +00:00
GDB Administrator 5e8bf44f4c Automatic date update in version.in 2017-04-09 00:00:35 +00:00
Jim Wilson b630840c9c Add support for fcvtl and fcvtl2.
sim/aarch64/
	* simulator.c (do_vec_FCVTL): New.
	(do_vec_op1): Call do_vec_FCVTL.

	sim/testsuite/sim/aarch64/
	* fcvtl.s: New.
2017-04-08 12:08:20 -07:00
Jim Wilson ae27d3fe76 Support the fcmXX zero instructions.
sim/aarch64/
	* simulator.c (do_scalar_FCMGE_zero): New.
	(do_scalar_FCMLE_zero, do_scalar_FCMGT_zero, do_scalar_FCMEQ_zero)
	(do_scalar_FCMLT_zero): Likewise.
	(do_scalar_vec): Add calls to new functions.

	sim/testsuite/sim/aarch64/
	* fcmXX.s: New.
2017-04-08 07:10:38 -07:00
GDB Administrator aebcde5eb4 Automatic date update in version.in 2017-04-08 00:00:33 +00:00
H.J. Lu a7eaf017f9 Use NOPIE_CFLAGS and NOPIE_LDFLAGS to disable PIE
Since not all compilers support -no-pie, NOPIE_CFLAGS and NOPIE_LDFLAGS
should be used to disable PIE.

	PR ld/21090
	* testsuite/ld-x86-64/x86-64.exp (undefined_weak): Use
	NOPIE_CFLAGS and NOPIE_LDFLAGS to disable PIE for the non-pie
	version of the test.
2017-04-07 08:53:43 -07:00
H.J. Lu 8170f7693b ELF: Check ELF_COMMON_DEF_P for common symbols
Since common symbols that are turned into definitions don't have the
DEF_REGULAR flag set, we need to check ELF_COMMON_DEF_P for common
symbols.

bfd/

	PR ld/19579
	PR ld/21306
	* elf32-s390.c (elf_s390_finish_dynamic_symbol): Check
	ELF_COMMON_DEF_P for common symbols.
	* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
	* elflink.c (_bfd_elf_merge_symbol): Revert commits
	202ac193bb and
	07492f668d.

ld/

	PR ld/19579
	PR ld/21306
	* testsuite/ld-elf/pr19579a.c (main): Updated.
2017-04-07 07:40:14 -07:00
Simon Marchi 6670ec1372 ptid-selftests: Fix erroneous assert messages
gdb/ChangeLog:

	* unittests/ptid-selftests.c: Fix erroneous assert messages.
2017-04-07 10:28:56 -04:00
Pedro Alves 49f4617bf4 Fix building the BFD library for Win64 by reqorking the find_separate_debug_file interface.
* opncls.c (bfd_get_debug_link_info): Rename to...
	(bfd_get_debug_link_info_1): ... this.  Change type of second
	parameter to void pointer.  Adjust.
	(bfd_get_debug_link_info): Reimplement on top of
	bfd_get_debug_link_info_1.
	(separate_debug_file_exists, separate_alt_debug_file_exists):
	Change type of second parameter to void pointer.  Adjust.
	(get_func_type, check_func_type): Change type of second parameter
	to void pointer.
	(find_separate_debug_file): Add 'func_data' parameter.  Pass it to
	the callback functions instead of passing the address of a local.
	(bfd_follow_gnu_debuglink): Pass address of unsigned long local to
	find_separate_debug_file.
	(get_alt_debug_link_info_shim): Change type of second parameter to
	void pointer.  Adjust.
	(bfd_follow_gnu_debugaltlink): Adjust to pass NULL to
	find_separate_debug_file.
	(get_build_id_name, bfd_boolean check_build_id_file): Change type
	of second parameter to void pointer.  Adjust.
	(bfd_follow_build_id_debuglink): Pass address of bfd_build_id
	pointer local to find_separate_debug_file.
2017-04-07 14:51:42 +01:00
Nick Clifton ae3f8c2813 Fix failure in x86_64 linker tests when compiling with a PIE enabled compiler.
PR 21090
	* testsuite/ld-x86-64/x86-64.exp (undefined_weak): Explicitly
	disable PIE for the non-pie version of the test.
2017-04-07 11:48:08 +01:00
Alan Modra ac8f0f721b Remove E6500 insns from PPC_OPCODE_ALTIVEC2
This isn't losing anything from the testsuite.  All of these insns
appear in testsuite/gas/ppc/e6500.s

opcodes/
	* ppc-opc.c (powerpc_opcodes <mviwsplt, mvidsplt, lvexbx, lvepxl,
	lvexhx, lvepx, lvexwx, stvexbx, stvexhx, stvexwx, lvtrx, lvtlx,
	lvswx, stvfrx, stvflx, stvswx, lvsm, stvepxl, lvtrxl, stvepx,
	lvtlxl, lvswxl, stvfrxl, stvflxl, stvswxl>): Enable E6500 only
	vector instructions with E6500 not PPCVEC2.
gas/
	* testsuite/gas/ppc/altivec2.s: Delete E6500 vector insns.
	* testsuite/gas/ppc/altivec2.d: Adjust to suit.
2017-04-07 18:24:38 +09:30
Alan Modra 5c1f54ce0b Tweak MBIND ld test for ARM.
* testsuite/ld-elf/mbind2a.s: Don't use @, the ARM comment char.
2017-04-07 18:24:38 +09:30
Alan Modra 498e34425b MBIND gas test tweak
score-elf aligns text sections.

	* testsuite/gas/elf/section12a.d: Don't expect alignment of 1
	for .mbind.text.
2017-04-07 18:24:38 +09:30
Alan Hayward ba2f91bb5d Add BFIN_MAX_REGISTER_SIZE
gdb/
	* bfin-tdep.c (BFIN_MAX_REGISTER_SIZE): Add.
	(bfin_pseudo_register_read): Use BFIN_MAX_REGISTER_SIZE.
	(bfin_pseudo_register_write): Likewise
2017-04-07 09:31:37 +01:00
Tristan Gingold 1fd6d11190 pe/coff: handle weak defined symbol for gc-sections.
bfd/
	* coffgen.c (_bfd_coff_gc_mark_hook): Handle PE weak
	external symbols with a definition.
	(_bfd_coff_gc_mark_extra_sections): Fix typo.

ld/
	* testsuite/ld-pe/pe.exp: New test.
	* testsuite/ld-pe/weakdef-1.s: New test source.
	* testsuite/ld-pe/weakdef-1.d: New test.
2017-04-07 10:03:17 +02:00
Simon Marchi 436252de3e Class-ify ptid_t
I grew a bit tired of using ptid_get_{lwp,pid,tid} and friends, so I decided to
make it a bit easier to use by making it a proper class.  The fields are now
private, so it's not possible to change a ptid_t field by mistake.

The new methods of ptid_t map to existing functions/practice like this:

  ptid_t (pid, lwp, tid) -> ptid_build (pid, lwp, tid)
  ptid_t (pid) -> pid_to_ptid (pid)
  ptid.is_pid () -> ptid_is_pid (ptid)
  ptid == other -> ptid_equal (ptid, other)
  ptid != other -> !ptid_equal (ptid, other)
  ptid.pid () -> ptid_get_pid (ptid)
  ptid.lwp_p () -> ptid_lwp_p (ptid)
  ptid.lwp () -> ptid_get_lwp (ptid)
  ptid.tid_p () -> ptid_tid_p (ptid)
  ptid.tid () -> ptid_get_tid (ptid)
  ptid.matches (filter) -> ptid_match (ptid, filter)

I've replaced the implementation of the existing functions with calls to
the new methods.  People are encouraged to gradually switch to using the
ptid_t methods instead of the functions (or we can change them all in
one pass eventually).

Also, I'm not sure if it's worth it (because of ptid_t's relatively
small size), but I have made the functions and methods take ptid_t
arguments by const reference instead of by value.

gdb/ChangeLog:

	* common/ptid.h (struct ptid): Change to...
	(class ptid_t): ... this.
	<ptid_t>: New constructors.
	<pid, lwp_p, lwp, tid_p, tid, is_pid, operator==, operator!=,
	matches>: New methods.
	<make_null, make_minus_one>: New static methods.
	<pid>: Rename to...
	<m_pid>: ...this.
	<lwp>: Rename to...
	<m_lwp>: ...this.
	<tid>: Rename to...
	<m_tid>: ...this.
	(ptid_build, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal,
	ptid_is_pid, ptid_lwp_p, ptid_tid_p, ptid_match): Take ptid arguments
	as references, move comment to class ptid_t.
	* common/ptid.c (null_ptid, minus_one_ptid): Initialize with
	ptid_t static methods.
	(ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_tid,
	ptid_equal, ptid_is_pid, ptid_lwp_p, ptid_tid_p, ptid_match):
	Take ptid arguments as references, implement using ptid_t methods.
	* unittests/ptid-selftests.c: New file.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/ptid-selftests.c.
	(SUBDIR_UNITTESTS_OBS): Add unittests/ptid-selftests.o.

gdb/gdbserver/ChangeLog:

	* server.c (handle_v_cont): Initialize thread_resume::thread
	with null_ptid.
2017-04-06 23:29:53 -04:00
GDB Administrator 1379e3aaea Automatic date update in version.in 2017-04-07 00:00:35 +00:00