]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
6 years agoFix a memory access violation when attempting to parse a corrupt COFF binary with... users/ARM/embedded-binutils-master-2017q4 users/ARM/embedded-gdb-master-2017q4
Nick Clifton [Tue, 28 Nov 2017 13:20:31 +0000 (13:20 +0000)] 
Fix a memory access violation when attempting to parse a corrupt COFF binary with a relocation that points beyond the end of the section to be relocated.

PR 22506
* reloc.c (reloc_offset_in_range): Rename to
bfd_reloc_offset_in_range and export.
(bfd_perform_relocation): Rename function invocation.
(bfd_install_relocation): Likewise.
(bfd_final_link_relocate): Likewise.
* bfd-in2.h: Regenerate.
* coff-arm.c (coff_arm_reloc): Use bfd_reloc_offset_in_range.
* coff-i386.c (coff_i386_reloc): Likewise.
* coff-i860.c (coff_i860_reloc): Likewise.
* coff-m68k.c (mk68kcoff_common_addend_special_fn): Likewise.
* coff-m88k.c (m88k_special_reloc): Likewise.
* coff-mips.c (mips_reflo_reloc): Likewise.
* coff-x86_64.c (coff_amd64_reloc): Likewise.

6 years agoELF: Don't set non_ir_ref_regular in check_relocs
H.J. Lu [Tue, 28 Nov 2017 12:54:35 +0000 (04:54 -0800)] 
ELF: Don't set non_ir_ref_regular in check_relocs

Since elf_link_add_object_symbols sets non_ir_ref_regular now, there is
no need to set non_ir_ref_regular in check_relocs.

Tested on i686 and x86-64.

* elf-m10300.c (mn10300_elf_check_relocs): Don't set
non_ir_ref_regular.
* elf32-arm.c (elf32_arm_check_relocs): Likewise.
* elf32-bfin.c (bfin_check_relocs): Likewise.
* elf32-cr16.c (cr16_elf_check_relocs): Likewise.
* elf32-cris.c (cris_elf_check_relocs): Likewise.
* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
* elf32-frv.c (elf32_frv_check_relocs): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-i370.c (i370_elf_check_relocs): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
* elf32-m32c.c (m32c_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
* elf32-metag.c (elf_metag_check_relocs): Likewise.
* elf32-microblaze.c (microblaze_elf_check_relocs): Likewise.
* elf32-moxie.c (moxie_elf_check_relocs): Likewise.
* elf32-msp430.c (elf32_msp430_check_relocs): Likewise.
* elf32-mt.c (mt_elf_check_relocs): Likewise.
* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-rl78.c (rl78_elf_check_relocs): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-aarch64.c (elf64_aarch64_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
* elf64-ia64-vms.c (elf64_ia64_check_relocs): Likewise.
* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-sh64.c (sh_elf64_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
* elfnn-ia64.c (elfNN_ia64_check_relocs): Likewise.
* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.

6 years agoPR22471, undefined reference to linker-defined symbols
Alan Modra [Mon, 27 Nov 2017 03:10:43 +0000 (13:40 +1030)] 
PR22471, undefined reference to linker-defined symbols

This patch processes linker script assignment statements before ld
opens DT_NEEDED libraries, in order to define symbols like __bss_start
that might also be defined by a library, falsely triggering an error
about "DSO missing from command line".

The initial value won't be correct when assigning a symbol from dot,
and I make no attempt to handle all expressions.  For example, an
assignment like "_start_foo = ADDR (.foo)" isn't valid until sections
are laid out, so won't define _start_foo early.  What's here should be
enough for most common scripts, and hopefully won't perturb fragile
scripts.

bfd/
PR 22471
* elflink.c (_bfd_elf_merge_symbol): Allow weak symbols to override
early passes over linker script symbols.
* linker.c (_bfd_generic_link_add_one_symbol): Allow symbols to
override early passes over linker script symbols.  Clear ldscript_def
on symbol definitions.
ld/
PR 22471
* ldexp.c (struct definedness_hash_entry): Delete "by_script".  Make
"iteration" an 8-bit field, and update mask in all uses.
(definedness_newfunc): Don't init "by_script".
(update_definedness): Test ldscript_def rather than by_script.
(is_sym_value): Likewise.
(fold_name <DEFINED>): Return a result for first phase.  Test
ldscript_def.
(fold_name <NAME>): Return a result for first phase.
* ldlang.c (open_input_bfds): Process all assignments, not just
defsym.
(lang_process): Increment lang_statement_iteration before
open_input_bfds.
* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Adjust for larger .dynsym.
* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.

6 years agoCopying symbol type in ld script assignments
Alan Modra [Mon, 27 Nov 2017 08:13:03 +0000 (18:43 +1030)] 
Copying symbol type in ld script assignments

There is a call to update_definedness between code that evaluates an
assignment expression value and code that transfers symbol
attributes.  When script assignment expressions contain DEFINED, that
can mean the wrong symbol type is copied.  This patch tracks symbols
read during expression evaluation, rather than examining the
expression and re-evaluating conditionals.  Not only does this
simplify the code, it also means ld can now copy symbol types in more
complex expressions.

An unfortunate side effect of copying symbol type for more complex
expressions affects mmix, which uses
 PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.));
in a default script.  So now _start or _start. symbol type may be
copied, losing the function type specially set up for Main.  This can
be avoided by making bfd_copy_link_hash_symbol_type do nothing for
mmix.

bfd/
* elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
ld/
* ldexp.h (struct ldexp_control): Add "assign_src".
* ldexp.c (fold_trinary): Save and restore assign_src around
condition evaluation.
(fold_name <NAME>): Set expld.assign_src.
(try_copy_symbol_type): Delete.
(exp_fold_tree_1): Set symbol type using expld.assign_src.

6 years agold: Set non_ir_ref_regular on symbols referenced in regular objects
H.J. Lu [Tue, 28 Nov 2017 11:48:25 +0000 (03:48 -0800)] 
ld: Set non_ir_ref_regular on symbols referenced in regular objects

If linker plugin is enabled, set non_ir_ref_regular on symbols referenced
in regular objects so that linker plugin will get the correct symbol
resolution.

bfd/

PR ld/22502
* elflink.c (_bfd_elf_merge_symbol): Also skip definition from
an IR object.
(elf_link_add_object_symbols): If linker plugin is enabled, set
non_ir_ref_regular on symbols referenced in regular objects so
that linker plugin will get the correct symbol resolution.

ld/

PR ld/22502
* testsuite/ld-plugin/lto.exp: Run PR ld/22502 test.
* testsuite/ld-plugin/pr22502a.c: New file.
* testsuite/ld-plugin/pr22502b.c: Likewise.

6 years agoCompress loads/stores with implicit 0 offset.
Jim Wilson [Tue, 28 Nov 2017 03:20:53 +0000 (19:20 -0800)] 
Compress loads/stores with implicit 0 offset.

gas/
* config/tc-riscv.c (riscv_handle_implicit_zero_offset): New.
(riscv_ip): Cases 'k', 'l', 'm', 'n', 'M', 'N', add call to
riscv_handle_implicit_zero_offset.  At label load_store, replace
existing code with call to riscv_handle_implicit_zero_offset.
* testsuite/gas/riscv/c-ld.d, testsuite/gas/riscv/c-ld.s: New.
* testsuite/gas/riscv/c-lw.d, testsuite/gas/riscv/c-lw.s: New.
* testsuite/gas/riscv/riscv.exp: Run new tests.

6 years agoFix symbol values and relocation addends for relocatable links.
Cary Coutant [Tue, 28 Nov 2017 01:32:55 +0000 (17:32 -0800)] 
Fix symbol values and relocation addends for relocatable links.

The fix for PR 19291 broke some other cases where -r is used with scripts,
as reported in PR 22266. The original fix for PR 22266 ended up breaking
many cases for REL targets, where the addends are stored in the section data,
and are not being adjusted properly.

The problem was basically that in a relocatable output file (ET_REL),
symbol values are supposed to be relative to the start address of their
section. Usually in a relocatable file, all sections start at 0, so the
failure to get this right is often irrelevant, but with a linker script,
we occasionally see an output section whose starting address is not 0,
and gold would occasionally write a symbol with its relocated value instead
of its section-relative value.

This patch reverts the recent fix for PR 22266 as well as my original fix
for PR 19291. The original fix moved the symbol value adjustment to
write_local_symbols, but neglected to undo a few places where the adjustment
was also being applied, resulting in an occasional double adjustment. The
more recent fix removed those other adjustments, but then failed to
re-account for the adjustment when rewriting the relocations on REL targets.

With the old attempts reverted, we now apply the symbol value adjustment to
the one case that had been missed (non-section symbols in merge sections).
But now we also need to account for the adjustment when rewriting the addends
for RELA relocations.

gold/
PR gold/19291
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.  Adjust symbol value in
relocatable links for non-section symbols.
(Sized_relobj_file::compute_final_local_value): Revert changes from
2017-11-08 patch.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
(Sized_relobj_file::write_local_symbols): Revert changes from
2015-11-25 patch.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.
* powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
relocatable links.
* target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
* testsuite/pr22266_a.c (hello): New function.
* testsuite/pr22266_main.c (main): Add test for merge sections.
* testsuite/pr22266_script.t: Add rule for .rodata.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Nov 2017 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRemove REMOTE_OBS
Tom Tromey [Thu, 23 Nov 2017 03:57:04 +0000 (20:57 -0700)] 
Remove REMOTE_OBS

This removes REMOTE_OBS from the Makefile.  It is no longer needed, as
remote support is always built into gdb.  The relevant sources are now
added to COMMON_SFILES, where they are treated like other ordinary
sources.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (REMOTE_OBS): Remove.
(SFILES): Remove remote sources.
(COMMON_SFILES): Add remote sources.
(ALLDEPFILES): Remove dcache.c.

6 years agoMove target object files to target subdirectory
Tom Tromey [Tue, 21 Nov 2017 21:29:59 +0000 (14:29 -0700)] 
Move target object files to target subdirectory

Move the object files corresponding to target/*.c to the target
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_TARGET_SRCS, SUBDIR_TARGET_OBS): New
variables.
(SFILES): Use SUBDIR_TARGET_SRCS.
(COMMON_OBS): Use SUBDIR_TARGET_OBS.  Remove waitstatus.o.
(CONFIG_SRC_SUBDIR): Add target.
(%.o): Remove target rule.

6 years agoAdd missing files to COMMON_SFILES
Tom Tromey [Tue, 21 Nov 2017 21:24:29 +0000 (14:24 -0700)] 
Add missing files to COMMON_SFILES

While working on the previous patch, I found a few .o files whose
corresponding .c file was not mentioned in Makefile.in.  This patch
fixes the problem.  I pulled this out separately to make it simpler to
review.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (COMMON_OBS): Remove filename-seen-cache.o,
registry.o, thread-fsm.o, debug.o.
(COMMON_SFILES): Add filename-seen-cache.c, registry.c,
thread-fsm.c, debug.c.

6 years agoSimplify COMMON_OBS by using list of sources
Tom Tromey [Tue, 21 Nov 2017 21:19:27 +0000 (14:19 -0700)] 
Simplify COMMON_OBS by using list of sources

This introduces a new COMMON_SFILES variable, and then defines some of
COMMON_OBS in terms of this new variable.  This simpifies adding a new
ordinary source file.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (COMMON_SFILES): New.
(SFILES): Move some entries to COMMON_SFILES.
(COMMON_OBS): Use COMMON_SFILES.

6 years agoDefine YYOBJ in terms of YYFILES
Tom Tromey [Tue, 21 Nov 2017 20:44:11 +0000 (13:44 -0700)] 
Define YYOBJ in terms of YYFILES

Change YYOBJ to be defined in terms of YYFILES.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (YYFILES): Update comment.
(YYOBJ): Redefine.

6 years agoMove python object files to python subdirectory
Tom Tromey [Tue, 21 Nov 2017 20:17:31 +0000 (13:17 -0700)] 
Move python object files to python subdirectory

Move the object files corresponding to python/*.c to the python
subdirectory in the build tree.

Because special CFLAGS are passed just to Python compilations, this
patch also required the addition of a pattern rule to update
INTERNAL_CFLAGS for here.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_PYTHON_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add python.
(%.o): Remove python rule.
(python/%.o): New rule.
* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to python/python.o

6 years agoMove guile object files to guile subdirectory
Tom Tromey [Tue, 21 Nov 2017 20:05:26 +0000 (13:05 -0700)] 
Move guile object files to guile subdirectory

Move the object files corresponding to guile/*.c to the guile
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to guile/guile.o.
* Makefile.in (SUBDIR_GUILE_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add guile.
(%.o): Remove guile rule.

6 years agoMove unittests object files to unittests subdirectory
Tom Tromey [Tue, 21 Nov 2017 19:56:55 +0000 (12:56 -0700)] 
Move unittests object files to unittests subdirectory

Move the object files corresponding to unittests/*.c to the unittests
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_UNITTESTS_OBS): Redefine.
(%.o): Remove unittests rule.
(CONFIG_SRC_SUBDIR): Add unittests.

6 years agoMove tui object files to tui subdirectory
Tom Tromey [Tue, 21 Nov 2017 19:42:33 +0000 (12:42 -0700)] 
Move tui object files to tui subdirectory

Move the object files corresponding to tui/*.c to the tui subdirectory
in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_TUI_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add tui.
(%.o): Remove tui rule.

6 years agoMove compile object files to compile subdirectory
Tom Tromey [Tue, 21 Nov 2017 19:35:05 +0000 (12:35 -0700)] 
Move compile object files to compile subdirectory

Move the object files corresponding to compile/*.c to the compile
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_GCC_COMPILE_OBS): Redefine.
(%.o): Remove compile rule.
(CONFIG_SRC_SUBDIR): Add compile.

6 years agoMove mi objects to mi subdirectory
Tom Tromey [Tue, 21 Nov 2017 19:26:11 +0000 (12:26 -0700)] 
Move mi objects to mi subdirectory

Move object files corresponding to mi/*.c to a subdirectory in the
build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_MI_OBS): Redefine.
(%.o): Remove mi rule.
(CONFIG_SRC_SUBDIR): Add mi.
(COMMON_OBS): Use mi/mi-common.o

6 years agoMove cli object files to cli subdirectory
Tom Tromey [Tue, 21 Nov 2017 19:22:11 +0000 (12:22 -0700)] 
Move cli object files to cli subdirectory

Following the "arch" move, this moves the object files corresponding
to the cli/*.c source files to the "cli" build directory.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* Makefile.in (SUBDIR_CLI_OBS): Redefine.
(%.o): Remove cli rule.
(CONFIG_SRC_SUBDIR): Add cli.

6 years agoA simpler way to make the "arch" build directory
Tom Tromey [Tue, 21 Nov 2017 19:15:33 +0000 (12:15 -0700)] 
A simpler way to make the "arch" build directory

This implements a simpler way to make the "arch" build directory --
namely, now it is done as an order-only dependency in the Makefile,
rather than being created when config.status is run.  This simpler
because it means that the build directories can be changed without
re-running autoconf.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

* configure.ac (CONFIG_SRC_SUBDIR): Don't subst.
* configure: Rebuild.
* Makefile.in (CONFIG_SRC_SUBDIR): Redefine.
(CONFIG_DEP_SUBDIR): New variable.
(%.o): Add order-only dependency.
($(CONFIG_DEP_SUBDIR)): New target.

6 years agogas: xtensa: speed up find_trampoline_seg
Max Filippov [Mon, 20 Nov 2017 14:35:06 +0000 (06:35 -0800)] 
gas: xtensa: speed up find_trampoline_seg

find_trampoline_seg takes noticeable time when assembling source with
many sections. Cache the result of the most recent search and check it
first. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (find_trampoline_seg): Add static variable
that caches the result of the most recent search.

6 years agogas: xtensa: implement trampoline coalescing
Max Filippov [Tue, 14 Nov 2017 23:16:08 +0000 (15:16 -0800)] 
gas: xtensa: implement trampoline coalescing

There is a recurring pattern in assembly files generated by a compiler
where a lot of jumps in a function are going to the same place. When
these jumps are relaxed with trampolines the assembler generates a
separate jump thread from each source.
Create an index of trampoline jump targets for each segment and see if a
jump being relaxed goes to a location from that index, in which case
replace its target with a location of existing trampoline jump that
results in the shortest path to the original target.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain)
(trampoline_chain_index): New structures.
(trampoline_index): Add chain_index field.
(xg_order_trampoline_chain_entry, xg_sort_trampoline_chain)
(xg_find_chain_entry, xg_get_best_chain_entry)
(xg_order_trampoline_chain, xg_get_trampoline_chain)
(xg_find_best_eq_target, xg_add_location_to_chain)
(xg_create_trampoline_chain, xg_get_single_symbol_slot): New
functions.
(xg_relax_fixups): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump. Call
xg_create_trampoline_chain to create new jump target. Call
xg_add_location_to_chain to add newly created trampoline jump
to the corresponding chain.
(add_jump_to_trampoline): Extract loop searching for a single
slot with a symbol into a separate function, replace that code
with a call to that function.
(relax_frag_immed): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump.
* testsuite/gas/xtensa/all.exp: Add trampoline-2 test.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as many duplicate trampoline chains are now coalesced.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.
* testsuite/gas/xtensa/trampoline-2.l: New test result file.
* testsuite/gas/xtensa/trampoline-2.s: New test source file.

6 years agogas: xtensa: reuse trampoline placement code
Max Filippov [Mon, 13 Nov 2017 08:42:43 +0000 (00:42 -0800)] 
gas: xtensa: reuse trampoline placement code

There's almost exact copy of the trampoline placement code in the
search_trampolines function that is used for jumps generated for relaxed
branch instructions. Get rid of the duplication and reuse
xg_find_best_trampoline function for that.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (search_trampolines, get_best_trampoline):
Remove definitions.
(xg_find_best_trampoline_for_tinsn): New function.
(relax_frag_immed): Replace call to get_best_trampoline with a
call to xg_find_best_trampoline_for_tinsn.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines for relaxed branches has been
changed.

6 years agogas: xtensa: rewrite xg_relax_trampoline
Max Filippov [Sat, 11 Nov 2017 12:15:55 +0000 (04:15 -0800)] 
gas: xtensa: rewrite xg_relax_trampoline

Replace linked list of trampoline frags with an ordered array, so that
instead of indexing fixups trampolines could be indexed. Keep each array
in the trampoline_seg structure, so there's no need to rebuild it for
every new processed segment. Don't run relaxation for each trampoline
frag, instead run it for each fixup in the current segment that needs
relaxation at the beginning of each relaxation pass. This way the
complexity of this process drops from about O(n^2 * m) to about
O(log n * m), where n is the number of trampoline frags and m is the
number of fixups that need relaxation in the segment.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (trampoline_index): New structure.
(trampoline_seg): Replace trampoline list with trampoline index.
(xg_find_trampoline, xg_add_trampoline_to_index)
(xg_remove_trampoline_from_index, xg_add_trampoline_to_seg)
(xg_is_trampoline_frag_full, xg_get_fulcrum)
(xg_find_best_trampoline, xg_relax_fixup, xg_relax_fixups)
(xg_is_relaxable_fixup): New functions.
(J_MARGIN): New macro.
(xtensa_create_trampoline_frag): Use xg_add_trampoline_to_seg
instead of open-coded addition to the linked list.
(dump_trampolines): Iterate through the trampoline_seg::index.
(cached_fixupS, cached_fixup, fixup_cacheS, fixup_cache)
(fixup_order, xtensa_make_cached_fixup)
(xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups)
(xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup)
(xtensa_add_cached_fixup, check_and_update_trampolines): Remove
definitions.
(xg_relax_trampoline): Extract logic into separate functions,
replace body with a call to xg_relax_fixups.
(search_trampolines): Replace search in linked list with search
in index. Change data type of address-tracking variables from
int to offsetT. Replace abs with labs.
(xg_append_jump): Finish the trampoline frag if it's full.
(add_jump_to_trampoline): Remove trampoline frag from the index
if the frag is full.
* config/tc-xtensa.h (xtensa_frag_type): Remove next_trampoline.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines has slightly changed.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.

6 years agogas: xtensa: merge trampoline_frag into xtensa_frag_type
Max Filippov [Fri, 10 Nov 2017 22:27:42 +0000 (14:27 -0800)] 
gas: xtensa: merge trampoline_frag into xtensa_frag_type

The split between fragS and trampoline_frag doesn't save much space, but
makes trampolines management much more awkward. Merge trampoline_frag
data into the xtensa_frag_type, which is a part of fragS. No functional
changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (init_trampoline_frag): Replace pointer to
struct trampoline_frag parameter with pointer to fragS.
(xg_append_jump): Remove jump_around parameter.
(struct trampoline_frag): Remove.
(struct trampoline_seg): Change type of trampoline_list from
struct trampoline_frag to fragS.
(xtensa_create_trampoline_frag): Don't allocate struct
trampoline_frag. Initialize new fragS::tc_frag_data fields.
(dump_trampolines, xg_relax_trampoline, search_trampolines)
(get_best_trampoline, init_trampoline_frag)
(add_jump_to_trampoline, relax_frag_immed): Replace pointer to
struct trampoline_frag with a pointer to fragS.
(xg_append_jump): Remove jump_around parameter, use
fragS::tc_frag_data.jump_around_fix instead.
(xg_relax_trampoline, init_trampoline_frag)
(add_jump_to_trampoline): Don't pass jump_around parameter to
xg_append_jump.
* config/tc-xtensa.h (struct xtensa_frag_type): Add new fields:
needs_jump_around, next_trampoline and jump_around_fix.

6 years agogas: xtensa: reuse find_trampoline_seg
Max Filippov [Fri, 10 Nov 2017 21:38:23 +0000 (13:38 -0800)] 
gas: xtensa: reuse find_trampoline_seg

xtensa_create_trampoline_frag has opencoded fragment equivalent to
find_trampoline_seg. Drop the fragment and use find_trampoline_seg
instead. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (find_trampoline_seg): Move above the first
use.
(xtensa_create_trampoline_frag): Replace trampoline seg search
code with a call to find_trampoline_seg.

6 years agogas: xtensa: extract jump assembling for trampolines
Max Filippov [Thu, 9 Nov 2017 22:51:18 +0000 (14:51 -0800)] 
gas: xtensa: extract jump assembling for trampolines

init_trampoline_frag, add_jump_to_trampoline and xg_relax_trampoline add
a jump to the end of a trampoline frag. Extract it into a separate
funciton and use it in all these places. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (xg_append_jump): New function.
(xg_relax_trampoline, init_trampoline_frag)
(add_jump_to_trampoline): Replace trampoline jump assembling
code with a call to xg_append_jump.

6 years agogas: extract xg_relax_trampoline from xtensa_relax_frag
Max Filippov [Fri, 20 Oct 2017 23:23:28 +0000 (16:23 -0700)] 
gas: extract xg_relax_trampoline from xtensa_relax_frag

To make measurement and changes easier extract trampoline relaxation
function. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (xg_relax_trampoline): New function.
(xtensa_relax_frag): Replace trampoline relaxation code with a
call to xg_relax_trampoline.

6 years agofix two issues in gdb.ada/mi_catch_ex.exp (re: "exception-message")
Joel Brobecker [Mon, 27 Nov 2017 19:38:54 +0000 (11:38 -0800)] 
fix two issues in gdb.ada/mi_catch_ex.exp (re: "exception-message")

The following patch introduced a new feature related to Ada exception
catchpoints:

    commit e547c119d043f2ecffb70452020ab9150d083a91
    Author: Joel Brobecker <brobecker@adacore.com>
    Date:   Fri Nov 24 17:09:42 2017 -0500
    Subject: (Ada) provide the exception message when hitting an exception catchpoint

Unfortunately, the patch left 2 errors in gdb.ada/mi_catch_ex.exp,
both inside the "continue_to_exception" function:

  1. The exception message on the console can include the exception
     message, and thus this patch adjust the expected output in
     the corresponding gdb_expect call to allow it;
     to allow it.

  2. There was a TCL syntax confusion in "$exception_name(..."
     that caused TCL to evaluate "exception_name as an array,
     rather than as a variable. This patch fixes this by escaping
     the '(' (and the corresponding closing parenthesis, for
     consistency).

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_catch_ex.exp (continue_to_exception): Adjust
        expected output in gdb_expect call to allow the exception
        message to be present as well.  Fix syntax confusion to avoid
        TCL thinking that exception_name is an array.

Tested on x86_64-linux, with:

    DejaGnu version  1.6
    Expect version   5.45
    Tcl version      8.6

6 years ago[PR ld/22263] aarch64: Avoid dynamic TLS relocs in PIE
Szabolcs Nagy [Wed, 15 Nov 2017 17:40:04 +0000 (17:40 +0000)] 
[PR ld/22263] aarch64: Avoid dynamic TLS relocs in PIE

No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.

Fixes
FAIL: Build pr22263-1

bfd/
PR ld/22263
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Use
bfd_link_executable instead of bfd_link_pic for TLS.
(elfNN_aarch64_allocate_dynrelocs): Likewise.
(aarch64_can_relax_tls): Likewise.

6 years ago[PR ld/22269] aarch64: Handle local undefined weak symbols
Szabolcs Nagy [Wed, 15 Nov 2017 15:56:30 +0000 (15:56 +0000)] 
[PR ld/22269] aarch64: Handle local undefined weak symbols

With static pie linking undefined weak symbols are forced to resolve locally
to 0, so no GOT setup is needed in elfNN_aarch64_finish_dynamic_symbol,
which previously failed for these symbols.

The failure caused the unhelpful error message:
"ld: final link failed: Nonrepresentable section on output"

bfd/
PR ld/22269
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Use
UNDEFWEAK_NO_DYNAMIC_RELOC to avoid dynamic GOT relocs.
(elfNN_aarch64_allocate_dynrelocs): Likewise.

6 years agoUpdate the simplified Chinese translation of the messages in the opcodes library.
Nick Clifton [Mon, 27 Nov 2017 11:14:38 +0000 (11:14 +0000)] 
Update the simplified Chinese translation of the messages in the opcodes library.

* po/zh_CN.po: Updated simplified Chinese translation.

6 years agoFix a seg-fault when displaying notes from a prorgam segment. Check for a NULL strin...
Nick Clifton [Mon, 27 Nov 2017 11:05:39 +0000 (11:05 +0000)] 
Fix a seg-fault when displaying notes from a prorgam segment.  Check for a NULL string section before attempting compute the name of a separate debug info file.

PR 22490
* readelf.c (dump_section_as_bytes): Check for a NULL string
section pointer.
(process_notes_at): Compute the alignment to use if displaying
notes from a segment.

6 years agoWhen creating a .note section to contain a version note, set the section alignment...
Nick Clifton [Mon, 27 Nov 2017 11:04:17 +0000 (11:04 +0000)] 
When creating a .note section to contain a version note, set the section alignment to 4 bytes.

PR 22492
* config/obj-elf.c (obj_elf_version): Set the alignment of the
.note section.

6 years agoUpdate find command help and search memory docs
Dominik Czarnota [Mon, 27 Nov 2017 03:42:18 +0000 (22:42 -0500)] 
Update find command help and search memory docs

This patch updates the `find` command help and docs description to show
how to search for not null terminated strings when current language's
strings includes it.

gdb/ChangeLog:

PR gdb/21945
* findcmd.c (_initialize_mem_search): Update find command help
text.

gdb/doc/ChangeLog:

PR gdb/21945
* gdb.texinfo (Search Memory): Update description and example
about how to search a string without NULL terminator.

6 years agopython: Fix memleak in do_start_initialization
Simon Marchi [Mon, 27 Nov 2017 00:32:47 +0000 (19:32 -0500)] 
python: Fix memleak in do_start_initialization

While playing with valgrind, I noticed that with Python 3, the progname
variable in do_start_initialization is not being freed (concat returns a
malloc'ed string).  This patch uses unique_xmalloc_ptr to manage it.
With Python 2, we pass progname it directly to Py_SetProgramName, so it
should not be freed.  We therefore release it before passing it.

gdb/ChangeLog:

* python/python.c (do_start_initialization): Change progname
type to gdb::unique_xmalloc_ptr.  Release the pointer when using
Python 2.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Nov 2017 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAdd include guards to common/format.h
Tom Tromey [Wed, 22 Nov 2017 16:37:05 +0000 (09:37 -0700)] 
Add include guards to common/format.h

This adds include guards to common/format.h.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

* common/format.h: Add include guards.

6 years agoRename argument name from link to xlink
H.J. Lu [Sun, 26 Nov 2017 18:12:35 +0000 (10:12 -0800)] 
Rename argument name from link to xlink

This fixed the build with GCC 4.2:

cc1: warnings being treated as errors
binutils-gdb/binutils/dwarf.c: In function â€˜load_separate_debug_info’:
binutils-gdb/binutils/dwarf.c:9650: warning: declaration of â€˜link’ shadows a global declaration
/usr/include/unistd.h:757: warning: shadowed declaration is here

* dwarf.c (load_separate_debug_info): Rename argument name from
link to xlink.

6 years agoChange maybe_disable_address_space_randomization to a class
Tom Tromey [Wed, 22 Nov 2017 16:30:21 +0000 (09:30 -0700)] 
Change maybe_disable_address_space_randomization to a class

This changes maybe_disable_address_space_randomization to be an RAII
class, rather than having it return a cleanup.

Regression tested by the buildbot.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

* nat/linux-personality.h (class
maybe_disable_address_space_randomization): New class.
(maybe_disable_address_space_randomization): Don't declare
function.
* nat/linux-personality.c (restore_personality)
(make_disable_asr_cleanup): Remove.
(maybe_disable_address_space_randomization): Now a constructor.
(~maybe_disable_address_space_randomization): New destructor.
* linux-nat.c (linux_nat_create_inferior): Update.

gdbserver/ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

* linux-low.c (linux_create_inferior): Update.

6 years agoRemoves a cleanup from gcore.c
Tom Tromey [Fri, 10 Nov 2017 00:15:37 +0000 (17:15 -0700)] 
Removes a cleanup from gcore.c

This removes a cleanup from gcore.c, replacing it with
unique_xmalloc_ptr.

Regression tested by the buildbot.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

* gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.

6 years agogas: Update x86 sse-noavx tests
H.J. Lu [Sun, 26 Nov 2017 16:28:25 +0000 (08:28 -0800)] 
gas: Update x86 sse-noavx tests

This fixed:

FAIL: i386 SSE without AVX equivalent
FAIL: x86-64 SSE without AVX equivalent
FAIL: x86-64 (ILP32) SSE without AVX equivalent

on x86-64.

* testsuite/gas/i386/sse-noavx.s: Add tests for fisttps and
fisttpl.
* testsuite/gas/i386/x86-64-sse-noavx.s: Likewise.
* testsuite/gas/i386/ilp32/x86-64-sse-noavx.d: Updated.
* testsuite/gas/i386/sse-noavx.d: Likewise.
* testsuite/gas/i386/x86-64-sse-noavx.d: Likewise.

6 years agoFix broken ChangeLog entry for last commit.
Ulrich Weigand [Sun, 26 Nov 2017 16:29:00 +0000 (17:29 +0100)] 
Fix broken ChangeLog entry for last commit.

6 years ago[spu] Fix various test cases
Ulrich Weigand [Sun, 26 Nov 2017 16:19:57 +0000 (17:19 +0100)] 
[spu] Fix various test cases

The SPU-specific test cases were not modified to use standard_output_file
and therefore all were no longer being executed.  Fixing this exposed a
few other bugs in spu-info noticed by using a more recent compiler, which
are also fixed here.

gdb/testsuite/ChangeLog:
2017-11-26  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.arch/spu-info.c: Include <unistd.h>.
(do_signal_test): Fix broken calls to write.
* gdb.arch/spu-info.exp: Use prepare_for_testing.
Fix checks for empty mailboxes.  Update signal tests for corrected
do_signal_test routine.  Allow nonzero event status.

6 years ago[spu] Fix single-stepping regression
Ulrich Weigand [Sun, 26 Nov 2017 16:15:25 +0000 (17:15 +0100)] 
[spu] Fix single-stepping regression

Switching spu_software_single_step to use a regcache instead of a frame:
https://sourceware.org/ml/gdb-patches/2016-11/msg00355.html
cause a serious regression to SPU single-stepping.

There were two separate problems:
- SPU_LSLR_REGNUM is a pseudo register, so we must use the "cooked"
  regcache methods instead of the "raw" ones to access it.
- When accessing a branch target register, we must only use the first
  four bytes of the 16-byte vector register.  This was done automatically
  by the frame routines, but not by the regcache routines.

gdb/ChangeLog:
2017-11-26  Ulrich Weigand  <uweigand@de.ibm.com>

* spu-tdep.c (spu_software_single_step): Access SPU_LSLR_REGNUM as
"cooked" register.  Access only first four bytes of branch target
registers.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Nov 2017 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAdding ChangeLog entry for the last commit.
Sergio Durigan Junior [Sat, 25 Nov 2017 15:57:58 +0000 (10:57 -0500)] 
Adding ChangeLog entry for the last commit.

6 years agoFix PR gdb/22491: Regression when setting SystemTap probe semaphores
Sergio Durigan Junior [Sat, 25 Nov 2017 06:13:03 +0000 (01:13 -0500)] 
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores

Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface.  The failure is
kind of cryptic:

 77 break -pstap bar
 78 Breakpoint 3 at 0x40048d
 79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
 80 continue
 81 Continuing.
 82
 83 Program received signal SIGILL, Illegal instruction.
 84 main () at amd64-stap-optional-prefix.S:26
 85 26              STAP_PROBE1(probe, foo, (%rsp))

It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.

In the end, this was a mistake that was introduced during the review
process of the patch.  When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address).  This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.

I am pushing this patch to correct the mistake.

On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here.  However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed.  I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed.  Oh, well.

2017-11-25  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.

6 years agoUse TOLOWER in SYMBOL_HASH_NEXT
Pedro Alves [Sat, 25 Nov 2017 00:33:05 +0000 (00:33 +0000)] 
Use TOLOWER in SYMBOL_HASH_NEXT

The support for setting breakpoint in functions with ABI tags patch
will add a use of SYMBOL_HASH_NEXT in cp-support.c, which fails to
compile with:

  src/gdb/cp-support.c:38:0:
  src/gdb/cp-support.c: In function â€˜unsigned int cp_search_name_hash(const char*)’:
  src/gdb/../include/safe-ctype.h:148:20: error: â€˜do_not_use_tolower_with_safe_ctype’ was not declared in this scope
   #define tolower(c) do_not_use_tolower_with_safe_ctype
      ^
  src/gdb/minsyms.h:174:18: note: in expansion of macro â€˜tolower’
     ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
    ^
  src/gdb/cp-support.c:1677:14: note: in expansion of macro â€˜SYMBOL_HASH_NEXT’
 hash = SYMBOL_HASH_NEXT (hash, *string);
^

This fixes the problem before it happens.

I was somewhat worried about whether this might have an impact with
languages that are case insensitive, but I convinced myself that it
doesn't.  As bonus, this improves GDB's minsym interning performance a
bit (3%-10%).  See
<https://sourceware.org/ml/gdb/2017-11/msg00021.html>.

gdb/ChangeLog:
2017-11-25  Pedro Alves  <palves@redhat.com>

* dictionary.c: Include "safe-ctype.h".
* minsyms.c: Include "safe-ctype.h".
* minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower.

6 years agoFix completing an empty string
Pedro Alves [Sat, 25 Nov 2017 00:20:31 +0000 (00:20 +0000)] 
Fix completing an empty string

Earlier while working on the big completer rework series, I managed to
break

 (gdb) [TAB]

locally, and make GDB crash, but only notice a few weeks down the
road, because we have no test for that...

I also noticed that:

 (gdb)     [TAB]

didn't work (didn't show all commands as matches), even though
entering a command with leading whitespace works:

 (gdb)     help

This commit fixes the latter and adds a testcase that covers both
issues.

The gdb.base/completion.exp change is necessary because the new test
has a file name that also starts with "gdb.base/complet", making that
particular test ambiguous.  Adding another letter disambiguates.

gdb/ChangeLog:
2017-11-25   Pedro Alves  <palves@redhat.com>

* completer.c (complete_line_internal_1): Skip spaces until the
start of the command.

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

* gdb.base/complete-empty.exp: New file.
* gdb.base/completion.exp: Adjust.

6 years agoAdd comprehensive C++ operator linespec/location/completion tests
Pedro Alves [Sat, 25 Nov 2017 00:09:25 +0000 (00:09 +0000)] 
Add comprehensive C++ operator linespec/location/completion tests

This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc.  Particularly, makes sure all that
works without quoting.

Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)

Grows the gdb.linespec/ tests like this:

 -# of expected passes           3464
 +# of expected passes           7823

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

* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Nov 2017 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoComprehensive C++ linespec/completer tests
Pedro Alves [Fri, 24 Nov 2017 23:41:12 +0000 (23:41 +0000)] 
Comprehensive C++ linespec/completer tests

Exercises all sorts of aspects fixed by previous patches, going back a
few months.

 - Exercises label completion, linespecs and explicit locations.

 - Exercises both quoting vs non-quoting, source filenames, function
   names, labels, with both linespecs and explicit locations.

 - Tests corner cases around not-quoting function names, and
   whitespace and/and completing inside a parameter or template
   argument list, anonymous namespace awareness, etc.

   E.g.,

     "break foo<[TAB]"          -> "break foo<int>()"
     "break bar ( int[TAB]"     -> "break bar ( int)
     "break ( anon"             -> "break ( anonymous namespace)::func()"
     "b cfunc() [tab]"          -> "b cfunc() const"
     "b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"

   ... and others.

 - Tests the "b source.c[TAB] -> b source.cc:" feature.  I.e., colon
   auto-appending.

 - Exercises corner cases around C++ "operator<" / "operator<<".
   (Much more extensive C++ operator completion/linespec handling in a
   separate patch.)

 - Exercises both tab completion and "complete" command completion,
   using routines that handle it automatically, to ensure no test
   forgets either mode.

 - Many of the completion tests test completion at at prefix of a
   given tricky name, to make sure all corner cases are covered.
   E.g., completing before, at and after ":", "(", "<".

 - Exercises "keyword" completion.  I.e., "b function() [TAB]"
   displaying "if task thread" as completion match list.  Likewise for
   display explicit location options matches at the appropriate
   points.

 - Ensures that the completer finds the same breakpoint locations that
   setting a breakpoint finds.

 - Tests that linespec/location completion doesn't find data symbols.

 - Tests that expression completion still kicks in after a
   linespec/location keyword.  I.e., this:

     "b function () if global1 + global[TAB]"

   knows that after "if", you're completing on an expression, and thus
   breaks words after "if" as an expression and matches on "global" as
   a data symbol.

 - Adds common routines to help with all the above, to be used by
   multiple completion and linespec/location test cases.

 - More...

Grows the gdb.linespec/ tests like this:

  -# of expected passes           573
  +# of expected passes           3464

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

* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp.  Adjust
test to use test_gdb_complete_unique.  Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.

6 years agoMake strcmp_iw NOT ignore whitespace in the middle of tokens
Pedro Alves [Fri, 24 Nov 2017 23:30:04 +0000 (23:30 +0000)] 
Make strcmp_iw NOT ignore whitespace in the middle of tokens

currently "b func tion" manages to set a breakpoint at "function" !

All these years I had never noticed this, but now that the linespec
completer actually works, this easily happens by accident, with:

  "b func t<tab>"

expecting to get "thread", but getting instead:

  "b func tion"

...

Also, this:

  "b rettypefunc<int>"

manages to set a breakpoint on "rettype func<int>()".

These things happen due to strcmp_iw "magic".

Fix it by teaching strcmp_iw about when can it skip whitespace.  This
required handling user-defined operators, and scope operators,
complicating the code a bit, unfortunately.  I added unit tests for
all the corner cases I stumbled on, as I was developing this, and then
in the end wrote a testsuite testcase covering many of the same things
and more (to be added later).

gdb/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

* cp-support.c (cp_symbol_name_matches_1): New, factored out from
cp_fq_symbol_name_matches.  Pass language_cplus to
strncmp_with_mode.
(cp_fq_symbol_name_matches): Call cp_symbol_name_matches_1.
(selftests::test_cp_symbol_name_cmp): New.
(_initialize_cp_support): Register "cp_symbol_name_matches"
selftests.
* language.c (default_symbol_name_matcher): Pass language_minimal
to strncmp_iw_with_mode.
* utils.c: Include "cp-support.h" and <algorithm>.
(valid_identifier_name_char, cp_skip_operator_token, skip_ws)
(cp_is_operator): New functions.
(strncmp_iw_with_mode): Use them.  Add language parameter.  Don't
skip whitespace in the symbol name when the lookup name doesn't
have spaces, and vice versa.
(strncmp_iw, strcmp_iw): Pass language to strncmp_iw_with_mode.
* utils.h (strncmp_iw_with_mode): Add language parameter.

6 years agoRe-apply "elf: Properly compute offsets of note descriptor and next note"
H.J. Lu [Fri, 24 Nov 2017 22:49:36 +0000 (14:49 -0800)] 
Re-apply "elf: Properly compute offsets of note descriptor and next note"

CORE PT_NOTE segments may have p_align values of 0 or 1.  gABI specifies
that PT_NOTE alignment should be aligned to 4 bytes for 32-bit objects
and to 8 bytes for 64-bit objects.  If segment alignment is less than 4,
we use 4 byte alignment.

6 years ago(Ada) provide the exception message when hitting an exception catchpoint
Joel Brobecker [Fri, 24 Nov 2017 22:09:42 +0000 (17:09 -0500)] 
(Ada) provide the exception message when hitting an exception catchpoint

This patch enhances the debugger to print the exception message, when
available, as part of an exception catchpoint hit notification (both
GDB/CLI and GDB/MI). For instance, with the following code...

    procedure A is
    begin
       raise Constraint_Error with "hello world";
    end A;

... instead of printing...

    Catchpoint 1, CONSTRAINT_ERROR at 0x000000000040245c in a () at a.adb:3

... it now prints:

    Catchpoint 1, CONSTRAINT_ERROR (hello world) at 0x000000000040245c in a ()
                                   ^^^^^^^^^^^^^

This enhancement requires runtime support. If not present, the debugger
just behaves as before.

In GDB/MI mode, if the exception message is available, it is provided
as an extra field named "exception-message" in the catchpoint notification:

    *stopped,bkptno="1",[...],exception-name="CONSTRAINT_ERROR",
       exception-message="hello world",[...]

gdb/ChangeLog:

        * ada-lang.c (ada_exception_message_1, ada_exception_message):
        New functions.
        (print_it_exception): If available, display the exception
        message as well.
        * NEWS: Document new feature.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Ada Exception Information): Document
        new "exception-message" field.

gdb/testsuite/ChangeLog:

        * gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp,
        gdb.ada/mi_ex_cond.exp: Accept optional exception message in
        when hitting an exception catchpoint.

6 years agoFix issues with gdb-memory-map.dtd
Simon Marchi [Fri, 24 Nov 2017 22:10:25 +0000 (17:10 -0500)] 
Fix issues with gdb-memory-map.dtd

While writing a unit test for parse_memory_map, I tried to validate my
test input against gdb-memory-map.dtd, and found a few problems with it.
This doesn't influence how gdb parses it (AFAIK it doesn't use the
linked dtd), but if you edit the xml file in an editor that supports
dtds, you'll get plenty of errors.

  - The <memory-map> element accepts exactly one <memory> OR <property>
    as a child.  This is a problem because you can't have multiple
    <memory> elements and you shouldn't be able to have <property> elements
    as direct children of <memory-map>.
  - The <memory> element wants exactly one <property> child.  This is
    wrong, since you could have zero or more (even though we only
    support one kind of property currently).
  - I have no idea wht the device attribute of <memory> is, GDB doesn't
    read that.  I searched back in time a bit but couldn't find a trace
    of it.

I took the opportunity to tighten what is accepted as a value of the
memory type and property name attributes.  We currently accept any
string, but we can restrict them to the values GDB really accepts (and
which are documented).

AFAIK, this "file" only exists in the documentation, in gdb.texinfo, so
this is what I modified.  However, it's also available at
http://sourceware.org/gdb/gdb-memory-map.dtd.  This one should be
updated too, but I don't know how that should be done.

gdb/doc/ChangeLog:

* gdb.texinfo (Memory Map Format): Update gdb-memory-map.dtd.

6 years ago[spu] Fix spu-linux gdbserver build
Ulrich Weigand [Fri, 24 Nov 2017 21:04:41 +0000 (22:04 +0100)] 
[spu] Fix spu-linux gdbserver build

Fix a typo in a newly added argument name.

gdb/ChangeLog:
2017-11-24  Ulrich Weigand  <uweigand@de.ibm.com>

* spu-low.c (spu_create_inferior): Fix typo in argument name.

6 years ago[spu] Fix spu-linux native build
Ulrich Weigand [Fri, 24 Nov 2017 21:03:28 +0000 (22:03 +0100)] 
[spu] Fix spu-linux native build

Add missing file to NATDEPFILES.

gdb/ChangeLog:
2017-11-24  Ulrich Weigand  <uweigand@de.ibm.com>

* configure.nat <spu-linux>: Add fork-inferior.o to NATDEPFILES.

6 years agoRevert "elf: Properly compute offsets of note descriptor and next note"
Simon Marchi [Fri, 24 Nov 2017 20:41:23 +0000 (15:41 -0500)] 
Revert "elf: Properly compute offsets of note descriptor and next note"

This reverts commit 650444eb540f9fd85e821567a3f943b4bc41b8be.

With this patch, running the GDB test case gdb.base/auxv.exp is stuck in
an infinite loop, consuming memory to the point that it renders the
machine unusable. I am reverting it so we can take our time to
investigate while not killing all the developers' machines.

6 years agoAdd reference to implicit use in _bfd_elf_is_local_label_name.
Jim Wilson [Fri, 24 Nov 2017 17:31:59 +0000 (09:31 -0800)] 
Add reference to implicit use in _bfd_elf_is_local_label_name.

gas/
* write.h (FAKE_LABEL_CHAR): Expand comment.

6 years agoUpdate PR ld/21562 tests for underscore targets
H.J. Lu [Fri, 24 Nov 2017 16:58:43 +0000 (08:58 -0800)] 
Update PR ld/21562 tests for underscore targets

We also need to provide __start_scnfoo and __stop_scnfoo with the extra
leading underscore for underscore targets.

This patch fixed:

FAIL: ld-elf/pr21562k
FAIL: ld-elf/pr21562l
FAIL: ld-elf/pr21562m
FAIL: ld-elf/pr21562n

for metag-linux,

* testsuite/ld-elf/pr21562c.t: Also provide ___start_scnfoo and
___stop_scnfoo.
* testsuite/ld-elf/pr21562d.t: Likewise.

6 years agoWorkaround build bug with GCC 6.2.1
Philipp Rudo [Fri, 24 Nov 2017 10:05:57 +0000 (11:05 +0100)] 
Workaround build bug with GCC 6.2.1

Building GDB with GCC 6.2.1 gives multiple errors like

gdb/dtrace-probe.c: In member function â€˜void dtrace_probe::build_arg_exprs(gdbarch*)’:
gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror]
    for (struct dtrace_probe_arg &arg : m_args

Fix it by removing the 'struct' keyword.

A similar Bug was already fixed for GCC 6.3.1
https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html

gdb/ChangeLog:

* dtrace-probe.c (dtrace_probe::build_arg_exprs)
(dtrace_probe::is_enabled, dtrace_probe::enable)
(dtrace_probe::disable): Remove keyword 'struct' at for-range
variable
* probe.c (gen_ui_out_table_header_info)
(print_ui_out_not_applicables):  Remove keyword 'struct' at
for-range variable

6 years agoFix aarch64-none-elf build error
Alan Hayward [Fri, 24 Nov 2017 15:54:57 +0000 (15:54 +0000)] 
Fix aarch64-none-elf build error

gdb/
* configure.tgt: Add arch/aarch64.o

6 years agoPoison XNEW and friends for types that should use new/delete
Simon Marchi [Fri, 24 Nov 2017 15:42:01 +0000 (10:42 -0500)] 
Poison XNEW and friends for types that should use new/delete

This patch (finally!) makes it so that trying to use XNEW with a type
that requires "new" will cause a compilation error.  The criterion I
initially used to allow a type to use XNEW (which calls malloc in the
end) was std::is_trivially_constructible, but then realized that gcc 4.8
did not have it.  Instead, I went with:

  using IsMallocatable = std::is_pod<T>;

which is just a bit more strict, which doesn't hurt.  A similar thing is
done for macros that free instead of allocated, the criterion is:

  using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;

Trying to use XNEW on a type that requires new will result in an error
like this:

    In file included from /home/simark/src/binutils-gdb/gdb/common/common-utils.h:26:0,
                     from /home/simark/src/binutils-gdb/gdb/common/common-defs.h:78,
                     from /home/simark/src/binutils-gdb/gdb/defs.h:28,
                     from /home/simark/src/binutils-gdb/gdb/lala.c:1:
    /home/simark/src/binutils-gdb/gdb/common/poison.h: In instantiation of â€˜T* xnew() [with T = bar]’:
    /home/simark/src/binutils-gdb/gdb/lala.c:13:3:   required from here
    /home/simark/src/binutils-gdb/gdb/common/poison.h:103:3: error: static assertion failed: Trying to use XNEW with a non-POD data type.  Use operator new instead.
       static_assert (IsMallocatable<T>::value, "Trying to use XNEW with a non-POD\
       ^~~~~~~~~~~~~

Generated-code-wise, it adds one more function call (xnew<T>) when using
XNEW and building with -O0, but it all goes away with optimizations
enabled.

gdb/ChangeLog:

* common/common-utils.h: Include poison.h.
(xfree): Remove declaration, add definition with static_assert.
* common/common-utils.c (xfree): Remove.
* common/poison.h (IsMallocatable): Define.
(IsFreeable): Define.
(free): Delete for non-freeable types.
(xnew): New.
(XNEW): Undef and redefine.
(xcnew): New.
(XCNEW): Undef and redefine.
(xdelete): New.
(XDELETE): Undef and redefine.
(xnewvec): New.
(XNEWVEC): Undef and redefine.
(xcnewvec): New.
(XCNEWVEC): Undef and redefine.
(xresizevec): New.
(XRESIZEVEC): Undef and redefine.
(xdeletevec): New.
(XDELETEVEC): Undef and redefine.
(xnewvar): New.
(XNEWVAR): Undef and redefine.
(xcnewvar): New.
(XCNEWVAR): Undef and redefine.
(xresizevar): New.
(XRESIZEVAR): Undef and redefine.

6 years agoCreate private_thread_info hierarchy
Simon Marchi [Fri, 24 Nov 2017 15:40:31 +0000 (10:40 -0500)] 
Create private_thread_info hierarchy

There are multiple definitions of the private_thread_info structure
compiled in the same GDB build.  Because of the one definition rule, we
need to change this if we want to be able to make them non-POD (e.g. use
std::vector fields).  This patch creates a class hierarchy, with
private_thread_info being an abstract base class, and all the specific
implementations inheriting from it.

In order to poison XNEW/xfree for non-POD types, it is also needed to
get rid of the xfree in thread_info::~thread_info, which operates on an
opaque type.  This is replaced by thread_info::priv now being a
unique_ptr, which calls the destructor of the private_thread_info
subclass when the thread is being destroyed.

Including gdbthread.h from darwin-nat.h gave these errors:

/Users/simark/src/binutils-gdb/gdb/gdbthread.h:609:3: error: must use 'class' tag to refer to type 'thread_info' in this scope
  thread_info *m_thread;
  ^
  class
/usr/include/mach/thread_act.h:240:15: note: class 'thread_info' is hidden by a non-type declaration of 'thread_info' here
kern_return_t thread_info
              ^

It turns out that there is a thread_info function in the Darwin/XNU/mach API:

  http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_info.html

Therefore, I had to add the class keyword at a couple of places in gdbthread.h,
I don't really see a way around it.

gdb/ChangeLog:

* gdbthread.h (private_thread_info): Define structure type, add
virtual pure destructor.
(thread_info) <priv>: Change type to unique_ptr.
<private_dtor>: Remove.
* thread.c (add_thread_with_info): Adjust to use of unique_ptr.
(private_thread_info::~private_thread_info): Provide default
implementation.
(thread_info::~thread_info): Don't call private_dtor nor
manually free priv.
* aix-thread.c (private_thread_info): Rename to ...
(aix_thread_info): ... this.
(get_aix_thread_info): New.
(sync_threadlists): Adjust.
(iter_tid): Adjust.
(aix_thread_resume): Adjust.
(aix_thread_fetch_registers): Adjust.
(aix_thread_store_registers): Adjust.
(aix_thread_extra_thread_info): Adjust.
* darwin-nat.h (private_thread_info): Rename to ...
(darwin_thread_info): ... this.
(get_darwin_thread_info): New.
* darwin-nat.c (darwin_init_thread_list): Adjust.
(darwin_check_new_threads): Adjust.
(thread_info_from_private_thread_info): Adjust.
* linux-thread-db.c (private_thread_info): Rename to ...
(thread_db_thread_info): ... this, initialize fields.
(get_thread_db_thread_info): New.
<dying>: Change type to bool.
(update_thread_state): Adjust to type rename.
(record_thread): Adjust to type rename an use of unique_ptr.
(thread_db_pid_to_str): Likewise.
(thread_db_extra_thread_info): Likewise.
(thread_db_thread_handle_to_thread_info): Likewise.
(thread_db_get_thread_local_address): Likewise.
* nto-tdep.h (private_thread_info): Rename to ...
(nto_thread_info): ... this, initialize fields.
(get_nto_thread_info): New.
<name>: Change type to std::string.
* nto-tdep.c (nto_extra_thread_info): Adjust to type rename and
use of unique_ptr.
* nto-procfs.c (update_thread_private_data_name): Adjust to
std::string change, allocate nto_private_thread_info with new.
(update_thread_private_data): Adjust to unique_ptr.
* remote.c (private_thread_info): Rename to ...
(remote_thread_info): ... this, initialize data members with
default values.
<extra, name>: Change type to std::string.
<thread_handle>: Change type to non-pointer.
(free_private_thread_info): Remove.
(get_private_info_thread): Rename to...
(get_remote_thread_info): ... this, change return type, adjust to
use of unique_ptr, use remote_thread_info constructor.
(remote_add_thread): Adjust.
(get_private_info_ptid): Rename to...
(get_remote_thread_info): ...this, change return type.
(remote_thread_name): Use get_remote_thread_info, adjust to
change to std::string.
(struct thread_item) <~thread_item>: Remove.
<thread_handle>: Make non pointer.
(start_thread): Adjust to thread_item::thread_handle type
change.
(remote_update_thread_list): Adjust to type name change, move
strings from temporary to long-lived object instead of
duplicating.
(remote_threads_extra_info): Use get_remote_thread_info.
(process_initial_stop_replies): Likewise.
(resume_clear_thread_private_info): Likewise.
(remote_resume): Adjust to type name change.
(remote_commit_resume): Use get_remote_thread_info.
(process_stop_reply): Adjust to type name change.
(remote_stopped_by_sw_breakpoint): Use get_remote_thread_info.
(remote_stopped_by_hw_breakpoint): Likewise.
(remote_stopped_by_watchpoint): Likewise.
(remote_stopped_data_address): Likewise.
(remote_core_of_thread): Likewise.
(remote_thread_handle_to_thread_info): Use
get_private_info_thread, adjust to thread_handle field type
change.

6 years agoremote: C++ify thread_item and threads_listing_context
Simon Marchi [Fri, 24 Nov 2017 15:40:13 +0000 (10:40 -0500)] 
remote: C++ify thread_item and threads_listing_context

This patch C++ifies the thread_item and threads_listing_context
structures in remote.c.  thread_item::{extra,name} are changed to
std::string.  As a result, there's a bit of awkwardness in
remote_update_thread_list, where we have to xstrdup those strings when
filling the private_thread_info structure.  This is removed in the
following patch, where private_thread_info is also C++ified and its
corresponding fields made std::string too.  The xstrdup then becomes an
std::move.

Other than that there's nothing really special, it's a usual day-to-day
VEC -> vector and char* -> std::string change.  It allows removing a
cleanup in remote_update_thread_list.

Note that an overload of hex2bin that returns a gdb::byte_vector is
added, with corresponding selftests.

gdb/ChangeLog:

* remote.c (struct thread_item): Add constructor, disable copy
construction and copy assignment, define default move
construction and move assignment.
<extra, name>: Change type to std::string.
<core>: Initialize.
<thread_handle>: Make non-pointer.
(thread_item_t): Remove typedef.
(DEF_VEC_O(thread_item_t)): Remove.
(threads_listing_context) <contains_thread>: New method.
<remove_thread>: New method.
<items>: Change type to std::vector.
(clear_threads_listing_context): Remove.
(threads_listing_context_remove): Remove.
(remote_newthread_step): Use thread_item constructor, adjust to
change to std::vector.
(start_thread): Use thread_item constructor, adjust to change to
std::vector.
(end_thread): Adjust to change to std::vector and std::string.
(remote_get_threads_with_qthreadinfo): Use thread_item
constructor, adjust to std::vector.
(remote_update_thread_list): Adjust to change to std::vector and
std::string, use threads_listing_context methods.
(remove_child_of_pending_fork): Adjust.
(remove_new_fork_children): Adjust.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add rsp-low-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add rsp-low-selftests.o.
* unittests/rsp-low-selftests.c: New file.
* common/rsp-low.h: Include common/byte-vector.h.
(hex2bin): New overload.
* common/rsp-low.c (hex2bin): New overload.

6 years agoCreate private_inferior class hierarchy
Simon Marchi [Fri, 24 Nov 2017 15:39:30 +0000 (10:39 -0500)] 
Create private_inferior class hierarchy

There are currently multiple definitions of private_inferior, defined in
remote.c and darwin-nat.h.  The patch that poisons XNEW and friends for
non-POD types trips on that, because private_inferior is freed in
~inferior(), where it is an opaque type.  Since the compiler can't tell
whether the type is POD, it gives an error.  Also, we can't start using
C++ features in these structures (make them non-POD) as long as there
are multiple definitions with the same name.  For these reasons, this
patch makes a class hierarchy, with private_inferior being the abstract
base class, and darwin_inferior & remote_inferior inheriting from it.
Destruction is done through the virtual destructor.

I stumbled on some suspicious code in the darwin implementation though.
darwin_check_new_threads does an XCNEW(darwin_thread_t) when it finds a
new thread, allocating a new structure for it (darwin_thread_t is a
typedef for private_thread_info).  It then VEC_safe_pushes it in a
vector defined as DEF_VEC_O (a vector of objects).  This means that the
structure content gets copied in the vector.  The thread_info object is
created with the XCNEW'ed structure as the private thread info, while
the rest of the code works with the instance in the vector.  We have
therefore two distinct instances of darwin_thread_t/private_thread_info
for each thread.  This is not really a problem in practice, because
thread_info::priv is not used in the darwin code.  I still find it weird
and far from ideal, so I tried to fix it by changing the vector to be a
vector of pointers.  There should now be a single instance of the
structure for each thread.  The deallocation of the
darwin_thread_t/private_thread_info structure is done by the thread_info
destructor.

I am able to build on macOS, but not really test, since the port seems a
bit broken.  I am not able to debug reliably on the machine I have
access to, which runs macOS 10.12.6.

gdb/ChangeLog:

* inferior.h (private_inferior): Define structure type, add
virtual pure destructor.
(inferior) <priv>: Change type to unique_ptr.
* inferior.c (private_inferior::~private_inferior): Provide
default implementation.
(inferior::~inferior): Don't free priv field.
(exit_inferior_1): Likewise.
* darwin-nat.h (struct darwin_exception_info): Initialize fields.
(darwin_exception_info): Remove typedef.
(DEF_VEC_O (darwin_thread_t)); Remove.
(private_inferior): Rename to ...
(darwin_private_inferior): ... this, extend private_inferior.
(get_darwin_inferior): New.
<threads>: Change type to std::vector of darwin_thread_t pointers.
* darwin-nat.c (darwin_check_new_threads): Adjust.
(find_inferior_task_it): Adjust.
(darwin_find_thread); Adjust.
(darwin_suspend_inferior): Adjust.
(darwin_resume_inferior): Adjust.
(darwin_find_new_inferior): Adjust.
(darwin_decode_notify_message): Adjust.
(darwin_send_reply): Adjust.
(darwin_resume_inferior_threads): Adjust.
(darwin_suspend_inferior_threads): Adjust.
(darwin_decode_message): Adjust.
(darwin_wait): Adjust.
(darwin_interrupt): Adjust.
(darwin_deallocate_threads): Adjust.
(darwin_mourn_inferior): Adjust, don't free private data.
(darwin_reply_to_all_pending_messages): Adjust.
(darwin_stop_inferior): Adjust.
(darwin_setup_exceptions): Adjust.
(darwin_kill_inferior): Adjust.
(darwin_setup_request_notification): Adjust.
(darwin_attach_pid): Adjust.
(darwin_init_thread_list): Adjust.
(darwin_setup_fake_stop_event): Adjust.
(darwin_attach): Adjust.
(darwin_detach): Adjust.
(darwin_xfer_partial): Adjust.
(set_enable_mach_exceptions): Adjust.
(darwin_pid_to_exec_file): Adjust.
(darwin_get_ada_task_ptid): Adjust.
* darwin-nat-info.c (get_task_from_args): Adjust.
(info_mach_ports_command): Adjust.
(info_mach_region_command): Adjust.
(info_mach_exceptions_command): Adjust.
* remote.c (private_inferior): Rename to ...
(remote_private_inferior): ... this, initialize fields.
(get_remote_inferior); New.
(remote_commit_resume): Use get_remote_inferior.
(check_pending_event_prevents_wildcard_vcont_callback): Likewise.

6 years agoDocument linespec/explicit locations & completion improvements (manual + NEWS)
Pedro Alves [Fri, 24 Nov 2017 15:21:16 +0000 (15:21 +0000)] 
Document linespec/explicit locations & completion improvements (manual + NEWS)

gdb/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

* NEWS: Mention linespecs and explicit locations, and completion
improvements.

gdb/doc/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Completion): Update need-quoting examples.  Remove
false claim that GDB inserts quoting automatically.
(Symbols): Add anchor.

6 years agoRemove dead code in regcache::dump
Yao Qi [Fri, 24 Nov 2017 14:58:45 +0000 (14:58 +0000)] 
Remove dead code in regcache::dump

footnote_register_size in regcache::dump is a constant zero, so the
condition check against footnote_register_size is dead code.  The code
writing to footnote_register_size was removed by 01e1877.

This patche removes footnote_register_size and the dead code.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::dump): Remove footnote_register_size.

6 years agoelf: Properly compute offsets of note descriptor and next note
H.J. Lu [Fri, 24 Nov 2017 14:41:40 +0000 (06:41 -0800)] 
elf: Properly compute offsets of note descriptor and next note

According to gABI, in a note entry, the note name field, not note name
size, is padded for the note descriptor.  And the note descriptor field,
not note descriptor size, is padded for the next note entry.  Also notes
are aligned to 4 bytes in 32-bit objects and 8 bytes in 64-bit objects.
Since on Linux, .note.ABI-tag and .note.gnu.build-id notes are always
aligned to 4 bytes, we need to use alignment of note section or note
segment, instead of assuming alignment based on ELF file class.

Tested on i686 and x86-64.

bfd/

PR binutils/22444
* elf.c (elf_read_notes): Add an argument for note aligment.
(elf_parse_notes): Likewise.
(_bfd_elf_make_section_from_shdr): Pass section aligment to
elf_parse_notes.
(bfd_section_from_phdr): Pass segment aligment to elf_read_notes.
(elf_parse_notes): Add an argument for note aligment.  Use
ELF_NOTE_DESC_OFFSET to get the offset of the note descriptor.
Use ELF_NOTE_NEXT_OFFSET to get the offset of the next note
entry.
(elf_read_notes): Add an argument for note aligment and pass it
to elf_parse_notes.

binutils/

PR binutils/22444
* readelf.c (process_notes_at): Use ELF_NOTE_DESC_OFFSET to get
the offset of the note descriptor.  Use ELF_NOTE_NEXT_OFFSET to
get the offset of the next note entry.

include/

PR binutils/22444
* elf/external.h (ELF_ALIGN_UP): New.
(ELF_NOTE_DESC_OFFSET): Likewise.
(ELF_NOTE_NEXT_OFFSET): Likewise.

6 years agocooked_read test for readonly regcache
Yao Qi [Fri, 24 Nov 2017 13:04:30 +0000 (13:04 +0000)] 
cooked_read test for readonly regcache

This patch adds a test to check cooked_read for readonly regcache.  For
raw registers, cooked_read get either REG_VALID or REG_UNKNOWN, depends on
the raw register is in save_reggroup or not.  For pseudo register,
cooked_read get different result in different ports.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* regcache.c (cooked_read_test): Add more test for readonly
regcache.

6 years agoregcache::cooked_read unit test
Yao Qi [Fri, 24 Nov 2017 13:04:30 +0000 (13:04 +0000)] 
regcache::cooked_read unit test

This patch adds a unit test to regcache::cooked_read.  This unit test is a
little different from normal unit test, it is more about conformance test
or interaction test.  This test pass both raw register number and pseudo
register number to regcache::cooked_read, in order to inspect 1) return
value of cooked_read, 2) how are target_ops to_xfer_partial,
to_{fetch,store}_registers called (because regcache is updated by means of
these three target_ops methods).  With this test here, we have a clear
picture about how each port of GDB get cooked registers.

This patch also shares some code on mock target.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* gdbarch-selftests.c (test_target_has_registers): Move it to
target.c.
(test_target_has_stack): Likewise.
(test_target_has_memory): Likewise.
(test_target_prepare_to_store): Likewise.
(test_target_store_registers): Likewise.
(test_target_ops): Likewise.
* regcache.c: Include selftest-arch.h and gdbthread.h.
(target_ops_no_register): New class.
(test_target_fetch_registers): New.
(test_target_store_registers): New.
(test_target_xfer_partial): New.
(readwrite_regcache): New.
(cooked_read_test): New.
(_initialize_regcache): Register the test.
* target.c: (test_target_has_registers): Moved from
gdbarch-selftests.c.
(test_target_has_stack): Likewise.
(test_target_has_memory): Likewise.
(test_target_prepare_to_store): Likewise.
(test_target_store_registers): Likewise.
* target.h (test_target_ops): New class.

6 years agoAdd xml selftests for aarch64 target description.
Alan Hayward [Fri, 24 Nov 2017 10:28:58 +0000 (10:28 +0000)] 
Add xml selftests for aarch64 target description.

gdb/
* aarch64-tdep.c (_initialize_aarch64_tdep): Add target desc
selftest.

gdbserver/
* configure.srv: Add linux-aarch64-tdesc-selftest.o.
* linux-aarch64-low.c (initialize_low_arch): Call init func.
* linux-aarch64-tdesc-selftest.c: New file.
* linux-aarch64-tdesc.h (initialize_low_tdesc): New declaration.

6 years agoUse flexible target descriptors for aarch64
Alan Hayward [Fri, 24 Nov 2017 10:20:48 +0000 (10:20 +0000)] 
Use flexible target descriptors for aarch64

gdb/
* aarch64-tdep.c (_initialize_aarch64_tdep): Remove init.
* arch/aarch64.c (aarch64_create_target_description): Create
new target description.
* features/Makefile: Add new files.
* features/aarch64.c: Remove file.
* features/aarch64-core.c: New autogenerated file.
* features/aarch64-fpu.c: New autogenerated file.
* target-descriptions.c (maint_print_c_tdesc_cmd): Check for aarch64.

gdbserver/
* linux-aarch64-ipa.c (initialize_low_tracepoint): Remove init.
* linux-aarch64-low.c (initialize_low_arch): Remove init.
* linux-aarch64-tdesc.c (aarch64_linux_read_description): Add init.

6 years agogdbserver: add aarch64_create_target_description
Alan Hayward [Fri, 24 Nov 2017 10:04:53 +0000 (10:04 +0000)] 
gdbserver: add aarch64_create_target_description

gdbserver/
* configure.srv: Add new files.
* linux-aarch64-ipa.c (get_ipa_tdesc): Call
aarch64_linux_read_description.
* linux-aarch64-low.c (aarch64_linux_read_description):
Merge with aarch64_arch_setup.
(aarch64_arch_setup): Call aarch64_linux_read_description.
* linux-aarch64-tdesc.c: New file.
* linux-aarch64-tdesc.h: New file.

6 years agoAdd aarch64_create_target_description
Alan Hayward [Fri, 24 Nov 2017 10:00:54 +0000 (10:00 +0000)] 
Add aarch64_create_target_description

gdb/
* Makefile.in: Add new files.
* aarch64-linux-nat.c (aarch64_linux_read_description): Call
aarch64_read_description.
* aarch64-linux-tdep.c (aarch64_linux_core_read_description):
Call aarch64_read_description.
* aarch64-tdep.c (aarch64_read_description): New function.
(aarch64_gdbarch_init): Call aarch64_read_description.
* aarch64-tdep.h (aarch64_read_description): New function.
* arch/aarch64.c: New file.
* configure.tgt: Add new files.

6 years agoChange value_contents_eq return bool
Yao Qi [Fri, 24 Nov 2017 10:47:27 +0000 (10:47 +0000)] 
Change value_contents_eq return bool

This patch changes value_contents_eq return type from int to bool.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* mi/mi-main.c (register_changed_p): Update.
* value.c (value_contents_bits_eq): Change return type.
(value_contents_eq): Likewise.
* value.h: Update comments.

6 years agoChange register_changed_p returns bool
Yao Qi [Fri, 24 Nov 2017 10:47:27 +0000 (10:47 +0000)] 
Change register_changed_p returns bool

register_changed_p actually returns bool, but return type is still int.
This patch changes the return type to bool.  The caller of
register_changed_p also checked whether the return value can be negative,
which is not needed now.  Such check was added in fb40c2090 in 2000,
at that moment, register_changed_p returns -1 when
read_relative_register_raw_bytes fails.  I can tell from its name that
it reads register contents, but we don't have this function called inside
register_changed_p, and the regcache is read-only.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove
local 'changed'.  Remove error.
(register_changed_p): Change return type to bool.

6 years agoChange tic6x target descriptions
Yao Qi [Fri, 24 Nov 2017 09:29:43 +0000 (09:29 +0000)] 
Change tic6x target descriptions

This patch changes tic6x target descriptions to be more flexible.  Rebuild
tic6x-uclinux GDBserver with my x86 g++, and the unit test passes.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* arch/tic6x.c: New file.
* arch/tic6x.h: New file.
* features/Makefile (FEATURE_XMLFILES): Add tic6x-c6xp.xml,
tic6x-core.xml and tic6x-gp.xml.
* features/tic6x-c6xp.c: Generated.
* features/tic6x-core.c: Generated.
* features/tic6x-gp.c: Generated.
* target-descriptions.c (maint_print_c_tdesc_cmd): Match
"tic6x-".

gdb/gdbserver:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* configure.srv: Set $srv_regobj for tic6x-linux.
* linux-tic6x-low.c: Include "arch/tic6x.h" and "tdesc.h".
(tic6x_read_description): Move some code to tic6x_arch_setup.
(tic6x_tdesc_test): New function.
(initialize_low_arch): Call selftests::register_test.

6 years agox86: reject further invalid AVX-512 masking constructs
Jan Beulich [Fri, 24 Nov 2017 07:42:57 +0000 (08:42 +0100)] 
x86: reject further invalid AVX-512 masking constructs

For one the register type used for masking should be validated. And then
we shouldn't accept input producing encodings which will #UD when
executed, as is the case when EVEX.Z is set while EVEX.AAA is zero.

6 years agox86: don't omit disambiguating suffixes from "fi*"
Jan Beulich [Fri, 24 Nov 2017 07:42:04 +0000 (08:42 +0100)] 
x86: don't omit disambiguating suffixes from "fi*"

"fi*" typically come in two (loads/stores: three) flavors, distinguished
by the suffix. Don't omit the 's' one when disassembling.

6 years agoFix memory leak in list_available_thread_groups
Simon Marchi [Fri, 24 Nov 2017 02:56:19 +0000 (21:56 -0500)] 
Fix memory leak in list_available_thread_groups

Commit

  C++ify osdata
  479f8de1b3b7e69ca8d557bbe9d843c7d1bc89c5

introduced a memory leak.  We allocate std::vectors and insert them in a
map, but never free them.  Instead, the map value type can be
std::vector objects directly.

gdb/ChangeLog:

* mi/mi-main.c (list_available_thread_groups): Change map value
type to std::vector.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Nov 2017 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoFix vax/ns32k/mmix gas testsuite regression.
Jim Wilson [Thu, 23 Nov 2017 21:11:40 +0000 (13:11 -0800)] 
Fix vax/ns32k/mmix gas testsuite regression.

gas/
* testsuite/gas/all/err-fakelabel.s (dg-error): Also accept fatal error
string.

6 years agoFix build error with --enable-targets=all.
Jim Wilson [Thu, 23 Nov 2017 20:30:47 +0000 (12:30 -0800)] 
Fix build error with --enable-targets=all.

gas/
* as.c (INITIALIZING_EMULS): Define.
* config/obj-multi.h (FAKE_LABEL_NAME): When INITIALIZING_EMULS set,
don't define it.

6 years agoFix clang warnings about copy elision
Simon Marchi [Thu, 23 Nov 2017 18:51:50 +0000 (13:51 -0500)] 
Fix clang warnings about copy elision

When building with clang, I get:

/home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
                             std::move (std::string (body_text)));
                             ^
/home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: note: remove std::move call here
                             std::move (std::string (body_text)));
                             ^~~~~~~~~~~                       ~
/home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
  return std::move (osdata);
         ^
/home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: note: remove std::move call here
  return std::move (osdata);
         ^~~~~~~~~~~      ~

Indeed, those two std::move are unnecessary.

gdb/ChangeLog:

* osdata.c (osdata_end_column, get_osdata): Remove std::move.

6 years agoRevert unexpected rename in previous patch
Simon Marchi [Thu, 23 Nov 2017 16:05:22 +0000 (11:05 -0500)] 
Revert unexpected rename in previous patch

While working on the previous patch, I renamed variables whose type I
changed to let the compiler help me find their usages, but I forgot to
rename one back to its original name.  This patch fixes it.

gdb/ChangeLog:

* varobj.c (struct varobj_dynamic) <children_requested_>: Rename
back to...
<children_requested>: ... this.
(varobj_get_num_children, varobj_update): Adjust.

6 years agoChange int -> bool where applicable throughout varobj
Simon Marchi [Thu, 23 Nov 2017 16:00:56 +0000 (11:00 -0500)] 
Change int -> bool where applicable throughout varobj

This patch changes all the "int" I could find in varobj.{c,h} that are
really boolean values to use bool.  I followed the ramifications
(parameters and return values of exported functions), so the changes
spilled a bit on other, related files (ada-varobj.c and c-varobj.c).

gdb/ChangeLog:

* ada-varobj.c (ada_value_is_changeable_p): Change int to bool where applicable.
(ada_value_has_mutated): Likewise.
* c-varobj.c (varobj_is_anonymous_child): Likewise.
(c_is_path_expr_parent): Likewise.
* mi/mi-cmd-var.c (varobj_update_one): Likewise.
(mi_cmd_var_set_frozen): Likewise.
(mi_cmd_var_update_iter): Likewise.
(mi_cmd_var_update): Likewise.
* varobj.c (pretty_printing): Likewise.
(varobj_enable_pretty_printing): Likewise.
(struct varobj_root) <floating, is_valid>: Likewise.
(struct varobj_dynamic) <children_requested>: Likewise.
(delete_variable): Likewise.
(delete_variable_1): Likewise.
(install_variable): Likewise.
(update_type_if_necessary): Likewise.
(install_new_value): Likewise.
(value_of_root): Likewise.
(is_root_p): Likewise.
(varobj_create): Likewise.
(varobj_delete): Likewise.
(varobj_has_more): Likewise.
(varobj_set_frozen): Likewise.
(varobj_get_frozen): Likewise.
(install_dynamic_child): Likewise.
(dynamic_varobj_has_child_method): Likewise.
(update_dynamic_varobj_children): Likewise.
(varobj_get_num_children): Likewise.
(varobj_list_children): Likewise.
(is_path_expr_parent): Likewise.
(varobj_default_is_path_expr_parent): Likewise.
(varobj_is_dynamic_p): Likewise.
(varobj_set_value): Likewise.
(varobj_value_has_mutated): Likewise.
(varobj_update): Likewise.
(check_scope): Likewise.
(value_of_root_1): Likewise.
(varobj_value_get_print_value): Likewise.
(varobj_editable_p): Likewise.
(varobj_value_is_changeable_p): Likewise.
(varobj_floating_p): Likewise.
(varobj_default_value_is_changeable_p): Likewise.
(varobj_invalidate_iter): Likewise.
* varobj.h (struct varobj_update_result) <type_changed,
children_changed, changed, value_installed>: Likewise.
(struct varobj) <updated, frozen, not_fetched>: Likewise.
(struct lang_varobj_ops) <value_is_changeable_p,
value_has_mutated, is_path_expr_parent>: Likewise.
(varobj_delete): Likewise.
(varobj_set_frozen): Likewise.
(varobj_get_frozen): Likewise.
(varobj_set_value): Likewise.
(varobj_update): Likewise.
(varobj_editable_p): Likewise.
(varobj_floating_p): Likewise.
(varobj_has_more): Likewise.
(varobj_is_dynamic_p): Likewise.
(varobj_default_value_is_changeable_p): Likewise.
(varobj_value_is_changeable_p): Likewise.
(varobj_is_anonymous_child): Likewise.
(varobj_default_is_path_expr_parent): Likewise.

6 years agoAvoid bogus compile time warning from clang by initialising local data structure...
Pavel I. Kryukov [Thu, 23 Nov 2017 15:53:04 +0000 (15:53 +0000)] 
Avoid bogus compile time warning from clang by initialising local data structure using memset.

PR 22485
* readelf.c (process_archive): Use memset to initiaise
thin_filedata structure.

6 years ago[testsuite] Pass -g3 to clang in gdb.base/macscp.exp
Yao Qi [Thu, 23 Nov 2017 15:30:56 +0000 (15:30 +0000)] 
[testsuite] Pass -g3 to clang in gdb.base/macscp.exp

clang accepts option -g3 too.  I checked the manual of xlc and icc, looks
they don't accept -g3 option, so I don't pass -g3 for them.

gdb/testsuite:

2017-11-23  Yao Qi  <yao.qi@linaro.org>

* gdb.base/macscp.exp: Append -g3 to additional_flags for clang.

6 years agoAdd Disp8MemShift for AVX512 VAES instructions.
Igor Tsimbalist [Wed, 22 Nov 2017 11:40:32 +0000 (14:40 +0300)] 
Add Disp8MemShift for AVX512 VAES instructions.

opcodes/
* i386-opc.tbl: Add Disp8MemShift for AVX512 VAES instructions.
* i386-tbl.h: Regenerate.

gas/
* testsuite/gas/i386/avx512f_vaes-intel.d: Regenerate.
* testsuite/gas/i386/avx512f_vaes.d: Likewise.
* testsuite/gas/i386/avx512f_vaes-wig1-intel.d: Likewise.
* testsuite/gas/i386/avx512f_vaes-wig1.d: Likewise.
* testsuite/gas/i386/avx512vl_vaes-intel.d: Likewise.
* testsuite/gas/i386/avx512vl_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512f_vaes.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512f_vaes-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512f_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig1-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig1.d: Likewise.
* testsuite/gas/i386/x86-64-avx512vl_vaes-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512vl_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig1-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig1.d: Regenerate.

6 years agoDon't move weak alias dyn_relocs to weakdef
Alan Modra [Wed, 22 Nov 2017 10:37:03 +0000 (21:07 +1030)] 
Don't move weak alias dyn_relocs to weakdef

I did this for powerpc64 a while ago.  Not moving weak symbol
dyn_relocs to the strong alias makes for a much simpler test for
dynamic relocs in relocate_section.

This patch implements the change for powerpc and hppa.  Other targets
could benefit from similar changes.

* elf32-hppa.c (pc_dynrelocs): Define.
(elf32_hppa_copy_indirect_symbol): Don't copy dyn_relocs to weakdefs.
(alias_readonly_dynrelocs): New function.
(elf32_hppa_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(elf32_hppa_relocate_section): Simplify test for dynamic relocs.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't copy dyn_relocs
to weakdefs.
(alias_readonly_dynrelocs, pc_dynrelocs): New functions.
(ppc_elf_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(ppc_elf_relocate_section): Simplify test for dynamic relocs.

6 years agoDelete powerpc64 symbol weakref field
Alan Modra [Wed, 22 Nov 2017 07:02:50 +0000 (17:32 +1030)] 
Delete powerpc64 symbol weakref field

Now that u.alias is circular, weakref just duplicates its function.
Also, function symbols shouldn't be on the alias list so there is no
need to use alias_readonly_dynrelocs with them.

* elf64-ppc.c (struct ppc_link_hash_entry): Delete weakref field.
(ppc64_elf_copy_indirect_symbol): Don't set weakref.
(alias_readonly_dynrelocs): Use u.alias rather than weakref.
(ppc64_elf_adjust_dynamic_symbol): Don't use
alias_readonly_dynrelocs for function symbols.

6 years agoRename u.weakdef and make it a circular list
Alan Modra [Wed, 22 Nov 2017 07:00:55 +0000 (17:30 +1030)] 
Rename u.weakdef and make it a circular list

This makes the elf_link_hash_entry weakdef field, currently used to
point from a weak symbol to a strong alias, a circular list so that
all aliases can be found from any of them.  A new flag, is_weakalias,
distinguishes the weak symbol from a strong alias, and is used in all
places where we currently test u.weakdef != NULL.

With the original u.weakdef handling it was possible to have two or
more weak symbols pointing via u.weakdef to a strong definition.
Obviously that situation can't map to a circular list; One or more of
the weak symbols must point at another weak alias rather than the
strong definition.  To handle that, I've added an accessor function to
return the strong definition.

* elf-bfd.h (struct elf_link_hash_entry): Add is_weakalias.
Rename u.weakdef to u.alias and update comment.
(weakdef): New static inline function.
* elflink.c (bfd_elf_record_link_assignment) Test is_weakalias
rather than u.weakdef != NULL, and use weakdef function.
(_bfd_elf_adjust_dynamic_symbol): Likewise.
(_bfd_elf_fix_symbol_flags): Likewise.  Clear is_weakalias on
all aliases if def has been overridden in a regular object, not
u.weakdef.
(elf_link_add_object_symbols): Delete new_weakdef flag.  Test
is_weakalias and use weakdef.  Set is_weakalias and circular
u.alias.  Update comments.
(_bfd_elf_gc_mark_rsec): Test is_weakalias rather than
u.weakdef != NULL and use weakdef function.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Test
is_weakalias rather than u.weakdef != NULL and use weakdef
function.  Assert that def is strong defined.
* elf32-arc.c (elf_arc_adjust_dynamic_symbol): Likewise.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_adjust_dynamic_symbol): Likewise.
(bfin_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-frv.c (elf32_frvfdpic_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
* elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Likewise.
* elf32-nds32.c (nds32_elf_adjust_dynamic_symbol): Likewise.
* elf32-nios2.c (nios2_elf32_adjust_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-score.c (s3_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-score7.c (s7_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Likewise.
(tilepro_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf32-xtensa.c (elf_xtensa_adjust_dynamic_symbol): Likewise.
* elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Likewise.
* elf64-hppa.c (elf64_hppa_adjust_dynamic_symbol): Likewise.
* elf64-ia64-vms.c (elf64_ia64_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise.
(ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
* elfnn-ia64.c (elfNN_ia64_adjust_dynamic_symbol): Likewise.
* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
(_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
(tilegx_elf_adjust_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Likewise.

6 years agoAdd libmsvcrt, libmsvcrt-os and libucrtbase to the list of libraries for which the...
Martin Storsjo [Thu, 23 Nov 2017 12:07:24 +0000 (12:07 +0000)] 
Add libmsvcrt, libmsvcrt-os and libucrtbase to the list of libraries for which the automatic generation of exported variables should be disabled.

In the latest git version of mingw-w64, one can set the default
libmsvcrt.a to actually be the import library of another CRT version,
to facilitate switching to ucrtbase.dll. In these versions, the
traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided
with the name libmsvcrt-os.a.

The import libraries for the CRT also contain a number of compatibility
wrapper functions. The ones in libmsvcrt.a have so far been excluded
automatically since they in most cases come with a corresponding
__imp_foo function. None of these make sense to export automatically
from a DLL though, so add these libraries to the exclude list.

libucrtbase.a contains a number of compatibility wrapper functions
that don't have a corresponding __imp_foo symbol, which cause
these symbols to be exported from DLLs.

This can be worked around on the mingw-w64 side by adding extra
__imp_ symbols, but since they aren't strictly necessary for linking
to succeed, it's probably better long-term to add these libraries to
the exclusion list.

ld * pe-dll.c (autofilter_liblist): Add libmsvcrt, libmsvcrt-os and
libucrtbase.

6 years agox86: fix AVX-512 16-bit addressing
Jan Beulich [Thu, 23 Nov 2017 10:04:18 +0000 (11:04 +0100)] 
x86: fix AVX-512 16-bit addressing

Despite EVEX encodings not being available in real and VM86 modes,
16-bit addressing still needs to be handled properly for 16-bit
protected mode as well as 16-bit addressing in 32-bit mode. Neither
should displacements be dropped silently by the assembler, nor should
the disassembler fail to correctly scale 8-bit displacements.

6 years agox86-64: always use unsigned 32-bit reloc for 32-bit addressing w/o base reg
Jan Beulich [Thu, 23 Nov 2017 10:02:30 +0000 (11:02 +0100)] 
x86-64: always use unsigned 32-bit reloc for 32-bit addressing w/o base reg

Except for %eip-relative addressing, where we don't have a suitable
relocation type silently wrapping at the 4G boundary, consistently
force use of R_X86_64_32 (in ELF terms) instead of its sign-extending
counterpart. This wasn't right in case there was no base register in
the addressing expression.

6 years agox86: drop redundant VSIB handling code
Jan Beulich [Thu, 23 Nov 2017 10:00:44 +0000 (11:00 +0100)] 
x86: drop redundant VSIB handling code

The vecsib && !base_reg case is already being handled (in a more correct
manner) by earlier code.