binutils-gdb.git
6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 14 Feb 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agox86: Properly check building shared library
H.J. Lu [Tue, 13 Feb 2018 22:31:53 +0000 (14:31 -0800)]
x86: Properly check building shared library

If a symbol is not defined in a regular file, and we are not generating
a shared library, then set the symbol to its location in the .plt.  This
is required to make function pointers compare as equal between the normal
executable and the shared library.

* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll,
instead of bfd_link_pic, for building shared library.

6 years agogas: xtensa: fix trampoline placement
Max Filippov [Sun, 11 Feb 2018 05:59:54 +0000 (21:59 -0800)]
gas: xtensa: fix trampoline placement

For jumps requiring multiple trampolines trampoline placement code may
place multiple sequential trampolines into the same frag. Don't do that.

gas/
2018-02-13  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline
frag that contains source address.

6 years agoUse enum flags for flags passed to openp
Simon Marchi [Tue, 13 Feb 2018 17:13:59 +0000 (12:13 -0500)]
Use enum flags for flags passed to openp

gdb/ChangeLog:

* defs.h (enum openp_flags): New enum.
(OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
Move to enum openp_flags.
(openp_flags): New enum flags.
(openp): Change parameter type to openp_flags.
* source.c (openp): Change parameter type to openp_flags.
* cli/cli-cmds.c (find_and_open_script): Use openp_flags.
* dwarf2read.c (try_open_dwop_file): Use openp_flags.

6 years agoFix ARm assembler so that it rejects invalid immediate values for the Thumb ORR instr...
Nick Clifton [Tue, 13 Feb 2018 16:50:04 +0000 (16:50 +0000)]
Fix ARm assembler so that it rejects invalid immediate values for the Thumb ORR instruction.

PR 22773
* config/tc-arm.c (md_apply_fix): Test Rn field of Thumb ORR
instruction before assuming that it is a MOV instruction.
* testsuite/gas/arm/pr22773.s: New test.
* testsuite/gas/arm/pr22773.d: New test driver.
* testsuite/gas/arm/pr22773.l: New expected output.

6 years agox86-64: Generate branch with PLT32 relocation
H.J. Lu [Tue, 13 Feb 2018 15:34:22 +0000 (07:34 -0800)]
x86-64: Generate branch with PLT32 relocation

Since there is no need to prepare for PLT branch on x86-64, generate
R_X86_64_PLT32, instead of R_X86_64_PC32, if possible, which can be
used as a marker for 32-bit PC-relative branches.

To compile Linux kernel, this patch:

From: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH] x86: Treat R_X86_64_PLT32 as R_X86_64_PC32

On i386, there are 2 types of PLTs, PIC and non-PIC.  PIE and shared
objects must use PIC PLT.  To use PIC PLT, you need to load
_GLOBAL_OFFSET_TABLE_ into EBX first.  There is no need for that on
x86-64 since x86-64 uses PC-relative PLT.

On x86-64, for 32-bit PC-relative branches, we can generate PLT32
relocation, instead of PC32 relocation, which can also be used as
a marker for 32-bit PC-relative branches.  Linker can always reduce
PLT32 relocation to PC32 if function is defined locally.   Local
functions should use PC32 relocation.  As far as Linux kernel is
concerned, R_X86_64_PLT32 can be treated the same as R_X86_64_PC32
since Linux kernel doesn't use PLT.

is needed.  It is available on hjl/plt32/master branch at

https://github.com/hjl-tools/linux

bfd/

PR gas/22791
* elf64-x86-64.c (is_32bit_relative_branch): Removed.
(elf_x86_64_relocate_section): Check PIC relocations in PIE.
Remove is_32bit_relative_branch usage.  Disallow PC32 reloc
against protected function in shared object.

gas/

PR gas/22791
* config/tc-i386.c (need_plt32_p): New function.
(output_jump): Generate BFD_RELOC_X86_64_PLT32 if possible.
(md_estimate_size_before_relax): Likewise.
* testsuite/gas/i386/reloc64.d: Updated.
* testsuite/gas/i386/x86-64-jump.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-1.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-3.d: Likewise.
* testsuite/gas/i386/ilp32/reloc64.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise.

ld/

PR gas/22791
* testsuite/ld-x86-64/mpx1c.rd: Updated.
* testsuite/ld-x86-64/pr22791-1.err: New file.
* testsuite/ld-x86-64/pr22791-1a.c: Likewise.
* testsuite/ld-x86-64/pr22791-1b.s: Likewise.
* testsuite/ld-x86-64/pr22791-2.rd: Likewise.
* testsuite/ld-x86-64/pr22791-2a.s: Likewise.
* testsuite/ld-x86-64/pr22791-2b.c: Likewise.
* testsuite/ld-x86-64/pr22791-2c.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/22791 tests.

6 years agoFix typo in Russian translation for the bfd/ sub-directory which could lead to a...
Sergei Trofimovich [Tue, 13 Feb 2018 15:13:58 +0000 (15:13 +0000)]
Fix typo in Russian translation for the bfd/ sub-directory which could lead to a seg-fault in the linker.

PR 22828
* po/ru.po: Fix typo in Russian translation.

6 years agoFix compile time warning messages from gcc version 8 about cast between incompatible...
Nick Clifton [Tue, 13 Feb 2018 13:14:47 +0000 (13:14 +0000)]
Fix compile time warning messages from gcc version 8 about cast between incompatible function types.

PR 22823
bfd Fix compile time warnings generated by gcc version 8.
* libbfd-in.h: Remove extraneous text from prototypes.
Add prototypes for bfd_false_any, bfd_true_any,
bfd_nullvoidptr_any, bfd_0_any, bfd_0u_any, bfd_0l_any,
bfd_n1_any, bfd_void_any.
(_bfd_generic_bfd_copy_private_bfd_data): Use vararg based dummy
function.
(_bfd_generic_bfd_merge_private_bfd_data): Likewise.
(_bfd_generic_bfd_set_private_flags): Likewise.
(_bfd_generic_bfd_copy_private_section_data): Likewise.
(_bfd_generic_bfd_copy_private_symbol_data): Likewise.
(_bfd_generic_bfd_copy_private_header_data): Likewise.
(_bfd_generic_bfd_print_private_bfd_data): Likewise.
(_bfd_noarchive_construct_extended_name_table): Likewise.
(_bfd_noarchive_truncate_arname): Likewise.
(_bfd_noarchive_write_ar_hdr): Likewise.
(_bfd_noarchive_get_elt_at_index): Likewise.
(_bfd_nosymbols_canonicalize_symtab): Likewise.
(_bfd_nosymbols_print_symbol): Likewise.
(_bfd_nosymbols_get_symbol_info): Likewise.
(_bfd_nosymbols_get_symbol_version_string): Likewise.
(_bfd_nosymbols_bfd_is_local_label_name): Likewise.
(_bfd_nosymbols_bfd_is_target_special_symbol): Likewise.
(_bfd_nosymbols_get_lineno): Likewise.
(_bfd_nosymbols_find_nearest_line): Likewise.
(_bfd_nosymbols_find_line): Likewise.
(_bfd_nosymbols_find_inliner_info): Likewise.
(_bfd_nosymbols_bfd_make_debug_symbol): Likewise.
(_bfd_nosymbols_read_minisymbols): Likewise.
(_bfd_nosymbols_minisymbol_to_symbol): Likewise.
(_bfd_norelocs_bfd_reloc_type_lookup): Likewise.
(_bfd_norelocs_bfd_reloc_name_lookup): Likewise.
(_bfd_nowrite_set_arch_mach): Likewise.
(_bfd_nowrite_set_section_contents): Likewise.
(_bfd_nolink_sizeof_headers): Likewise.
(_bfd_nolink_bfd_get_relocated_section_contents): Likewise.
(_bfd_nolink_bfd_relax_section): Likewise.
(_bfd_nolink_bfd_gc_sections): Likewise.
(_bfd_nolink_bfd_lookup_section_flags): Likewise.
(_bfd_nolink_bfd_merge_sections): Likewise.
(_bfd_nolink_bfd_is_group_section): Likewise.
(_bfd_nolink_bfd_discard_group): Likewise.
(_bfd_nolink_bfd_link_hash_table_create): Likewise.
(_bfd_nolink_bfd_link_add_symbols): Likewise.
(_bfd_nolink_bfd_link_just_syms): Likewise.
(_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise.
(_bfd_nolink_bfd_final_link): Likewise.
(_bfd_nolink_bfd_link_split_section): Likewise.
(_bfd_nolink_section_already_linked): Likewise.
(_bfd_nolink_bfd_define_common_symbol): Likewise.
(_bfd_nolink_bfd_define_start_stop): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise.
(_bfd_nodynamic_get_synthetic_symtab): Likewise.
(_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise.
* libbfd.c (bfd_false_any): New function.  Like bfd_false but
accepts one or more arguments.
(bfd_true_any): Likewise.
(bfd_nullvoidptr_any): Likewise.
(bfd_0_any): Likewise.
(bfd_0u_any): Likewise.
(bfd_0l_any): Likewise.
(_bfd_n1_any): Likewise.
(bfd_void_any): Likewise.
* libbfd.h (extern): Regenerate
* aout-target.h (MY_bfd_is_target_special_symbol): Use vararg
based dummy function.
* aout-tic30.c (tic30_aout_set_arch_mach): Likewise.
* binary.c (binary_get_symbol_info): Likewise.
* coff-alpha.c (alpha_ecoff_backend_data): Likewise.
* coff-mips.c (mips_ecoff_backend_data): Likewise.
* coffcode.h (coff_set_alignment_hook): Likewise.
(symname_in_debug_hook): Likewise.
(bfd_coff_backend_data bigobj_swap_table): Likewise.
* elf-m10300.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-metag.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score7.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise.
* elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise.
* elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise.
(bfd_elfNN_bfd_make_debug_symbol): Likewise.
(bfd_elfNN_bfd_merge_private_bfd_data): Likewise.
(bfd_elfNN_bfd_set_private_flags): Likewise.
(bfd_elfNN_bfd_is_target_special_symbol): Likewise.
(elf_backend_init_index_section): Likewise.
(elf_backend_allow_non_load_phdr): Likewise.
* elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise.
* i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise.
* ieee.c (ieee_construct_extended_name_table): Likewise.
(ieee_write_armap): Likewise.
(ieee_write_ar_hdr): Likewise.
(ieee_bfd_is_target_special_symbol): Likewise.
* ihex.c (ihex_canonicalize_symtab): Likewise.
(ihex_bfd_is_target_special_symbol): Likewise.
* libaout.h (aout_32_bfd_is_target_special_symbol): Likewise.
* libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise.
(_bfd_ecoff_set_alignment_hook): Likewise.
* mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise.
* mmo.c (mmo_bfd_is_target_special_symbol): Likewise.
* nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise.
* oasys.c (oasys_construct_extended_name_table): Likewise.
(oasys_write_armap): Likewise.
(oasys_write_ar_hdr): Likewise.
(oasys_bfd_is_target_special_symbol): Likewise.
* pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise.
* plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise.
* ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise.
* som.c (som_bfd_is_target_special_symbol): Likewise.
* srec.c (srec_bfd_is_target_special_symbol): Likewise.
* tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise.
* verilog.c (verilog_bfd_is_target_special_symbol): Likewise.
* versados.c (versados_bfd_is_target_special_symbol): Likewise.
(versados_bfd_reloc_name_lookup): Likewise.
* vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise.
(vms_bfd_define_start_stop): Likewise.
(alpha_vms_bfd_is_target_special_symbol): Likewise.
* wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise.
* xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise.
* elf32-arc.c (get_replace_function): Assign replacement function
to func pointer.
* elf32-i370.c (i370_noop): Update prototype.

gas * config/obj-elf.c (elf_pseudo_table): Remove now redundant
casts.
(obj_elf_vtable_inherit): Rename to obj_elf_get_vtable_inherit.
(obj_elf_vtable_inherit): New stub function that calls
obj_elf_get_vtable_inherit.
(obj_elf_vtable_entry): Rename to obj_elf_get_vtable_entry.
(obj_elf_vtable_entry): New stub function that calls
obj_elf_get_vtable_entry.
* config/obj-elf.h (obj_elf_vtable_inherit): Update prototype.
(obj_elf_vtable_entry) Likewise.
(obj_elf_get_vtable_inherit) Likewise.
(obj_elf_get_vtable_entry) Likewise.
* config/tc-arm.c (md_pseudo_table): Remove now redundant cast.
* config/tc-i386c (md_pseudo_table): Likewise.
* config/tc-hppa.c (pa_vtable_entry): Call
obj_elf_get_vtable_entry.
(pa_vtable_inherit): Call obj_elf_get_vtable_inherit.
* config/tc-mips.c (s_mips_file): Replace call to dwarf2_get_file
with call to dwarf2_get_filename.
* dwarf2dbg.c (dwarf2_directive_file): Rename to
dwarf2_directive_filename.
(dwarf2_directive_file): New stub function that calls
dwarf2_directive_filename.
* dwarf2dbg.h: Prototype dwarf2_directive_filename.

opcodes * metag-dis.c (print_fmmov): Double buffer size to avoid warning
about truncation of printing.

6 years agoWebAssembly: Disable subdirectory configuration for unsupported LD
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)]
WebAssembly: Disable subdirectory configuration for unsupported LD

Remove an LD subdirectory configuration error:

*** ld does not support target wasm32-unknown-none
*** see ld/configure.tgt for supported targets
make[1]: *** [configure-ld] Error 1

which prevents binutils for the WebAssembly target from being built
unless an explicit `--disable-ld' configuration option has been given.
Users must not have to disable features selected by default to get a
working configuration.

/
* configure.ac <wasm32-*-*> (noconfigdirs): Add `ld'.
* configure: Regenerate.

6 years agoWebAssembly: Correct an `index' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)]
WebAssembly: Correct an `index' global shadowing error for pre-4.8 GCC

Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../bfd/wasm-module.c: In function 'wasm_scan_name_function_section':
.../bfd/wasm-module.c:312: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_register_section':
.../bfd/wasm-module.c:494: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_compute_custom_section_file_position':
.../bfd/wasm-module.c:523: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here

and:

cc1: warnings being treated as errors
.../opcodes/wasm32-dis.c: In function 'print_insn_wasm32':
.../opcodes/wasm32-dis.c:272: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
make[4]: *** [wasm32-dis.lo] Error 1

which for versions of GCC before 4.8 prevent support for the WebAssembly
target from being built.  See also GCC PR c/53066.

bfd/
* wasm-module.c (wasm_scan_name_function_section): Rename
`index' local variable to `idx'.

opcodes/
* wasm32-dis.c (print_insn_wasm32): Rename `index' local
variable to `function_index'.

6 years agoMIPS/GAS/testsuite: Correct duplicate `Loongson-3A tests' test name
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)]
MIPS/GAS/testsuite: Correct duplicate `Loongson-3A tests' test name

Correct a duplicate `Loongson-3A tests' GAS test name introduced with
commit 986754024085 ("Add Loongson3A specific instructions"),
<https://sourceware.org/ml/binutils/2010-12/msg00447.html>, shared
between gas/testsuite/gas/mips/loongson-3a.d and
gas/testsuite/gas/mips/loongson-3a-2.d.

gas/
* testsuite/gas/mips/loongson-3a-2.d: Rename test.

6 years agoPR22836, "-r -s" doesn't work with -g3 using GCC 7
Alan Modra [Tue, 13 Feb 2018 03:39:48 +0000 (14:09 +1030)]
PR22836, "-r -s" doesn't work with -g3 using GCC 7

This fixes the case where all of a group is removed with ld -r, the
situation in the PR, and failures where part of a group is removed
that contain relocs.

bfd/
PR 22836
* elf.c (_bfd_elf_fixup_group_sections): Account for removed
relocation sections.  If size reduces to just the flag word,
remove that too and mark with SEC_EXCLUDE.
* elflink.c (bfd_elf_final_link): Strip empty group sections.
binutils/
* testsuite/binutils-all/group-7.s,
* testsuite/binutils-all/group-7a.d,
* testsuite/binutils-all/group-7b.d,
* testsuite/binutils-all/group-7c.d: New tests.
* testsuite/binutils-all/objcopy.exp: Run them.
ld/
* testsuite/ld-elf/pr22836-2.d,
* testsuite/ld-elf/pr22836-2.s: New test.

6 years agoPR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries
Alan Modra [Mon, 12 Feb 2018 02:36:07 +0000 (13:06 +1030)]
PR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries

lld lays out the relro segment differently to GNU ld, not bothering to
include the first few bytes of .got.plt and padding out to a page at
the end of the segment.  This patch teaches binutils to recognize the
different (and somewhat inferior) layout as valid.

bfd/
PR 22829
* elf.c (assign_file_positions_for_non_load_sections): Rewrite
PT_GNU_RELRO setup.
ld/
* testsuite/ld-x86-64/pr14207.d: Adjust relro p_filesz.

6 years agoFix prefix of maint set/show per-command
Simon Marchi [Tue, 13 Feb 2018 05:32:53 +0000 (00:32 -0500)]
Fix prefix of maint set/show per-command

I noticed this:

(gdb) apropos per-command
maintenance set per-command -- Per-command statistics settings
set per-command space -- Set whether to display per-command space usage
set per-command symtab -- Set whether to display per-command symtab statistics
set per-command time -- Set whether to display per-command execution time
maintenance show per-command -- Show per-command statistics settings
show per-command space -- Show whether to display per-command space usage
show per-command symtab -- Show whether to display per-command symtab statistics
show per-command time -- Show whether to display per-command execution time

The subcommands of "maintenance set per-command" are missing the
maintenance keyword.  This is because that command is registered with
the wrong prefix.  This patch fixes that.

gdb/ChangeLog:

* maint.c (_initialize_maint_cmds): Fix prefix of maint set/show
per-command.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 13 Feb 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agogdb: Remove cleanup from dw2_do_instantiate_symtab
Andrew Burgess [Mon, 5 Feb 2018 17:13:17 +0000 (17:13 +0000)]
gdb: Remove cleanup from dw2_do_instantiate_symtab

When running the test gdb.dwarf2/dw2-bad-parameter-type.exp under
valgrind, I see the following issue reported (on x86-64 Fedora):

  (gdb) ptype f
  ==5203== Invalid read of size 1
  ==5203==    at 0x6931FE: process_die_scope::~process_die_scope() (dwarf2read.c:10642)
  ==5203==    by 0x66818F: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10664)
  ==5203==    by 0x66A01F: read_file_scope(die_info*, dwarf2_cu*) (dwarf2read.c:11650)
  ==5203==    by 0x667F2D: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10672)
  ==5203==    by 0x6677B6: process_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10445)
  ==5203==    by 0x66657A: process_queue(dwarf2_per_objfile*) (dwarf2read.c:9945)
  ==5203==    by 0x6559B4: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3163)
  ==5203==    by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034)
  ==5203==    by 0x66622A: dwarf2_read_symtab(partial_symtab*, objfile*) (dwarf2read.c:9811)
  ==5203==    by 0x787984: psymtab_to_symtab(objfile*, partial_symtab*) (psymtab.c:792)
  ==5203==    by 0x786E3E: psym_lookup_symbol(objfile*, int, char const*, domain_enum_tag) (psymtab.c:522)
  ==5203==    by 0x804BD0: lookup_symbol_via_quick_fns(objfile*, int, char const*, domain_enum_tag) (symtab.c:2383)
  ==5203==  Address 0x147ed063 is 291 bytes inside a block of size 4,064 free'd
  ==5203==    at 0x4C2CD5A: free (vg_replace_malloc.c:530)
  ==5203==    by 0x444415: void xfree<void>(void*) (common-utils.h:60)
  ==5203==    by 0x9DA8C2: call_freefun (obstack.c:103)
  ==5203==    by 0x9DAD35: _obstack_free (obstack.c:280)
  ==5203==    by 0x44464C: auto_obstack::~auto_obstack() (gdb_obstack.h:73)
  ==5203==    by 0x68AFB0: dwarf2_cu::~dwarf2_cu() (dwarf2read.c:25080)
  ==5203==    by 0x68B204: free_one_cached_comp_unit(dwarf2_per_cu_data*) (dwarf2read.c:25174)
  ==5203==    by 0x66668C: dwarf2_release_queue(void*) (dwarf2read.c:9982)
  ==5203==    by 0x563A4C: do_my_cleanups(cleanup**, cleanup*) (cleanups.c:154)
  ==5203==    by 0x563AA7: do_cleanups(cleanup*) (cleanups.c:176)
  ==5203==    by 0x5646CE: throw_exception_cxx(gdb_exception) (common-exceptions.c:289)
  ==5203==    by 0x5647B7: throw_exception(gdb_exception) (common-exceptions.c:317)
  ==5203==  Block was alloc'd at
  ==5203==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
  ==5203==    by 0x564BE8: xmalloc (common-utils.c:44)
  ==5203==    by 0x9DA872: call_chunkfun (obstack.c:94)
  ==5203==    by 0x9DA935: _obstack_begin_worker (obstack.c:141)
  ==5203==    by 0x9DAA3C: _obstack_begin (obstack.c:164)
  ==5203==    by 0x4445E0: auto_obstack::auto_obstack() (gdb_obstack.h:70)
  ==5203==    by 0x68AE07: dwarf2_cu::dwarf2_cu(dwarf2_per_cu_data*) (dwarf2read.c:25073)
  ==5203==    by 0x661A8A: init_cutu_and_read_dies(dwarf2_per_cu_data*, abbrev_table*, int, int, void (*)(die_reader_specs const*, unsigned char const*, die_info*, int, void*), void*) (dwarf2read.c:7869)
  ==5203==    by 0x666A29: load_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10108)
  ==5203==    by 0x655847: load_cu(dwarf2_per_cu_data*) (dwarf2read.c:3120)
  ==5203==    by 0x655928: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3148)
  ==5203==    by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034)

There's actually a series of three issues reported, but it turns out
they're all related, so we can consider on the first one.

The invalid read is triggered from a destructor which is being invoked
as part of a stack unwind after throwing an error.  At the time the
error is thrown, the stack looks like this:

    #0  0x00000000009f4ecd in __cxa_throw ()
    #1  0x0000000000564761 in throw_exception_cxx (exception=...) at ../../src/gdb/common/common-exceptions.c:303
    #2  0x00000000005647b8 in throw_exception (exception=...) at ../../src/gdb/common/common-exceptions.c:317
    #3  0x00000000005648ff in throw_it(return_reason, errors, const char *, typedef __va_list_tag __va_list_tag *) (reason=RETURN_ERROR,
        error=GENERIC_ERROR, fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]",
        ap=0x7fff387f2d68) at ../../src/gdb/common/common-exceptions.c:373
    #4  0x0000000000564929 in throw_verror (error=GENERIC_ERROR,
        fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]", ap=0x7fff387f2d68)
        at ../../src/gdb/common/common-exceptions.c:379
    #5  0x0000000000867be4 in verror (string=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]",
        args=0x7fff387f2d68) at ../../src/gdb/utils.c:251
    #6  0x000000000056879d in error (fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]")
        at ../../src/gdb/common/errors.c:43
    #7  0x0000000000686875 in follow_die_ref (src_die=0x30bc8a0, attr=0x30bc8c8, ref_cu=0x7fff387f2ed0) at ../../src/gdb/dwarf2read.c:22969
    #8  0x00000000006844cd in lookup_die_type (die=0x30bc8a0, attr=0x30bc8c8, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21976
    #9  0x0000000000683f27 in die_type (die=0x30bc8a0, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21832
    #10 0x0000000000679b39 in read_subroutine_type (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:17343
    #11 0x00000000006845fb in read_type_die_1 (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22035
    #12 0x0000000000684576 in read_type_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22010
    #13 0x000000000067003f in read_func_scope (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:13822
    #14 0x0000000000667f5e in process_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10679
    #15 0x000000000066a020 in read_file_scope (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:11650
    #16 0x0000000000667f2e in process_die (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10672
    #17 0x00000000006677b7 in process_full_comp_unit (per_cu=0x3089b80, pretend_language=language_minimal)
        at ../../src/gdb/dwarf2read.c:10445
    #18 0x000000000066657b in process_queue (dwarf2_per_objfile=0x30897d0) at ../../src/gdb/dwarf2read.c:9945
    #19 0x00000000006559b5 in dw2_do_instantiate_symtab (per_cu=0x3089b80) at ../../src/gdb/dwarf2read.c:3163
    #20 0x000000000066683e in psymtab_to_symtab_1 (pst=0x3089bd0) at ../../src/gdb/dwarf2read.c:10034
    #21 0x000000000066622b in dwarf2_read_symtab (self=0x3089bd0, objfile=0x3073f40) at ../../src/gdb/dwarf2read.c:9811
    #22 0x0000000000787985 in psymtab_to_symtab (objfile=0x3073f40, pst=0x3089bd0) at ../../src/gdb/psymtab.c:792
    #23 0x0000000000786e3f in psym_lookup_symbol (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/psymtab.c:522
    #24 0x0000000000804bd1 in lookup_symbol_via_quick_fns (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/symtab.c:2383
    #25 0x0000000000804fe4 in lookup_symbol_in_objfile (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/symtab.c:2558
    #26 0x0000000000805125 in lookup_static_symbol (name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/symtab.c:2595
    #27 0x0000000000804357 in lookup_symbol_aux (name=0x30b2e30 "f", match_type=symbol_name_match_type::FULL, block=0x0,
        domain=VAR_DOMAIN, language=language_c, is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:2105
    #28 0x0000000000803ad9 in lookup_symbol_in_language (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, lang=language_c,
        is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1887
    #29 0x0000000000803b53 in lookup_symbol (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, is_a_field_of_this=0x0)
        at ../../src/gdb/symtab.c:1899
    #30 0x000000000053b246 in classify_name (par_state=0x7fff387f6090, block=0x0, is_quoted_name=false, is_after_structop=false)
        at ../../src/gdb/c-exp.y:2879
    #31 0x000000000053b7e9 in c_yylex () at ../../src/gdb/c-exp.y:3083
    #32 0x000000000053414a in c_yyparse () at c-exp.c:1903
    #33 0x000000000053c2e7 in c_parse (par_state=0x7fff387f6090) at ../../src/gdb/c-exp.y:3255
    #34 0x0000000000774a02 in parse_exp_in_context_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0)
        at ../../src/gdb/parse.c:1213
    #35 0x000000000077476a in parse_exp_in_context (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0)
        at ../../src/gdb/parse.c:1115
    #36 0x0000000000774714 in parse_exp_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0) at ../../src/gdb/parse.c:1106
    #37 0x0000000000774c53 in parse_expression (string=0x27ff996 "f") at ../../src/gdb/parse.c:1253
    #38 0x0000000000861dc4 in whatis_exp (exp=0x27ff996 "f", show=1) at ../../src/gdb/typeprint.c:472
    #39 0x00000000008620d8 in ptype_command (type_name=0x27ff996 "f", from_tty=1) at ../../src/gdb/typeprint.c:561
    #40 0x000000000047430b in do_const_cfunc (c=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:106
    #41 0x000000000047715e in cmd_func (cmd=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:1886
    #42 0x00000000008431bb in execute_command (p=0x27ff996 "f", from_tty=1) at ../../src/gdb/top.c:630
    #43 0x00000000006bf946 in command_handler (command=0x27ff990 "ptype f") at ../../src/gdb/event-top.c:583
    #44 0x00000000006bfd12 in command_line_handler (rl=0x30bb3a0 "\240\305\v\003") at ../../src/gdb/event-top.c:774

The problem is that in `process_die` (frames 14 and 16) we create a
`process_die_scope` object, that takes a copy of the `struct
dwarf2_cu *` passed into the frame.  The destructor of the
`process_die_scope` dereferences the stored pointer.  This wouldn't be
an issue, except...

... in dw2_do_instantiate_symtab (frame 19) a clean up was registered that
clears the dwarf2_queue in case of an error.  Part of this clean up
involves deleting the `struct dwarf2_cu`s referenced from the queue..

The problem then, is that cleanups are processed at the site of the
throw, while, class destructors are invoked as we unwind their frame.
The result is that we process the frame 19 cleanup (and delete the
struct dwarf2_cu) before we process the destructors in frames 14 and 16.
When we do get back to frames 14 and 16 the objects being references
have already been deleted.

The solution is to remove the cleanup from dw2_do_instantiate_symtab, and
instead use a destructor to release the dwarf2_queue instead.  With this
patch in place, the valgrind errors are now resolved.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_release_queue): Delete function, move body
into...
(class dwarf2_queue_guard): ...the destructor of this new class.
(dw2_do_instantiate_symtab): Create instance of the new class
dwarf2_queue_guard, remove cleanup.

6 years agoMIPS/GAS/test: Fix an n32 `.reginfo' size test failure
Maciej W. Rozycki [Mon, 12 Feb 2018 16:04:05 +0000 (16:04 +0000)]
MIPS/GAS/test: Fix an n32 `.reginfo' size test failure

Correct a commit 2d6dda71611b ("MIPS/BFD: Correctly report unsupported
`.reginfo' section size") issue and avoid a GAS test failure:

regexp_diff match failure
regexp "^.*: Incorrect `\.reginfo' section size; expected 24, got 28$"
line   "../as-new: dump.o: Incorrect `.reginfo' section size; expected 24, got 32"
FAIL: MIPS assembled .reginfo section size (n32)

on MIPS targets other than bare-metal ones.  The reason for this failure
is section padding to alignment, done in `size_seg'.  For n32 `.reginfo'
the section alignment is set to 3, and therefore the section is padded
to a multiple of 8, except for bare-metal targets, for which padding is
unconditionally disabled in `md_section_align'.

Use `--no-pad-sections' then to disable padding for all targets, so that
the size of `.reginfo' is always the same, matching the message pattern.

gas/
* testsuite/gas/mips/reginfo-2-n32.d: Add `--no-pad-sections' to
`as' flags.

6 years agoMIPS: Fix encoding for MIPSr6 sigrie instruction.
Henry Wong [Mon, 12 Feb 2018 14:50:42 +0000 (14:50 +0000)]
MIPS: Fix encoding for MIPSr6 sigrie instruction.

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

References:

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

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

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

gas/
* testsuite/gas/mips/r6.d: Update for "sigrie" encoding fix.
* testsuite/gas/mips/r6-n32.d: Likewise.
* testsuite/gas/mips/r6-n64.d: Likewise.

6 years agoAdd support for reading msdos MZ executables.
Zebediah Figura [Mon, 12 Feb 2018 13:12:45 +0000 (13:12 +0000)]
Add support for reading msdos MZ executables.

See email thread starting here:  https://www.sourceware.org/ml/binutils/2018-01/msg00001.html

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

bfd * i386msdos.c (msdos_mkobject); New function.
(msdos_object_p): New function.
(i386_msdos_vec): Use msdos_object_p as the check_format
function.
* peicode.h: Rename external_PEI_DOS_hdr, DOSMAGIC, and
NT_SIGNATURE to external_DOS_hdr, IMAGE_DOS_SIGNATURE, and
IMAGE_NT_SIGNATURE.
* peXXigen.c: Likewise.
* coff-ia64.c: Likewise.

6 years agoUpdate Russian translation for the gas/ sub-directory.
Nick Clifton [Mon, 12 Feb 2018 12:10:50 +0000 (12:10 +0000)]
Update Russian translation for the gas/ sub-directory.

6 years agoFix compile time warning: bfd/elf32-arc.c:1537]: (warning) Redundant assignment of...
Nick Clifton [Mon, 12 Feb 2018 11:57:41 +0000 (11:57 +0000)]
Fix compile time warning: bfd/elf32-arc.c:1537]: (warning) Redundant assignment of 'rel->r_offset' to itself.

* elf32-arc.c (elf_arc_relocate_section):  Remove redundant
assignment.

6 years agooops - actually remove the assignment this time: bfd/elf32-nds32.c:9693]: (warning...
Nick Clifton [Mon, 12 Feb 2018 11:54:48 +0000 (11:54 +0000)]
oops - actually remove the assignment this time: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself.

6 years agoFix compile time warning: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment...
Nick Clifton [Mon, 12 Feb 2018 11:51:56 +0000 (11:51 +0000)]
Fix compile time warning: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself.

* elf32-nds32.c (nds32_elf_relax_longjump3): Remove redundant
assignment.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 12 Feb 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 11 Feb 2018 00:01:01 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoFix commit date.
Eric Botcazou [Sat, 10 Feb 2018 01:37:32 +0000 (02:37 +0100)]
Fix commit date.

6 years agoFix GOT relocation overflow on SPARC.
Eric Botcazou [Sat, 10 Feb 2018 01:30:25 +0000 (02:30 +0100)]
Fix GOT relocation overflow on SPARC.

There are 2 failures left in the linker testsuite on SPARC64/Linux and
they are caused by 2 different issues leading to the same end effect:
the overflow of the relocation section for the GOT, i.e. the linker
generates too many dynamic relocations for the GOT wrt the size of the
relocation section, leading to memory corruption and missing relocations
in the final binary.

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

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

bfd/
* elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Reorder conditions.
(sparc_elf_append_rela): Assert that there is enough room in section.
(_bfd_sparc_elf_copy_indirect_symbol): Fix formatting.
(_bfd_sparc_elf_adjust_dynamic_symbol): Minor tweak.
(allocate_dynrelocs): Remove outdated comments and reorder conditions.
For a symbol subject to a GOT relocation, reserve a slot in the
relocation section if the symbol isn't dynamic and we are in PIC mode.
(_bfd_sparc_elf_relocate_section) <R_SPARC_GOTDATA_OP>: If relocation
is relaxed and a slot was reserved, generate a R_SPARC_NONE relocation.
<R_SPARC_GOTDATA_OP_HIX22>: Adjust comments.
<R_SPARC_PC10>: Reorder conditions.  Remove always-false assertion.
(_bfd_sparc_elf_finish_dynamic_symbol): Rename local_undefweak into
resolved_to_zero.  Do not generate a dynamic GOT relocation for an
undefined weak symbol with non-default visibility.  Remove superfluous
'else' and fix formatting.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 10 Feb 2018 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agox86: Add is_solaris to elf_x86_target_os
H.J. Lu [Fri, 9 Feb 2018 16:44:42 +0000 (08:44 -0800)]
x86: Add is_solaris to elf_x86_target_os

Add is_solaris to elf_x86_target_os since Solaris is quite different.

* elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle
is_solaris.
(i386_elf32_sol2_vec): Don't declare.
(elf_i386_link_setup_gnu_properties): Also handle is_solaris.
Don't set need_global_offset_table.
(elf_i386_solaris_arch_bed): New.
(elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for
Solaris.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check
target_os != is_nacl instead of target_os == is_normal.
(x86_64_elf64_sol2_vec): Don't declare.
(elf_x86_64_link_setup_gnu_properties): Check target_os !=
is_nacl instead of target_os == is_normal.  Don't set
need_global_offset_table.
(elf_x86_64_solaris_arch_bed): New.
(elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for
Solaris.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep
_GLOBAL_OFFSET_TABLE_ for Solaris.
(_bfd_x86_elf_link_setup_gnu_properties): Don't copy
need_global_offset_table.
* elfxx-x86.h (elf_x86_target_os): Add is_solaris.
(elf_x86_link_hash_table): Remove need_global_offset_table.
(elf_x86_init_table): Likewise.

6 years agoDon't reference past the end of the vector
Tom Tromey [Fri, 9 Feb 2018 12:58:46 +0000 (05:58 -0700)]
Don't reference past the end of the vector

An earlier change made find_source_lines read:

    end = &data[size];

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

    end = data.data () + size;

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

* source.c (find_source_lines): Don't reference past the end of
the vector.

6 years agobtrace: reword error messages
Markus Metzger [Thu, 8 Feb 2018 13:35:44 +0000 (14:35 +0100)]
btrace: reword error messages

Reword some btrace error messages to align with the format discussed in
https://sourceware.org/ml/gdb-patches/2018-02/msg00135.html.

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

testsuite/
* lib/gdb.exp (skip_btrace_pt_tests): Update expected error message.
Fix test name.

6 years agobtrace: check perf_event_paranoid
Markus Metzger [Fri, 19 Jan 2018 14:17:43 +0000 (15:17 +0100)]
btrace: check perf_event_paranoid

One recurring error on Debian systems is that the default perf_event_paranoid
setting disables the perf_event interface for user-space.

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

gdb/
* nat/linux-btrace.c (diagnose_perf_event_open_fail): New.
(linux_enable_pt, linux_enable_bts): Call
diagnose_perf_event_open_fail.

6 years agobtrace: improve enable error messages
Markus Metzger [Fri, 19 Jan 2018 12:56:32 +0000 (13:56 +0100)]
btrace: improve enable error messages

Improve the error message when GDB fails to start recording branch trace.

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

gdb/
* nat/linux-btrace.c (perf_event_pt_event_type): Improve error message.
Remove parameter and change return type.  Update callers.  Move it.
(linux_enable_bts, linux_enable_pt): Improve error message.
(linux_enable_pt): Remove zero buffer size check.
(linux_enable_btrace): Improve error messages.  Remove NULL return
check.

6 years agobtrace, gdbserver: remove the to_supports_btrace target method
Markus Metzger [Fri, 19 Jan 2018 13:32:09 +0000 (14:32 +0100)]
btrace, gdbserver: remove the to_supports_btrace target method

Remove the to_supports_btrace target method and instead rely on detecting errors
when trying to enable recording.  This will also provide a suitable error
message explaining why recording is not possible.

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

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

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

gdbserver/
* linux-low.c (linux_target_ops): Remove linux_supports_btrace.
* nto-low.c (nto_target_ops): Remove NULL for supports_btrace.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c (win32_target_ops): Likewise.
* server.c (supported_btrace_packets): Report packets unconditionally.
* target.h (target_ops) <supports_btrace>: Remove.
(target_supports_btrace): Remove.

6 years agobtrace, gdbserver: use exceptions to convey btrace enable/disable errors
Markus Metzger [Fri, 19 Jan 2018 08:41:42 +0000 (09:41 +0100)]
btrace, gdbserver: use exceptions to convey btrace enable/disable errors

Change error reporting to use exceptions and be prepared to catch them in
gdbserver.  We use the exception message in our error reply to GDB.

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

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

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

gdb/
* nat/linux-btrace.c (linux_enable_btrace): Throw exception if enabling
btrace failed.
* x86-linux-nat.c (x86_linux_enable_btrace): Catch btrace enabling
exception and use message in own exception.

6 years agobtrace: prepare for throwing exceptions when enabling btrace
Markus Metzger [Fri, 19 Jan 2018 08:38:33 +0000 (09:38 +0100)]
btrace: prepare for throwing exceptions when enabling btrace

We indicate success or failure for enabling branch tracing via the pointer
return value.  Depending on the type of error, errno may provide additional
information.

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

gdb/
* nat/linux-btrace.c: Include scoped_fd.h and scoped_mmap.h.
(perf_event_pt_event_type): Use gdb_file_up.
(linux_enable_bts, linux_enable_pt): Use gdb::unique_xmalloc_ptr,
scoped_fd, and scoped_mmap.

6 years agocommon: add scoped_mmap
Markus Metzger [Fri, 26 Jan 2018 12:57:48 +0000 (13:57 +0100)]
common: add scoped_mmap

Add a simple helper to automatically unmap a memory mapping.

gdb/
* common/scoped_mmap.h: New.
* unittests/scoped_mmap-selftest.c: New.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/scoped_mmap-selftest.c.

6 years agocommon: add scoped_fd
Markus Metzger [Fri, 26 Jan 2018 12:07:29 +0000 (13:07 +0100)]
common: add scoped_fd

Add a simple helper to automatically close a file descriptor.

gdb/
* common/scoped_fd.h: New.
* unittests/scoped_fd-selftest.c: New.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/scoped_fd-selftest.c.

6 years agoUse gdb::unique_xmalloc_ptr in auto_load_section_scripts
Tom Tromey [Thu, 8 Feb 2018 19:08:58 +0000 (12:08 -0700)]
Use gdb::unique_xmalloc_ptr in auto_load_section_scripts

This changes auto_load_section_scripts to use gdb::unique_xmalloc_ptr,
allowing the removal of a cleanup.

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

* auto-load.c (auto_load_section_scripts): Use
gdb::unique_xmalloc_ptr.

6 years agoUse std::string in execute_script_contents
Tom Tromey [Thu, 8 Feb 2018 19:06:44 +0000 (12:06 -0700)]
Use std::string in execute_script_contents

This changes execute_script_contents to use a std::string, allowing
the removal of a cleanup.

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

* auto-load.c (execute_script_contents): Use std::string.

6 years agogdb/NEWS: Clarify the news entry for "rbreak" in GDB 8.1
Joel Brobecker [Fri, 9 Feb 2018 12:04:38 +0000 (16:04 +0400)]
gdb/NEWS: Clarify the news entry for "rbreak" in GDB 8.1

gdb/ChangeLog:

        * NEWS <Changes in GDB 8.1>: Clarify that "rbreak" is a new
        Python function, rather than a new command.

6 years agox86: Set need_global_offset_table with info->output_bfd->xvec
H.J. Lu [Fri, 9 Feb 2018 00:29:19 +0000 (16:29 -0800)]
x86: Set need_global_offset_table with info->output_bfd->xvec

* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
Remove prototype.
(i386_elf32_sol2_vec): Declared.
(elf_i386_link_setup_gnu_properties): Set
need_global_offset_table with info->output_bfd->xvec.
* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
Remove prototype.
(x86_64_elf64_sol2_vec): Declared.
(elf_x86_64_link_setup_gnu_properties): Set
need_global_offset_table with info->output_bfd->xvec.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 9 Feb 2018 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agox86: Keep the unused _GLOBAL_OFFSET_TABLE_ for Solaris
H.J. Lu [Thu, 8 Feb 2018 21:52:22 +0000 (13:52 -0800)]
x86: Keep the unused _GLOBAL_OFFSET_TABLE_ for Solaris

Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it isn't used.
This patch detects Solaris target and keeps _GLOBAL_OFFSET_TABLE_ for
Solaris.

* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
New prototype.
(elf_i386_link_setup_gnu_properties): Set need_global_offset_table
for Solaris.
* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
New prototype.
(elf_x86_64_link_setup_gnu_properties): Set
need_global_offset_table for Solaris.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep the
unused _GLOBAL_OFFSET_TABLE_ for Solaris.
(_bfd_x86_elf_link_setup_gnu_properties): Copy
need_global_offset_table.
* elfxx-x86.h (elf_x86_link_hash_table): Add
need_global_offset_table.
(elf_x86_init_table): Likewise.

6 years agoRISC-V: Add comment for previous change.
Jim Wilson [Thu, 8 Feb 2018 21:15:10 +0000 (13:15 -0800)]
RISC-V: Add comment for previous change.

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous
change.

6 years agoRemove cleanups from solib.c
Tom Tromey [Tue, 6 Feb 2018 20:00:40 +0000 (13:00 -0700)]
Remove cleanups from solib.c

This removes a couple of cleanups from solib.c, replacing one with
std::string and another with unique_xmalloc_ptr.

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

* solib.c (solib_find_1): Use std::string.
(solib_bfd_fopen): Use unique_xmalloc_ptr.

6 years agoUse unique_xmalloc_ptr in build_id_to_debug_bfd
Tom Tromey [Tue, 6 Feb 2018 19:54:44 +0000 (12:54 -0700)]
Use unique_xmalloc_ptr in build_id_to_debug_bfd

This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr,
removing a cleanup.

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

* build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr.

6 years agoUse gdb::def_vector in find_source_lines
Tom Tromey [Tue, 6 Feb 2018 19:51:42 +0000 (12:51 -0700)]
Use gdb::def_vector in find_source_lines

This replaces an explicit malloc and a cleanup with a gdb::def_vector.

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

* source.c (find_source_lines): Use gdb::def_vector.

6 years agoRemove cleanups from macro_define_command
Tom Tromey [Tue, 6 Feb 2018 19:25:00 +0000 (12:25 -0700)]
Remove cleanups from macro_define_command

This removes cleanups from macro_define_command, by introducing a new
struct temporary_macro_definition that cleans up after itself.

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

* macrocmd.c (struct temporary_macro_definition): New.
(macro_define_command): Use temporary_macro_definition.  Remove
cleanups.
(free_macro_definition_ptr): Remove.

6 years agoUse std::string in maybe_expand
Tom Tromey [Tue, 6 Feb 2018 19:11:21 +0000 (12:11 -0700)]
Use std::string in maybe_expand

This patch changes maybe_expand to use std::string rather than an
explicit malloc and a cleanup.

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

* macroexp.c (maybe_expand): Use std::string.

6 years agoClass-ify macro_buffer
Tom Tromey [Tue, 6 Feb 2018 19:10:20 +0000 (12:10 -0700)]
Class-ify macro_buffer

This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members.  Then this is
used to remove various cleanups in macroexp.c.

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

* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type.  Remove argc_p argument,
add args_ptr argument.  Use std::vector.
(substitute_args): Remove argc argument.  Accept std::vector.
(expand): Update.  Use std::vector.
(scan, macro_expand, macro_expand_next): Update.

6 years agoReturn unique_xmalloc_ptr from macro scope functions
Tom Tromey [Tue, 6 Feb 2018 00:02:00 +0000 (01:02 +0100)]
Return unique_xmalloc_ptr from macro scope functions

This changes the macro scope functions (sal_macro_scope,
user_macro_scope, and default_macro_scope) to return a
unique_xmalloc_ptr, then fixes up the users.  This allowed for the
removal of several cleanups.

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

* symtab.c (default_collect_symbol_completion_matches_break_on):
Use unique_xmalloc_ptr.
* macroscope.h: (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroscope.c (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroexp.h (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macroexp.c (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macrocmd.c (macro_expand_command, macro_expand_once_command)
(info_macro_command, info_macros_command): Use
unique_xmalloc_ptr.
* compile/compile-c-support.c (write_macro_definitions): Use
unique_xmalloc_ptr.
* c-exp.y (c_parse): Use unique_xmalloc_ptr.

6 years agoRemove make_cleanup_restore_current_thread from gdbserver
Tom Tromey [Mon, 5 Feb 2018 09:59:52 +0000 (10:59 +0100)]
Remove make_cleanup_restore_current_thread from gdbserver

This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.

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

* linux-low.c (install_software_single_step_breakpoints): Use
make_scoped_restore.
* inferiors.c (make_cleanup_restore_current_thread): Remove.
(do_restore_current_thread_cleanup): Remove.
* gdbthread.h (make_cleanup_restore_current_thread): Don't
declare.

6 years agoRemove a cleanup from gdbserver
Tom Tromey [Mon, 5 Feb 2018 09:53:57 +0000 (10:53 +0100)]
Remove a cleanup from gdbserver

This removes a cleanup from gdbserver's set_raw_breakpoint_at,
replacing it with unique_xmalloc_ptr.

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

* mem-break.c (set_raw_breakpoint_at): Use
gdb::unique_xmalloc_ptr.

6 years agoSpeed up readelf and objdump by not looking for DWO links unless the user has request...
Nick Clifton [Thu, 8 Feb 2018 12:29:07 +0000 (12:29 +0000)]
Speed up readelf and objdump by not looking for DWO links unless the user has requested that they be displayed/followed.

PR 22802
* dwarf.c (load_separate_debug_file): Return early if the user is
not interested in debug links.

6 years agoFix a seg-fault in the ELF note parser when a note with an excessively large alignmen...
Nick Clifton [Thu, 8 Feb 2018 10:28:25 +0000 (10:28 +0000)]
Fix a seg-fault in the ELF note parser when a note with an excessively large alignment is encountered.

PR 22788
* elf.c (elf_parse_notes): Reject notes with excessuively large
alignments.

6 years agoPR22819, powerpc gas "instruction address is not a multiple of 4"
Alan Modra [Wed, 7 Feb 2018 23:48:59 +0000 (10:18 +1030)]
PR22819, powerpc gas "instruction address is not a multiple of 4"

Checks for insn alignment were hopelessly confused when misaligned
data starts a new frag.  The real-world testcase happened to run out
of frag space in the middle of emitting a trace-back table via
something like:
.byte 0 /* VERSION=0 */
  .byte 9 /* LANG=C++ */
.byte 34 /* Bits on: has_tboff, fp_present */
.byte 64 /* Bits on: name_present */
.byte 128 /* Bits on: stores_bc, FP_SAVED=0 */
.byte 0 /* Bits on: GP_SAVED=0 */
.byte 2 /* FIXEDPARMS=2 */
.byte 1 /* FLOATPARMS=0, parmsonstk */
.long 0
.long 768 /* tb_offset: 0x300 */
.hword 45 /* Function name length: 45 */
  .long 0x334e5a5f
.long 0x31766f70
.long 0x65744932
.long 0x69746172
.long 0x7a5f6e6f
.long 0x64504533
.long 0x5f534e50
.long 0x72463431
.long 0x61746361
.long 0x74535f6c
.long 0x74637572
.byte 0x45
.byte 0
The trigger being those misaligned .long's output for the function
name.  A most horrible way to output a string, especially considering
endian issues..

PR 22819
* config/tc-ppc.c (md_assemble): Rewrite insn alignment checking.
(ppc_frag_check): Likewise.
* testsuite/gas/ppc/misalign.d,
* testsuite/gas/ppc/misalign.l,
* testsuite/gas/ppc/misalign.s: New test.
* testsuite/gas/ppc/misalign2.d,
* testsuite/gas/ppc/misalign2.s: New test.
* testsuite/gas/ppc/ppc.exp: Run them.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 8 Feb 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix type of values representing optimized out static members
Simon Marchi [Wed, 7 Feb 2018 13:48:14 +0000 (08:48 -0500)]
Fix type of values representing optimized out static members

As reported here:

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

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

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

gdb/ChangeLog:

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

gdb/testsuite/ChangeLog:

* gdb.cp/m-static.exp: Check type of optimized out static
member.

6 years agoRevert "PowerPC PLT speculative execution barriers"
Alan Modra [Mon, 5 Feb 2018 02:47:52 +0000 (13:17 +1030)]
Revert "PowerPC PLT speculative execution barriers"

This reverts most of commit 1be5d8d3bb.
Left in place are addition of --no-plt-align to some ppc32 ld tests
and the ld.texinfo --no-plt-thread-safe fix.

6 years agoRISC-V: Eliminate spurious error w/ reloc truncated message
Jim Wilson [Wed, 7 Feb 2018 00:53:00 +0000 (16:53 -0800)]
RISC-V: Eliminate spurious error w/ reloc truncated message

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used
callback to report an error.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Feb 2018 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoRemove some $ARCH_read_pc and $ARCH_write_pc
Yao Qi [Tue, 6 Feb 2018 17:31:33 +0000 (17:31 +0000)]
Remove some $ARCH_read_pc and $ARCH_write_pc

Nowadays, gdbarch_read_pc is called in this way,

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

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

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

gdb:

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

* ft32-tdep.c (ft32_read_pc): Remove.
(ft32_write_pc): Remove.
(ft32_gdbarch_init): Update.
* m32r-tdep.c (m32r_read_pc): Remove.
(m32r_gdbarch_init): Update.
* mep-tdep.c (mep_read_pc): Remove.
(mep_gdbarch_init): Update.
* microblaze-tdep.c (microblaze_write_pc): Remove.
(microblaze_gdbarch_init): Update.
* mn10300-tdep.c (mn10300_read_pc): Remove.
(mn10300_write_pc): Remove.
(mn10300_gdbarch_init): Update.
* moxie-tdep.c (moxie_read_pc): Remove.
(moxie_write_pc): Remove.
(moxie_gdbarch_init): Update.

6 years agoFix PR ld/22263 on SPARC.
Eric Botcazou [Tue, 6 Feb 2018 17:15:56 +0000 (18:15 +0100)]
Fix PR ld/22263 on SPARC.

This is -fpie -pie generating dynamic relocations in the text section,
simply because no TLS transitions are applied in PIE mode.  The meat
of the patch is to turn calls to bfd_link_pic (info) in TLS-related code
into !bfd_link_executable (info) and there are quite a lot of them...

bfd/
* elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic
into call to !bfd_link_executable and tidy up.
(_bfd_sparc_elf_check_relocs): Fix formatting and tidy up.
<R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_IE_HI22>: Likewise.
<GOT relocations>: Remove useless code, tidy and merge blocks.
<R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_WPLT30>: Tidy up.
(_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call
to !bfd_link_executable.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_relocate_section): Fix formatting and tidy up.
<R_SPARC_TLS_GD_HI22>: Merge into...
<R_SPARC_TLS_GD_LO10>: ...this.  Adjust 4th argument in call to
sparc_elf_tls_transition and remove redundant code.
<R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_LDO_HIX22>: Likewise.
<R_SPARC_TLS_LE_HIX22>: Likewise.  Tidy up.
<R_SPARC_TLS_LDM_CALL>: Likewise.
<R_SPARC_TLS_GD_CALL>: Likewise.  Tidy up.
<R_SPARC_TLS_GD_ADD>: Likewise.
<R_SPARC_TLS_LDM_ADD>: Likewise.
<R_SPARC_TLS_LDO_ADD>: Likewise.
<R_SPARC_TLS_IE_LD>: Likewise.
ld/
* testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC.
(pr22263-1): Pass AFLAGS_PIC to the assembler.
* testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie32.dd: Adjust to above.
* testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie64.dd: Adjust to above.

6 years agoTreat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL
Yao Qi [Tue, 6 Feb 2018 17:12:12 +0000 (17:12 +0000)]
Treat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL

When I debug some fortran expression parsing, I got

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

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

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

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

gdb:

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

* expprint.c (print_subexp_standard): Handle
OP_F77_UNDETERMINED_ARGLIST.
(dump_subexp_body_standard): Likewise.

6 years agoFix up one ChangeLog entry date
Yao Qi [Tue, 6 Feb 2018 17:05:59 +0000 (17:05 +0000)]
Fix up one ChangeLog entry date

The patch was committed on 5th Feb, and the first line of ChangeLog
entry is too long.  The max line length is 74.
https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog

6 years agoImprove the find_nearest_line function for the MIPS target so that it tries harder...
Nick Clifton [Tue, 6 Feb 2018 17:00:25 +0000 (17:00 +0000)]
Improve the find_nearest_line function for the MIPS target so that it tries harder to find a function name.

PR 22789
* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf
functions failed to find the function name, try the generic elf
find function instead.

6 years agoFix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.c
Sergio Durigan Junior [Tue, 6 Feb 2018 15:37:04 +0000 (10:37 -0500)]
Fix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.c

GCC 8 will bring a new warning option which will detect possible
overflow and truncation on string manipulation functions.  For more
details, see:

  https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00471.html

While compiling BFD with it, I can see one place on bfd/coff-rs6000.c
where the warning is triggered.  This:

  (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);

will not include the trailing NUL on fhdr.magic, but that's fine
because it's a magic number.  The fix is trivial: just use memcpy
instead.

OK to push?

2018-02-06  Sergio Durigan Junior  <sergiodj@redhat.com>

* coff-rs6000.c (xcoff_write_archive_contents_old): Use
'memcpy' instead of 'strncpy' when writing the magic number.

6 years agoReplace reachable assertion with a test and return of NULL.
Nick Clifton [Tue, 6 Feb 2018 16:05:13 +0000 (16:05 +0000)]
Replace reachable assertion with a test and return of NULL.

PR 22793
* readelf.c (find_section): Replace assertion with test and return
of NULL.
(find_section_by_address): Add test of section header table
existance.
(find_section_by_type): Likewise.
(find_section_in_set): Likewise.

6 years agoPrevent attempts to call strncpy with a zero-length field by chacking the size of...
Nick Clifton [Tue, 6 Feb 2018 15:48:29 +0000 (15:48 +0000)]
Prevent attempts to call strncpy with a zero-length field by chacking the size of debuglink sections.

PR 22794
* opncls.c (bfd_get_debug_link_info_1): Check the size of the
section before attempting to read it in.
(bfd_get_alt_debug_link_info): Likewise.

6 years agoAllow the find_abstract_instance_name() function in the BFD library to also return...
Paul Carroll [Tue, 6 Feb 2018 15:45:31 +0000 (15:45 +0000)]
Allow the find_abstract_instance_name() function in the BFD library to also return file and line number information.

The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available.
We have a tool that consumes this information and displays it.
This identified a problem with the 'nm' utility.

When a source is compiled with -O2, functions can be inlined.  The compiler also produces an uninlined copy of the function, normally for linking to other object files.
In the case of DWARF2 debug information, the compiler generates debug information to describe a function.  If that function is inlined, the compiler then references that debug information from the inlined and uninlined copies of the routine through the use of the DW_AT_abstract_origin reference.
When nm is used on such a file, it is not able to find file and line information because that information is present in the common debug information and not at each actual implementation of the function.
The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more.

What I am proposing is to modify the find_abstract_instance_name() function (which I renamed to find_abstract_instance() ) to return the name of the function as well as any file and line information.  The routine is already parsing all of the debug information in the abstract instance, so it is easy to pick up the file and line information at that time. If, for some reason, the file and line information is not present, the routine behaves as before.

For example, if I have a simple test case:

int foo(int j)
{
        if (j < 15)
                j += j << 2;
        else
                j += j << 6;
        return j;
}

int main (int argc,char **argv)
{
        int i = argc;
        i += foo(i);
        return i;
}

If that test case is compiled with -O2 and then 'nm -l' reads that executable, it currently produces this symbol output (ignoring a lot of library symbols):

8048400 T foo
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12

If I modify 'nm' to return file and line information for abstract instances, it produces the following output:

08048400 T foo  /scratch/pcarroll/its254/test/mytest.c:1
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12
--------------------------------------------------------------------------
bfd * bfd/dwarf2.c (find_abstract_name): Modified to return file and
line information in addition to name, if they can be found.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Feb 2018 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoppc64: Fix stwux encoding
Jan Kratochvil [Mon, 5 Feb 2018 19:19:49 +0000 (20:19 +0100)]
ppc64: Fix stwux encoding

With gcc-8.0.1-0.9.fc28.x86_64 I get:

../../gdb/rs6000-tdep.c: In function 'CORE_ADDR skip_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, rs6000_framedata*)':
../../gdb/rs6000-tdep.c:1911:34: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
       else if ((op & 0xfc1f016a) == 0x7c01016e)
                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.alangref/idalangref_stwux_stux_instrs.htm
says
bit 21 - 30 = 183
Those are bits 1..10 in normal bit order: 183<<1 = 0x16e

gdb/ChangeLog
2018-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

* rs6000-tdep.c (skip_prologue): Fix stwux encoding.

6 years ago[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution...
Renlin Li [Sat, 3 Feb 2018 13:18:17 +0000 (13:18 +0000)]
[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared object.

The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi
will be used to generate an address does not hold for absolute symbol.
In this case, it is a value fixed at static linking time.

The condition to check the relocations is relax to allow absolute symbol and
undefined symbol case.

bfd/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
check for writeable section as well.

ld/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
* testsuite/ld-aarch64/pr22764.s: New.
* testsuite/ld-aarch64/pr22764.d: New.

6 years agoRemove myself as a write-after-approval GDB maintainer.
Antoine Tremblay [Mon, 5 Feb 2018 16:38:08 +0000 (11:38 -0500)]
Remove myself as a write-after-approval GDB maintainer.

Since I'll be leaving Ericsson.

gdb/
* MAINTAINERS (Write After Approval): Remove Antoine Tremblay.

6 years agox86: Remove the unused _GLOBAL_OFFSET_TABLE_
H.J. Lu [Mon, 5 Feb 2018 16:38:16 +0000 (08:38 -0800)]
x86: Remove the unused _GLOBAL_OFFSET_TABLE_

Since _GLOBAL_OFFSET_TABLE_ may be referenced implicitly on x86,
checking ref_regular_nonweak leaves the unused _GLOBAL_OFFSET_TABLE_
in output.  This patch checks explicit GOT references instead.

ld-i386/discarded1.s and ld-x86-64/discarded1.s are updated to avoid
linker optimization which removes GOT references.

bfd/

PR ld/22782
* elf32-i386.c (elf_i386_check_relocs): Set got_referenced if
_GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve
undefined weak symbol to 0.
* elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced
if _GLOBAL_OFFSET_TABLE_ is referenced.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check
got_referenced instead of ref_regular_nonweak.  Remove the
unused _GLOBAL_OFFSET_TABLE_ from symbol table.
* elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced.

ld/

PR ld/22782
* testsuite/ld-i386/discarded1.s: Replace mov with div.
* testsuite/ld-x86-64/discarded1.s: Likewise.
* testsuite/ld-i386/i386.exp: Run pr22782.
* testsuite/ld-i386/load1-nacl.d: Updated for removing
_GLOBAL_OFFSET_TABLE_ from output.
* testsuite/ld-i386/load1.d: Likewise.
* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
* testsuite/ld-x86-64/load1a.d: Likewise.
* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
* testsuite/ld-x86-64/load1b.d: Likewise.
* testsuite/ld-i386/pr22782.d: New file.
* testsuite/ld-i386/pr22782.s: Likewise.
* testsuite/ld-x86-64/pr22782.s: Likewise.
* testsuite/ld-x86-64/pr22782a.d: Likewise.
* testsuite/ld-x86-64/pr22782b.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr22782a and pr22782b.

6 years agoUse visitors for make_gdb_type
Alan Hayward [Mon, 5 Feb 2018 16:33:04 +0000 (16:33 +0000)]
Use visitors for make_gdb_type

Remove the make_gdb_type functions from the tdesc_type_ classes.
Replace with a static make_gdb_type function that uses a element
visitor called gdb_type_creator.

gdb/
* target-descriptions.c (tdesc_element_visitor) Add empty implementations.
(tdesc_type): Move make_gdb_type from here.
(tdesc_type_builtin): Likewise.
(tdesc_type_vector): Likewise.
(tdesc_type_with_fields): Move make_gdb_type_ functions from here.
(make_gdb_type_struct): Move from tdesc_type_with_fields.
(make_gdb_type_union): Likewise.
(make_gdb_type_flags): Likewise.
(make_gdb_type_enum): Likewise.
(make_gdb_type): New function.
(tdesc_register_type): Use static make_gdb_type.

6 years agoRISC-V/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Mon, 5 Feb 2018 14:05:51 +0000 (14:05 +0000)]
RISC-V/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC

Correct a commit f0531ed6a429 ("Compress loads/stores with implicit 0
offset.") regression and remove a `-Wshadow' compilation error:

cc1: warnings being treated as errors
.../gas/config/tc-riscv.c: In function 'riscv_handle_implicit_zero_offset':
.../gas/config/tc-riscv.c:1194: error: declaration of 'expr' shadows a global declaration
.../gas/expr.h:180: error: shadowed declaration is here
make[4]: *** [tc-riscv.o] Error 1

which for versions of GCC before 4.8 prevents GAS for RISC-V targets
from being built.  See also GCC PR c/53066.

gas/
* config/tc-riscv.c (riscv_handle_implicit_zero_offset): Rename
`expr' parameter to `ep'.

6 years agoRISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC
Maciej W. Rozycki [Mon, 5 Feb 2018 14:05:51 +0000 (14:05 +0000)]
RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC

Correct a commit 9d06997adb88 ("RISC-V: Relax RISCV_PCREL_* to
RISCV_GPREL_*") regression and remove a `-Wmissing-field-initializers'
compilation error:

cc1: warnings being treated as errors
.../bfd/elfnn-riscv.c: In function '_bfd_riscv_relax_pc':
.../bfd/elfnn-riscv.c:3117: error: missing initializer
.../bfd/elfnn-riscv.c:3117: error: (near initialization for 'hi_reloc.hi_addend')
make[4]: *** [elf64-riscv.lo] Error 1

which for versions of GCC before 4.7 prevents support for RISC-V targets
from being built.  See also GCC PR c/36750.

bfd/
* elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to
initialize `hi_reloc'.

6 years agoMIPS/BFD: Correctly report unsupported `.reginfo' section size
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)]
MIPS/BFD: Correctly report unsupported `.reginfo' section size

Report an error when an unsupported `.reginfo' section size is found in
`_bfd_mips_elf_section_processing', removing an assertion that triggers
at elfxx-mips.c:7105 in GAS when assembling input like:

.section .reginfo
.word 0xdeadbeef

and in `objcopy --rename-section' when renaming an incorrectly sized
section to `.reginfo'.

bfd/
* elfxx-mips.c (_bfd_mips_elf_section_processing): For
SHT_MIPS_REGINFO sections don't assert the correct size and
report an error instead.

binutils/
* testsuite/binutils-all/mips/mips-reginfo.d: New test.
* testsuite/binutils-all/mips/mips-reginfo-n32.d: New test.
* testsuite/binutils-all/mips/mips-reginfo.s: New test source.
* testsuite/binutils-all/mips/mips.exp: Run the new tests.

gas/
* testsuite/gas/mips/reginfo-2.d: New test.
* testsuite/gas/mips/reginfo-2-n32.d: New test.
* testsuite/gas/mips/reginfo-2.l: New test stderr output.
* testsuite/gas/mips/reginfo-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

6 years agoELF/BFD: Propagate the return status from backend section processing
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)]
ELF/BFD: Propagate the return status from backend section processing

Fix the issue of any failure from `->elf_backend_section_processing'
not being propagated by `_bfd_elf_write_object_contents'.  The MIPS
`_bfd_mips_elf_section_processing' handler can actually potentially
fail, however the caller currently ignores that.

bfd/
* elf.c (_bfd_elf_write_object_contents): Propagate a failure
status from `->elf_backend_section_processing'.

6 years agobinutils/testsuite: Support stderr options with `run_dump_test'
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)]
binutils/testsuite: Support stderr options with `run_dump_test'

Add support for the `error', `error_output', `warning' and
`warning_output' options for `run_dump_test' input files, based on the
version of the procedure in ld/testsuite/lib/ld-lib.exp and providing
compatible semantics.  These options apply to PROG under test and let
test cases specify output expected on stderr as well as express a
requirement for PROG to exit unsuccessfully.  Messages to match against
can be supplied either inline or fetched from a named file.  Update
procedure description in the introductory comment accordingly.

As the exit status from `remote_exec' is regrettably lost in our default
implementation of `binutils_run', which is user-overridable, avoid
changing this procedure's API and use a global `binutils_run_status'
variable to pass the status up to the caller, similarly to how
`binutils_run_failed' is handled.  Document the new variable in the
respective introductory comments.

binutils/
* testsuite/config/default.exp (binutils_run): Document
`binutils_run_status'.
* testsuite/lib/utils-lib.exp (default_binutils_run): Likewise,
and set it.
(run_dump_test): Add `error', `error_output', `warning' and
`warning_output' options.  Update documentation accordingly.

6 years agoUpdated Brazillian portuguese and Russian translation
Nick Clifton [Mon, 5 Feb 2018 13:09:15 +0000 (13:09 +0000)]
Updated Brazillian portuguese and Russian translation

6 years agoAlign natural-format register values to the same column
Ruslan Kabatsayev [Fri, 19 Jan 2018 06:15:39 +0000 (09:15 +0300)]
Align natural-format register values to the same column

Currently, commands such as "info reg", "info all-reg", as well as register
window in the TUI print badly aligned columns, like here:

eax            0x1      1
ecx            0xffffd3e0       -11296
edx            0xffffd404       -11260
ebx            0xf7fa5ff4       -134586380
esp            0xffffd390       0xffffd390
ebp            0xffffd3c8       0xffffd3c8
esi            0x0      0
edi            0x0      0
eip            0x8048b60        0x8048b60 <main+16>
eflags         0x286    [ PF SF IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x0      0
gs             0x63     99

After this patch, these commands print the third column values consistently
aligned one under another, provided the second column is not too long.
Originally, the third column was (attempted to be) aligned using a simple tab
character. This patch changes the alignment to spaces only. The tests checking
the output and expecting the single tab have been fixed in a previous patch, so
this change doesn't break any.

gdb/ChangeLog:

* infcmd.c (default_print_one_register_info): Align natural-format
column values consistently one under another.
(pad_to_column): New function.

6 years agoMove comment in gdb/dwarf2read.c::dwarf2_physname
Joel Brobecker [Mon, 5 Feb 2018 04:45:06 +0000 (23:45 -0500)]
Move comment in gdb/dwarf2read.c::dwarf2_physname

This commit just moves a comment right next to where it is actually
relevant. No actual code change.

gdb/ChangeLog:

        * dwarf2read.c (dwarf2_physname): Move commment.

Tested by rebuilding GDB.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 5 Feb 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agold/testsuite: Replace -Sw with -SW for readelf
H.J. Lu [Sun, 4 Feb 2018 15:51:10 +0000 (07:51 -0800)]
ld/testsuite: Replace -Sw with -SW for readelf

-Sw is a typo.  It should be -SW for readelf.

* testsuite/ld-i386/lea1d.d: Replace -Sw with -SW.
* testsuite/ld-i386/lea1e.d: Likewise.
* testsuite/ld-i386/lea1f.d: Likewise.
* testsuite/ld-x86-64/lea1g.d: Likewise.
* testsuite/ld-x86-64/lea1h.d: Likewise.
* testsuite/ld-x86-64/lea1i.d: Likewise.
* testsuite/ld-x86-64/lea1j.d: Likewise.
* testsuite/ld-x86-64/lea1k.d: Likewise.
* testsuite/ld-x86-64/lea1l.d: Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 4 Feb 2018 00:01:03 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agogdb/testsuite: Remove use of dejagnu cleanup proc
Andrew Burgess [Fri, 2 Feb 2018 12:51:10 +0000 (12:51 +0000)]
gdb/testsuite: Remove use of dejagnu cleanup proc

The 'cleanup' proc has been removed from dejagnu (Feb 15 2016).  The
proc has not done anything useful since at least 2001 so removing
these calls should be harmless.

gdb/testsuite/ChangeLog:

* config/sid.exp (gdb_target_sid): Remove use of cleanup.
* config/sim.exp (gdb_target_sim): Remove use of cleanup.

6 years agoRemove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbol...
Nick Clifton [Sat, 3 Feb 2018 13:11:35 +0000 (13:11 +0000)]
Remove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbols in PE linker scripts.

PR 22762
* scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and
__DTOR_LIST__ symbols.  Add a comment explaining why this is
necessary.
* scripttemp/pep.sc: Likewise.
* ld.texinfo (PROVIDE): Add a note about the effect of common
symbols.

6 years agoDisable -shared support in nios2-elf-ld.
Sandra Loosemore [Sat, 3 Feb 2018 07:00:02 +0000 (23:00 -0800)]
Disable -shared support in nios2-elf-ld.

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

* emulparams/nios2elf.sh (GENERATE_SHLIB_SCRIPT): Don't set.

6 years agoAdd support for DWARF-4 line number tables.
Cary Coutant [Sat, 3 Feb 2018 01:44:27 +0000 (17:44 -0800)]
Add support for DWARF-4 line number tables.

Reads the maximum_operations_per_instruction field, added in DWARF-4 to the
line number program header.

gold/
* PR gold/22776
* dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog): Add
support for DWARF-4 line number tables.
* dwarf_reader.h (Sized_dwarf_line_info::max_ops_per_insn): New field.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 3 Feb 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoRISC-V: Fix --wrap and relaxation conflict.
Jim Wilson [Fri, 2 Feb 2018 20:43:09 +0000 (12:43 -0800)]
RISC-V: Fix --wrap and relaxation conflict.

bfd/
PR ld/22756
* elfnn-riscv.c (riscv_relax_delete_bytes): New parameter link_info.
If link_info->wrap_hash, check for a duplicate symbol and ignore.
(_bfd_riscv_relax_call, bfd_riscv_relax_lui, _bfd_riscv_relax_tls_le):
Pass new argument to riscv_relax_delete_bytes.
(_bfd_riscv_relax_align, _bfd_riscv_relax_delete): Likewise.  Remove
ATTRIBUTE_UNUSED from link_info parameter.

6 years agoMI: Allow non-raw varobj evaluation
Leszek Swirski via gdb-patches [Fri, 2 Feb 2018 04:23:28 +0000 (23:23 -0500)]
MI: Allow non-raw varobj evaluation

Make the MI variable object expression evaluation, with the
-var-evaluate-expression command, recursively call pretty printers, to
match the output of normal expression printing.

Consider the following code:

        struct Foo { int val; };
        struct Wrapper { Foo foo; };

        int main() {
                Wrapper w;
                w.foo.val = 23;
        }

and this pretty printer file:

        import gdb.printing

        class FooPrinter:
          def __init__(self, val):
            self.val = val
          def to_string(self):
            return "Foo" + str(self.val["val"])

        class WrapperPrinter:
          def __init__(self, val):
            self.val = val
          def to_string(self):
            return self.val["foo"]

        test_printer = gdb.printing.RegexpCollectionPrettyPrinter("test")
        test_printer.add_printer('Foo', '^Foo$', FooPrinter)
        test_printer.add_printer('Wrapper', '^Wrapper$', WrapperPrinter)

        gdb.printing.register_pretty_printer(None, test_printer)

Setting a breakpoint at the end of the function, we call the following commands:

        -enable-pretty-printing
        ^done

        -var-create var_w @ w
        ^done,name="var_w",numchild="0",value="{val = 23}",type="Wrapper",dynamic="1",has_more="0"
        -var-create var_w_foo @ w.foo
        ^done,name="var_w_foo",numchild="0",value="Foo23",type="Foo",dynamic="1",has_more="0"

        -var-evaluate-expression var_w
        ^done,value="{val = 23}"
        -var-evaluate-expression var_w_foo
        ^done,value="Foo23"

        -data-evaluate-expression w
        ^done,value="Foo23"
        -data-evaluate-expression w.foo
        ^done,value="Foo23"

So, in the -var-evaluate-expression var_w case, we print the "raw" value
of w.foo, while in the -data-evaluate-expression w case, we print the
pretty printed w.foo value. After this patch, all of the above print
"Foo23".

gdb/ChangeLog:

* varobj.c (varobj_formatted_print_options): Allow recursive
pretty printing if pretty printing is enabled.

gdb/testsuite/ChangeLog:

* gdb.python/py-prettyprint.c
(struct to_string_returns_value_inner,
struct to_string_returns_value_wrapper): New.
(main): Add tsrvw variable.
* gdb.python/py-prettyprint.py (ToStringReturnsValueInner,
ToStringReturnsValueWrapper): New classes.
(register_pretty_printers): Register new pretty-printers.
* gdb.python/py-prettyprint.exp (run_lang_tests): Test printing
recursive pretty printer.
* gdb.python/py-mi.exp: Likewise.

6 years agobinutils/riscv: Register names in DWARF output
Andrew Burgess [Fri, 2 Feb 2018 15:25:31 +0000 (15:25 +0000)]
binutils/riscv: Register names in DWARF output

Adds a register name table for RiscV so that objdump and readelf can
both use better register names.

binutils/ChangeLog:

* dwarf.c (dwarf_regnames_riscv): New register name table.
(init_dwarf_regnames_riscv): New function.
(init_dwarf_regnames): Add call to initialise RiscV register
names.
* dwarf.h (init_dwarf_regnames_riscv): Declare.
* objdump.c (dump_dwarf): Add call to initialise RiscV register
names.

6 years agoLD/testsuite: Pass $AFLAGS_PIC to GAS for PIC assembly
Maciej W. Rozycki [Fri, 2 Feb 2018 18:08:04 +0000 (18:08 +0000)]
LD/testsuite: Pass $AFLAGS_PIC to GAS for PIC assembly

Add $AFLAGS_PIC flags for PIC assembly to a number of tests missing them
and remove `tic6x-*-*' XFAIL annotations from them, previously added to
paper over:

.../ld-new: warning: generating a shared library containing non-PID code

error messages produced due to `-mpic -mpid=near' GAS options having not
been used.  Such errors now do not happen anymore, removing:

XFAIL: Build shared library for pr14170
XFAIL: PR ld/21703 shared
XFAIL: Build shared library for broken linker script test
XFAIL: Build pr17068.so
XFAIL: -Bsymbolic-functions
XFAIL: Build pr20995.so
XFAIL: Build pr22374 shared library

with `tic6x-elf' and `tic6x-uclinux' targets.  These tests now pass all
except for:

FAIL: PR ld/21703 shared

which is now due to a different reason, as follows:

extra regexps in .../ld/testsuite/ld-elf/pr21703-shared.sd starting with "^Symbol table '\.dynsym' contains [0-9]+ entries:$"
EOF from dump.out
FAIL: PR ld/21703 shared

The addition of $AFLAGS_PIC requires the affected test cases to use the
`list' command rather than `{}' characters to create a list, to avoid
the quoting property `{}' also have in TCL.  Consequently the change is
slightly more extensive than it could otherwise be.

ld/
* testsuite/ld-elf/shared.exp: Add $AFLAGS_PIC throughout to PIC
assembly builds where missing and remove `tic6x-*-*' XFAIL
markings accordingly.

6 years agoPowerPC64, don't relocate nops
Alan Modra [Fri, 2 Feb 2018 06:25:21 +0000 (16:55 +1030)]
PowerPC64, don't relocate nops

This fixes a "bug" in that nops emitted as part of code optimization
were being relocated.  As it happens the relocation value was always
zero so the nop wasn't changed.  Whew!  I've also moved the use of
"howto" later since I was caught out in some recent code changes with
the howto not matching r_type.

* elf64-ppc.c (ppc64_elf_relocate_section): Don't relocate nops
emitted for toc sequence optimization.  Set and use "howto" later.

6 years agoDo not classify C struct members as a filename
Leszek Swirski [Thu, 25 Jan 2018 16:20:47 +0000 (16:20 +0000)]
Do not classify C struct members as a filename

There is existing logic in C/C++ expression parsing to avoid classifying
names as a filename when they are a field on the this object. This
change extends this logic to also avoid classifying names after a
struct-op (-> or .) as a filename, which otherwise causes a syntax
error.

Thus, it is now possible in the file

    #include <map>
    struct D {
        void map();
    }
    D d;

to call

    (gdb) print d.map()

where previously this would have been a syntax error.

Tested on gdb.cp/*.exp

gdb/ChangeLog:

        * c-exp.y (lex_one_token, classify_name, yylex): Don't classify
        names after a structop as a filename

gdb/testsuite/ChangeLog:

        * gdb.cp/filename.cc, gdb.cp/filename.exp: Test that member
        functions with the same name as an include file are parsed
        correctly.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 2 Feb 2018 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in