external/binutils.git
7 years agoAdd new counter-enable CSRs
Andrew Waterman [Thu, 23 Feb 2017 05:23:05 +0000 (21:23 -0800)]
Add new counter-enable CSRs

include/ChangeLog:

2017-02-22  Andrew Waterman  <andrew@sifive.com>

       * opcode/riscv-opc.h (CSR_SCOUNTEREN): New define.
       (CSR_MCOUNTEREN): Likewise.
       (scounteren): Declare register.
       (mcounteren): Likewise.

7 years agoRemove use of MAX_REGISTER_SIZE
Alan Hayward [Fri, 24 Feb 2017 16:09:48 +0000 (16:09 +0000)]
Remove use of MAX_REGISTER_SIZE

gdb/
* stack.c (frame_info): Use frame_unwind_register_value to avoid buf.

7 years agoUse I386_MAX_REGISTER_SIZE and M68K_MAX_REGISTER_SIZE
Alan Hayward [Fri, 24 Feb 2017 16:09:43 +0000 (16:09 +0000)]
Use I386_MAX_REGISTER_SIZE and M68K_MAX_REGISTER_SIZE

gdb/
* i386-tdep.c (i386_pseudo_register_read_into_value): Use
I386_MAX_REGISTER_SIZE.
(i386_pseudo_register_write): Likewise.
(i386_process_record): Likewise.
* i387-tdep.c (i387_supply_xsave): Likewise.
* m68k-linux-nat.c (fetch_register): Use M68K_MAX_REGISTER_SIZE.
(store_register): Likewise.

7 years agoTidy up readelf's use of boolean values.
Nick Clifton [Fri, 24 Feb 2017 14:48:19 +0000 (14:48 +0000)]
Tidy up readelf's use of boolean values.

* readelf.c (show_name, do_dynamic, do_syms, do_dyn_syms,
(do_reloc, do_sections, do_section_groups, do_section_details,
(do_segments, do_unwind, do_using_dynamic, do_header, do_dump,
(do_version, do_histogram, do_debugging, do_arch, do_notes,
(do_archive_index, is_32bit_elf, decompress_dumps): Use
bfd_boolean type.
(parse_args): Treat the do_* variables as booleans.
(print_vma): Return an unsigned int.
(print_symbol): Change width parameter to signed int.
(is_ia64_vms): Change return type to bfd_boolean.
(guess_is_rela): Likewise.
(slurp_rela_relocs): Likewise.
(slurp_rel_relocs): Likewise.
(dump_relocations): Likewise.
(process_file_header): Likewise.
(get_program_headers): Likewise.
(process_program_headers): Likewise.
(process_section_headers): Likewise.
(process_section_groups): Likewise.
(dump_ia64_vms_dynamic_fixups): Likewise.
(dump_ia64_vms_dynamic_relocs): Likewise.
(process_ia64_vms_dynamic_relocs): Likewise.
(process_relocs): Likewise.
(dump_ia64_unwind): Likewise.
(ia64_process_unwind): Likewise.
(dump_hppa_unwind): Likewise.
(slurp_hppa_unwind_table): Likewise.
(hppa_process_unwind): Likewise.
(decode_arm_unwind_bytecode): Likewise.
(decode_tic6x_unwind_bytecode): Likewise.
(decode_arm_unwind): Likewise.
(dump_arm_unwind): Likewise.
(arm_process_unwind): Likewise.
(process_unwind): Likewise.
(get_32bit_dynamic_section): Likewise.
(get_64bit_dynamic_section): Likewise.
(process_dynamic_section): Likewise.
(process_version_sections): Likewise.
(process_symbol_table): Likewise.
(process_syminfo): Likewise.
(apply_relocations): Likewise.
(disassemble_section): Likewise.
(dump_section_as_strings): Likewise.
(dump_section_as_bytes): Likewise.
(load_specific_debug_section): Likewise.
(load_debug_section): Likewise.
(display_debug_section): Likewise.
(process_section_contents): Likewise.
(process_attributes): Likewise.
(process_nds32_specific): Likewise.
(process_gnu_liblist): Likewise.
(print_core_note): Likewise.
(print_gnu_note): Likewise.
(print_v850_note): Likewise.
(process_netbsd_elf_note): Likewise.
(print_stapsdt_note): Likewise.
(print_ia64_vms_note): Likewise.
(process_note): Likewise.
(process_notes_at): Likewise.
(process_corefile_note_segments): Likewise.
(process_v850_notes): Likewise.
(process_note_sections): Likewise.
(process_notes): Likewise.
(process_arch_specific): Likewise.
(get_file_header): Likewise.
(process_object): Likewise.
(process_archive): Likewise.
(process_file): Likewise.
(section_subset): Make static.
(get_mips_reg_size): Return a signed integer.
(process_object): Reverse the logic of the return value.
(process_archive): Likewise.
(process_file): Likewise.

7 years agoreadelf: Correct version flag formatting
Maciej W. Rozycki [Thu, 23 Feb 2017 18:18:51 +0000 (18:18 +0000)]
readelf: Correct version flag formatting

Remove a trailing space or a leading pipe character from version flags
printed with `readelf --version-info'.

For example with the `mips-linux' target we get:

$ cat ver_def.s
.data
.globl new_foo
.type new_foo, %object
new_foo:
.symver new_foo, foo@@ver_foo
$ cat ver_def.ver
{ global: *foo*; local: *; };
$ as -o ver_def.o ver_def.s
$ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
$

which includes an unnecessary space after `BASE'; both call sites
already provide suitable separation from output that follows.  Also if
only unknown flags were present, then lone `| <unknown>' would be
printed.

binutils/
* readelf.c (get_ver_flags): Tidy the formatting of the string
returned

7 years agoreadelf: Make version section index sum unsigned
Maciej W. Rozycki [Thu, 23 Feb 2017 18:16:55 +0000 (18:16 +0000)]
readelf: Make version section index sum unsigned

Make `isum' unsigned like data it is calculated from.

binutils/
* readelf.c (process_version_sections) <SHT_GNU_verdef>: Make
`isum' unsigned.
<SHT_GNU_verneed>: Likewise.

7 years agoreadelf: Fix incorrect "Version definition past end of section" message
Maciej W. Rozycki [Thu, 23 Feb 2017 18:16:11 +0000 (18:16 +0000)]
readelf: Fix incorrect "Version definition past end of section" message

Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.")
`readelf --version-info' regression that caused "Version definition past
end of section" to be always printed at the end, even with good section
data.

For example with the `mips-linux' target we get:

$ cat ver_def.s
.data
.globl new_foo
.type new_foo, %object
new_foo:
.symver new_foo, foo@@ver_foo
$ cat ver_def.ver
{ global: *foo*; local: *; };
$ as -o ver_def.o ver_def.s
$ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

The cause is the `if (idx + ent.vd_next <= idx)' condition introduced to
ensure forward progress, which however always triggers for good version
definition section data as the last entry will have its `vd_next' value
set to 0.

Adjust the condition then, to say `if (idx + ent.vd_next < idx)' instead
and to ensure forward progress limit the number of entries processed to
the size of the version definition section, removing the problematic
message from output quoted above, while ensuring the original PR 17531
test case is still handled gracefully.

Add a suitable test case so that we have `readelf --version-info'
coverage; due to the lack of infrastructure needed to run the linker in
the `binutils' test suite and limited justification to implement it add
a new `readelf.exp' script to the `ld' test suite instead, intended to
gather any `readelf' test cases that require the linker to be run.  If
ever we decide to have linker infrastructure added to the `binutils'
test suite, then the script can be moved between the test suites.

binutils/
* readelf.c (process_version_sections) <SHT_GNU_verdef>: Limit
the number of entries processed by the section size.  Don't
break out of the loop if `ent.vd_next' is 0.

ld/
* testsuite/ld-elf/ver_def.d: New test.
* testsuite/ld-elf/ver_def.ld: New test linker script.
* testsuite/ld-elf/ver_def.ver: New test version script.
* testsuite/ld-elf/ver_def.s: New test source.
* testsuite/ld-elf/readelf.exp: New test script.

7 years agox86: also correctly support TEST opcode aliases
Jan Beulich [Fri, 24 Feb 2017 09:04:26 +0000 (10:04 +0100)]
x86: also correctly support TEST opcode aliases

Opcodes F6/1 and F7/1 are aliases of F6/0 and F7/0 in all modes. This
complements commit 8b89fe14b5 ("X86: Decode opcode 0x82 as opcode 0x80
in 32-bit mode"), just that here 64-bit mode is also covered.

7 years agogas: test cases for the architecture level aware SPARC ASI work.
Sheldon Lobo [Fri, 24 Feb 2017 08:23:50 +0000 (00:23 -0800)]
gas: test cases for the architecture level aware SPARC ASI work.

gas/ChangeLog:

Test cases for the architecture level aware SPARC ASI work.
* gas/testsuite/gas/sparc/sparc.exp: 2 new tests
* gas/testsuite/gas/sparc/asi-bump-warn.s: New test
* gas/testsuite/gas/sparc/asi-bump-warn.l: Likewise
* gas/testsuite/gas/sparc/asi-arch-error.s: Likewise
* gas/testsuite/gas/sparc/asi-arch-error.l: Likewise

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Feb 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoMIPS/BFD: Remove duplicate NewABI JALR relocation handling
Maciej W. Rozycki [Thu, 23 Feb 2017 22:27:50 +0000 (22:27 +0000)]
MIPS/BFD: Remove duplicate NewABI JALR relocation handling

Remove separate original NewABI JALR relocation handling, introduced
with commit d06471104a83 ("relax jalr $t9 [R_MIPS_JALR symbol] to bal
symbol"), <https://sourceware.org/ml/binutils/2003-03/msg00394.html>,
and only used by LD with the `--relax' option specified, and rely solely
on `mips_elf_perform_relocation' code, which has been introduced with
commit 1367d393bb74 ("On the RM9000 convert jal to bal if in range"),
<https://www.sourceware.org/ml/binutils/2004-12/msg00088.html> and since
made more complete, across all the three ABIs.

Also remove the `--relax' option, now irrelevant, from the tests added
with the former commit.

bfd/
* elfxx-mips.h (_bfd_mips_relax_section): Remove prototype.
* elfxx-mips.c (_bfd_mips_relax_section): Remove function.
* elf64-mips.c (bfd_elf64_bfd_relax_section): Remove macro.
* elfn32-mips.c (bfd_elf32_bfd_relax_section): Likewise.

ld/
* testsuite/ld-mips-elf/relax-jalr-n32.d: Remove `--relax'
option.
* testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Likewise.
* testsuite/ld-mips-elf/relax-jalr-n64.d: Likewise.
* testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise.

7 years agoMIPS/BFD: Discard ineligible JALR relocations right away
Maciej W. Rozycki [Thu, 23 Feb 2017 19:26:53 +0000 (19:26 +0000)]
MIPS/BFD: Discard ineligible JALR relocations right away

Discard R_MIPS_JALR and R_MICROMIPS_JALR relocations associated with
jumps that cannot be converted to an equivalent branch right away in
`mips_elf_calculate_relocation' rather than letting them through to
`mips_elf_perform_relocation'.  This includes cross-mode jumps which
need to flip the ISA bit or jumps to a misaligned location that cannot
be encoded with a branch, in addition to preemptible symbol references
already handled.

Cross-mode jumps are actually already rejected as the conversion is made
in `mips_elf_perform_relocation', so in this case this change only saves
some processing.  Jumps to a misaligned location are however converted,
with bits causing misalignment lost, making resulting code functionally
different even if the lone effect is avoiding an address error exception
with an instruction fetch at the jump destination requested.

Add test cases suitable, also including GAS verification to confirm that
the JALR relocations explicitly requested have indeed been output in the
intermediate objects used.

bfd/
* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_JALR>
<R_MICROMIPS_JALR>: Discard relocation if `cross_mode_jump_p'
or misaligned.

gas/
* testsuite/gas/mips/jalr4.d: New test.
* testsuite/gas/mips/jalr4-n32.d: New test.
* testsuite/gas/mips/jalr4-n64.d: New test.
* testsuite/gas/mips/jalr4.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/jalr4.dd: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.

7 years agoDWARF-5: testcase
Jan Kratochvil [Thu, 23 Feb 2017 21:54:02 +0000 (22:54 +0100)]
DWARF-5: testcase

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* testsuite/binutils-all/dw5.S: New file.
* testsuite/binutils-all/dw5.W: New file.
* testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.

7 years agoDWARF-5: DW_FORM_data16
Jan Kratochvil [Thu, 23 Feb 2017 21:54:02 +0000 (22:54 +0100)]
DWARF-5: DW_FORM_data16

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.

7 years agoDWARF-5: Macros
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)]
DWARF-5: Macros

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (display_debug_macro): Support DWARF-5.  Rename
DW_MACRO_GNU_*.

7 years agoDWARF-5: call sites
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)]
DWARF-5: call sites

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer,
DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert
and DW_OP_reinterpret.
(read_and_display_attr_value): Support DW_AT_call_value,
DW_AT_call_data_value, DW_AT_call_target and
DW_AT_call_target_clobbered.

7 years agoDWARF-5 basic functionality
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)]
DWARF-5 basic functionality

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (fetch_indirect_line_string): New function.
(abbrev_attr): New field implicit_const.
(add_abbrev_attr): New parameter implicit_const.
(process_abbrev_section): Support DW_FORM_implicit_const.
(decode_location_expression): Support DW_OP_entry_value.
(read_and_display_attr_value): Add parameter implicit_const.  Support
DW_FORM_line_strp and DW_FORM_implicit_const.
(read_and_display_attr): Add parameter implicit_const.
(process_debug_info): Support line_str and DWARF-5.
(read_debug_line_header): Support DWARF-5.
(display_formatted_table): New function.
(display_debug_lines_raw): New parameter file.  Support DWARF-5.
(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
(display_debug_lines): Pass file parameter.
(display_debug_macro): Update read_and_display_attr_value caller.
(display_debug_abbrev): Support DW_FORM_implicit_const.
(display_loclists_list): New function.
(display_loc_list): Support .debug_loclists.
(display_debug_ranges_list): New function from display_debug_ranges.
(display_debug_rnglists_list): New function.
(display_debug_ranges): Support .debug_rnglists.
(debug_displays): Add .debug_line_str, .debug_loclists and
.debug_rnglists.
* dwarf.h: Include dwarf2.h
(DWARF2_Internal_LineInfo): Add li_offset_size.
(DWARF2_Internal_CompUnit): Add cu_unit_type.
(enum dwarf_section_display_enum): Add line_str.
* readelf.c (process_section_headers): Add rnglists and loclists.

7 years agoDWARF attrs: add delimiter
Jan Kratochvil [Thu, 23 Feb 2017 21:54:00 +0000 (22:54 +0100)]
DWARF attrs: add delimiter

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (display_block): Add parameter delimiter.
(decode_location_expression): Update display_block callers.
(read_and_display_attr_value): Add parameter delimiter.
(read_and_display_attr, display_debug_macro): Update
read_and_display_attr_value caller.

7 years agoPR21166: Validate rdrand/rdseed support separately in gdb.reverse/insn-reverse-x86.c
Luis Machado [Thu, 23 Feb 2017 20:36:58 +0000 (14:36 -0600)]
PR21166: Validate rdrand/rdseed support separately in gdb.reverse/insn-reverse-x86.c

As reported in PR21166, there are Intel processors out there that support
rdrand but not rdseed. The fix is to verify both features separately and only
run rdrand/rdseed tests if supported.

gdb/testsuite/ChangeLog:
2017-02-23  Luis Machado  <lgustavo@codesourcery.com>

* gdb.reverse/insn-reverse.x86.c (check_rdrand_support): Renamed to ...
(check_supported_features): ... this. Changed return type to void.
(supports_rdseed): New static global.
(rdseed): Check supports_rdseed.
(initialize): Call check_supported_features.

7 years agodwarf.c: Use more dwarf_vma
Jan Kratochvil [Thu, 23 Feb 2017 20:37:31 +0000 (21:37 +0100)]
dwarf.c: Use more dwarf_vma

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address
and off.
(display_loc_list_dwo): Use dwarf_vma for offset.
(display_debug_loc): Use dwarf_vma for offset, base_address.
(struct range_entry, range_entry_compar): Use dwarf_vma for
ranges_offset.
(display_debug_ranges): Use dwarf_vma for ranges_offset, offset and
base_address.

7 years agoS/390: Add support for new cpu architecture - arch12.
Andreas Krebbel [Mon, 2 Jan 2017 15:40:29 +0000 (16:40 +0100)]
S/390: Add support for new cpu architecture - arch12.

This adds support of new instructions to the S/390 specific parts.

The important feature of the new instruction set is the support of
single and extended precision floating point vector operations.

Note: arch12 is NOT the official name of the new CPU.  It just
continues the series of archXX options supported as alternate names.
The archXX terminology refers to the edition number of the Principle
of Operations manual.  The official CPU name will be added later while
keeping support of the arch12 for backwards compatibility.

No testsuite regressions.

Committed to mainline.

Bye,

-Andreas-

opcodes/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-mkopc.c (main): Accept arch12 as cpu string and vx2 as
facility.
* s390-opc.c: Add new operand description macros, new instruction
types, instruction masks, and new .insn instruction types.
* s390-opc.txt: Add new arch12 instructions.

include/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* opcode/s390.h (enum s390_opcode_cpu_val): New value
S390_OPCODE_ARCH12.
(S390_INSTR_FLAG_VX2): New macro definition.

gas/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/tc-s390.c (s390_parse_cpu): New entry for arch12.
* doc/as.texinfo: Document arch12 as cpu type.
* doc/c-s390.texi: Likewise.
* testsuite/gas/s390/s390.exp: Run arch12 specific tests.
* testsuite/gas/s390/zarch-arch12.d: New test.
* testsuite/gas/s390/zarch-arch12.s: New test.
* testsuite/gas/s390/zarch-z13.d: Rename some mnemonics in the
output patterns.

7 years agoUse gdb::function_view in iterate_over_symtabs & co
Pedro Alves [Wed, 22 Feb 2017 14:43:35 +0000 (14:43 +0000)]
Use gdb::function_view in iterate_over_symtabs & co

I wanted to pass a lambda to iterate_over_symtabs (see following
patch), so I converted it to function_view, and then the rest is
cascaded from that.

This gets rid of a bunch of single-use callback functions and
corresponding manually managed callback capture types
(add_partial_datum, search_symbols_data, etc.) in favor of letting the
compiler generate them for us by using lambdas with a capture.  In a
couple cases, it was more natural to convert the existing function
callbacks to function objects (i.e., operator(), e.g.,
decode_compound_collector).

gdb/ChangeLog:
2017-02-23  Pedro Alves  <palves@redhat.com>

* ada-lang.c: Include "common/function-view.h".
(ada_iterate_over_symbols): Adjust to use function_view as
callback type.
(struct add_partial_datum, ada_complete_symbol_matcher): Delete.
(ada_make_symbol_completion_list): Use a lambda.
(ada_exc_search_name_matches): Delete.
(name_matches_regex): New.
(ada_add_global_exceptions): Use a lambda and name_matches_regex.
* compile/compile-c-support.c: Include "common/function-view.h".
(print_one_macro): Change prototype to accept a ui_file pointer.
(write_macro_definitions): Use a lambda.
* dwarf2read.c: Include "common/function-view.h".
(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
(dw2_expand_symtabs_matching): Adjust to use function_view as
callback type.
* language.h: Include "common/function-view.h".
(struct language_defn) <la_iterate_over_symbols>: Adjust to use
function_view as callback type.
(LA_ITERATE_OVER_SYMBOLS): Remove DATA parameter.
* linespec.c: Include "common/function-view.h".
(collect_info::add_symbol): New method.
(struct symbol_and_data_callback, iterate_inline_only, struct
symbol_matcher_data, iterate_name_matcher): Delete.
(iterate_over_all_matching_symtabs): Adjust to use function_view
as callback type and lambdas.
(iterate_over_file_blocks): Adjust to use function_view as
callback type.
(decode_compound_collector): Now a class with private fields.
(decode_compound_collector::release_symbols): New method.
(collect_one_symbol): Rename to...
(decode_compound_collector::operator()): ... this and adjust.
(lookup_prefix_sym): decode_compound_collector construction bits
move to decode_compound_collector ctor.  Pass the
decode_compound_collector object directly as callback.  Remove
cleanups and use decode_compound_collector::release_symbols
instead.
(symtab_collector): Now a class with private fields.
(symtab_collector::release_symtabs): New method.
(add_symtabs_to_list): Rename to...
(symtab_collector::operator()): ... this and adjust.
(collect_symtabs_from_filename): symtab_collector construction
bits move to symtab_collector ctor.  Pass the symtab_collector
object directly as callback.  Remove cleanups and use
symtab_collector::release_symtabs instead.
(collect_symbols): Delete.
(add_matching_symbols_to_info): Use lambdas.
* macrocmd.c (print_macro_callback): Delete.
(info_macro_command): Use a lambda.
(info_macros_command): Pass print_macro_definition as callable
directly.
(print_one_macro): Remove 'ignore' parameter.
(macro_list_command): Adjust.
* macrotab.c (macro_for_each_data::fn): Now a function_view.
(macro_for_each_data::user_data): Delete field.
(foreach_macro): Adjust to call the function_view.
(macro_for_each): Adjust to use function_view as callback type.
(foreach_macro_in_scope): Adjust to call the function_view.
(macro_for_each_in_scope): Adjust to use function_view as callback
type.
* macrotab.h: Include "common/function-view.h".
(macro_callback_fn): Declare a prototype instead of a pointer.
Remove "user_data" parameter.
(macro_for_each, macro_for_each_in_scope): Adjust to use
function_view as callback type.
* psymtab.c (partial_map_expand_apply)
(psym_map_symtabs_matching_filename, recursively_search_psymtabs):
Adjust to use function_view as callback type and to return bool.
(psym_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile-debug.c (debug_qf_map_symtabs_matching_filename): Adjust
to use function_view as callback type and to return bool.
(debug_qf_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile.c (expand_symtabs_matching): Adjust to use function_view
as callback types.
* symfile.h: Include "common/function-view.h".
(expand_symtabs_file_matcher_ftype)
(expand_symtabs_symbol_matcher_ftype)
(expand_symtabs_exp_notify_ftype): Remove "data" parameter and
return bool.
(quick_symbol_functions::map_symtabs_matching_filename)
(quick_symbol_functions::expand_symtabs_matching): Adjust to use
function_view as callback type and return bool.
(expand_symtabs_matching): Adjust to use function_view as callback
type.
(maintenance_expand_name_matcher)
(maintenance_expand_file_matcher): Delete.
(maintenance_expand_symtabs): Use lambdas.
* symtab.c (iterate_over_some_symtabs): Adjust to use
function_view as callback types and return bool.
(iterate_over_symtabs): Likewise.  Use unique_xmalloc_ptr instead
of a cleanup.
(lookup_symtab_callback): Delete.
(lookup_symtab): Use a lambda.
(iterate_over_symbols): Adjust to use function_view as callback
type.
(struct search_symbols_data, search_symbols_file_matches)
(search_symbols_name_matches): Delete.
(search_symbols): Use a pair of lambdas.
(struct add_name_data, add_macro_name, symbol_completion_matcher)
(symtab_expansion_callback): Delete.
(default_make_symbol_completion_list_break_on_1): Use lambdas.
* symtab.h: Include "common/function-view.h".
(iterate_over_some_symtabs): Adjust to use function_view as
callback type and return bool.
(iterate_over_symtabs): Adjust to use function_view as callback
type.
(symbol_found_callback_ftype): Remove 'data' parameter and return
bool.
(iterate_over_symbols): Adjust to use function_view as callback
type.

7 years agoIntroduce gdb::function_view
Pedro Alves [Thu, 23 Feb 2017 16:14:08 +0000 (16:14 +0000)]
Introduce gdb::function_view

This commit adds a new function_view type.  This type holds a
non-owning reference to a callable.  It is meant to be used as
callback type of functions, instead of using the C-style pair of
function pointer and 'void *data' arguments.  function_view allows
passing references to stateful function objects / lambdas with
captures as callbacks efficiently, while function pointer + 'void *'
does not.

See the intro in the new function-view.h header for more.

Unit tests included, put into a new gdb/unittests/ subdir.

gdb/ChangeLog:
2017-02-23  Pedro Alves  <palves@redhat.com>

* Makefile.in (SUBDIR_UNITTESTS_SRCS, SUBDIR_UNITTESTS_OBS): New.
(%.o) <unittests/%.c>: New pattern.
* configure.ac ($development): Add $(SUBDIR_UNITTESTS_OBS) to
CONFIG_OBS, and $(SUBDIR_UNITTESTS_SRCS) to CONFIG_SRCS.
* common/function-view.h: New file.
* unittests/function-view-selftests.c: New file.
* configure: Regenerate.

7 years agoopcodes,gas: associate SPARC ASIs with an architecture level.
Sheldon Lobo [Thu, 23 Feb 2017 15:49:37 +0000 (07:49 -0800)]
opcodes,gas: associate SPARC ASIs with an architecture level.

With this change an architecture level bump due to assembly ASIs will show
up as a warning/error depending on options passed to gas.

Tested with sparc64-linux-gnu, and it does not introduce any regressions.

gas/ChangeLog:

Add support for associating SPARC ASIs with an architecture level.
* config/tc-sparc.c (parse_sparc_asi): New encode SPARC ASIs.

opcodes/ChangeLog:

Add support for associating SPARC ASIs with an architecture level.
* include/opcode/sparc.h (sparc_asi): New sparc_asi struct.
* opcodes/sparc-opc.c (asi_table): Updated asi_table and encoding/
decoding of SPARC ASIs.

7 years agoFix usage of inferior_ptid in two thread_alive implementations
Simon Marchi [Thu, 23 Feb 2017 15:36:20 +0000 (10:36 -0500)]
Fix usage of inferior_ptid in two thread_alive implementations

While inspecting some target code, I noticed that in these two
implementations of thread_alive, inferior_ptid is referenced directly
instead of using the ptid passed as parameters.  I guess that it is
wrong, although I can't really test it in both cases.

gdb/ChangeLog:

* bsd-uthread.c (bsd_uthread_thread_alive): Use ptid instead of
inferior_ptid.
* go32-nat.c (go32_thread_alive): Likewise.

7 years agoAdd support to readelf for displaying gnu attributes in architectures not known to...
Nick Clifton [Thu, 23 Feb 2017 13:45:21 +0000 (13:45 +0000)]
Add support to readelf for displaying gnu attributes in architectures not known to support them.

* readelf.c (display_tag_value): Use an explicit signed type for
the tag parameter.
(display_gnu_attributes): Use an unsigned integer type for
attribute tags.
(display_power_gnu_attribute): Likewise.
(display_s390_gnu_attribute): Likewise.
(display_sparc_hwcaps): Likewise.
(display_sparc_hwcaps2): Likewise.
(display_sparc_gnu_attribute): Likewise.
(display_mips_gnu_attribute): Likewise.
(display_tic6x_attribute): Likewise.
(display_raw_attribute): Likewise.
(process_attributes): Likewise.
(process_arm_specific): Delete redundant function.
(process_power_specific): Likewise.
(process_s390_specific): Likewise.
(process_sparc_specific): Likewise.
(process_tic6x_specific): Likewise.
(process_msp430x_specific): Likewise.
(display_public_gnu_attributes): New function.  Displays known
information about an unknown gnu attribute.
(display_generic_attribute): New function.  Calls
display_tag_value for non-nul tags.
(process_arch_specific): Call process_attributes even for
architectures not known to specifically support gnu attributes.

7 years agoUse xfree rather than delete for varobj_iter
Yao Qi [Thu, 23 Feb 2017 11:57:46 +0000 (11:57 +0000)]
Use xfree rather than delete for varobj_iter

ASAN reports an error,

-var-create container @ c^M
=================================================================^M
^[[1m^[[31m==21639==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6030000805c0^M
^[[1m^[[0m    #0 0x7f2449b01b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)^M
    #1 0xbb601d in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:794^M
    #2 0xbb6556 in varobj_get_num_children(varobj*) ../../binutils-gdb/gdb/varobj.c:854^M
    #3 0x580cb4 in print_varobj ../../binutils-gdb/gdb/mi/mi-cmd-var.c:61^M
    #4 0x58138b in mi_cmd_var_create(char*, char**, int) ../../binutils-gdb/gdb/mi/mi-cmd-var.c:145^M
    #5 0x5967ce in mi_cmd_execute ../../binutils-gdb/gdb/mi/mi-main.c:2301^M
    #6 0x594b05 in captured_mi_execute_command ../../binutils-gdb/gdb/mi/mi-main.c:2001
....
^M
^[[1m^[[32m0x6030000805c0 is located 0 bytes inside of 32-byte region [0x6030000805c0,0x6030000805e0)^M
^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M
    #0 0x7f2449b00602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)^M
    #1 0x7d1596 in xmalloc ../../binutils-gdb/gdb/common/common-utils.c:43^M
    #2 0x604176 in py_varobj_iter_new ../../binutils-gdb/gdb/python/py-varobj.c:159^M
    #3 0x6042da in py_varobj_get_iterator(varobj*, _object*) ../../binutils-gdb/gdb/python/py-varobj.c:198^M
    #4 0xbb5806 in varobj_get_iterator ../../binutils-gdb/gdb/varobj.c:720^M
    #5 0xbb5b9b in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:758^M

gdb:

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

* varobj-iter.h (varobj_iter_delete): Call xfree instead of
delete.

7 years agoUse delete instead of xfree for varobj_item
Yao Qi [Thu, 23 Feb 2017 11:05:03 +0000 (11:05 +0000)]
Use delete instead of xfree for varobj_item

In commit 2f408ec (Use ui_file_as_string throughout more), we start to
new varobj_item,

> -  vitem = XNEW (struct varobj_item);
> +  vitem = new varobj_item ();

but we still use xfree.  This causes some ASAN errors,

-var-update container^M
=================================================================^M
^[[1m^[[31m==20660==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602000090c10^M
^[[1m^[[0m    #0 0x2baa77d03631 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54631)^M
    #1 0x80e0c8 in xfree(void*) /home/yao/SourceCode/gnu/gdb/git/gdb/common/common-utils.c:100^M
    #2 0xc13670 in varobj_clear_saved_item /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:727^M
    #3 0xc13957 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:752^M
    #4 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M
    #5 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M
    #6 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^
........
^M
^[[1m^[[32m0x602000090c10 is located 0 bytes inside of 16-byte region [0x602000090c10,0x602000090c20)^M
^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M
    #0 0x2baa77d0415f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5515f)^M
    #1 0x63613e in py_varobj_iter_next /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-varobj.c:112^M
    #2 0xc13b89 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:776^M
    #3 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M
    #4 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M
    #5 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^M

gdb:

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

* varobj.c (varobj_clear_saved_item): Use delete instead of
xfree.
(update_dynamic_varobj_children): Likewise.

7 years agogas: slightly relax .startof.()/.sizeof.() testcase
Jan Beulich [Thu, 23 Feb 2017 10:21:10 +0000 (11:21 +0100)]
gas: slightly relax .startof.()/.sizeof.() testcase

7 years agox86: drop stray VEX opcode 82 references
Jan Beulich [Thu, 23 Feb 2017 10:03:55 +0000 (11:03 +0100)]
x86: drop stray VEX opcode 82 references

No such ModR/M-less opcode has ever existed in public documentation
afaict, so I can't see why it had been added in the first place.
Furthermore opcode 77 is special only with implied prefix 0F.

7 years agox86: extend 64-bit invalid MPX insn forms testcase
Jan Beulich [Thu, 23 Feb 2017 10:00:44 +0000 (11:00 +0100)]
x86: extend 64-bit invalid MPX insn forms testcase

7 years agoCorrect VLE 16D and SDAREL relocations
Alan Modra [Thu, 23 Feb 2017 01:50:42 +0000 (12:20 +1030)]
Correct VLE 16D and SDAREL relocations

PR 20744
bfd/
* elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE
16D relocations.
(ppc_elf_vle_split16): Correct field mask and shift for 16D relocs.
(ppc_elf_relocate_section): Correct calculation for VLE SDAREL
relocs.
ld/
* testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of
each group.
* testsuite/ld-powerpc/vle-reloc-2.d: Update for above change
and sdarel reloc fix.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Feb 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoDisplay user op byte
Jan Kratochvil [Wed, 22 Feb 2017 19:22:59 +0000 (20:22 +0100)]
Display user op byte

binutils/
2017-02-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (decode_location_expression): Display also OP.

7 years agoreadelf: Restore a lost new line in version information
Maciej W. Rozycki [Wed, 22 Feb 2017 18:09:41 +0000 (18:09 +0000)]
readelf: Restore a lost new line in version information

Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.")
`readelf --version-info' output formatting regression where a dropped
new line caused section header information from the `.gnu.version_d'
version definition section to be printed on the same line as this
section's first entry.

For example with the `mips-linux' target we get:

$ cat ver_def.s
.data
.globl new_foo
.type new_foo, %object
new_foo:
.symver new_foo, foo@@ver_foo
$ cat ver_def.ver
{ global: *foo*; local: *; };
$ as -o ver_def.o ver_def.s
$ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

Add the new line then, to get:

$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

instead.

binutils/
* readelf.c (process_version_sections) <SHT_GNU_verdef>: Print a
new line between the heading and the first version definition
entry.

7 years agoPR ld/20828: Move symbol version processing ahead of GC symbol sweep
Maciej W. Rozycki [Tue, 21 Feb 2017 01:46:42 +0000 (01:46 +0000)]
PR ld/20828: Move symbol version processing ahead of GC symbol sweep

Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep
stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker
script symbols wrongly forced local with section GC") and move symbol
version processing ahead of the symbol sweep stage of section GC, all in
`bfd_elf_size_dynamic_sections', so that version symbols created stay in
the global scope and are not output as local symbols to the dynamic
symbol table in the presence of corresponding symbol definitions pulled
from a DSO involved in a link.

Consolidate the whole of symbol version processing into a single block
from all parts scattered across the function and rearranging the local
variables used as necessary, however leaving the setting of dynamic
entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and
DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version'
section in the original places.

With the rearrangement of code blocks `Elf_Internal_Verneed *t' would
shadow the previous definition of `struct bfd_elf_version_tree *t', so
rename the former variable to `vn'.

bfd/
PR ld/20828
* elflink.c (bfd_elf_size_dynamic_sections): Move symbol version
processing ahead of the call to `elf_gc_sweep_symbol'.

ld/
PR ld/20828
* testsuite/ld-elf/pr20828-d.sd: New test.
* testsuite/ld-elf/pr20828-e.sd: New test.
* testsuite/ld-elf/pr20828-v.od: New test.
* testsuite/ld-elf/pr20828-v.ver: New test version script.
* testsuite/ld-elf/pr20828-v.ld: New test linker script.
* testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and
`.gnu.version_d'.
* testsuite/ld-elf/shared.exp: Run the new tests.

7 years agoGAS: Consistently fix labels at the `.end' pseudo-op
Maciej W. Rozycki [Fri, 17 Feb 2017 20:30:55 +0000 (20:30 +0000)]
GAS: Consistently fix labels at the `.end' pseudo-op

Fix a functional regression with the `.end' pseudo-op, introduced with
commit ecb4347adecd ("Last take: approval for MIPS_STABS_ELF killing"),
<https://sourceware.org/ml/binutils/2002-06/msg00443.html>, and commit
dcd410fe1544 ("GNU as 2.14 on IRIX 6: crashes with shared libs"),
<https://sourceware.org/ml/binutils/2003-07/msg00415.html>, which caused
symbol values for labels placed between the end of a function's contents
and its terminating `.end' followed by one of the alignment pseudo-ops
to be different depending on whether either `-mdebug', or `-mno-pdr', or
neither of the command-line options is in effect, be it implied or
specified.

Given debug-label-end.s as follows and the `mips-linux' target we have:

$ cat debug-label-end.s
.text

.globl foo
.globl bar
.align 4, 0
.ent foo
foo:
nop
.aent bar
bar:
.insn
.end foo
.align 4, 0
.space 16

.globl baz
.ent baz
baz:
nop
.end baz
.align 4, 0
.space 16
$ as -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     9: 00000004     0 FUNC    GLOBAL DEFAULT    1 bar
$ as -mdebug -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     9: 00000010     0 FUNC    GLOBAL DEFAULT    1 bar
$ as -mno-pdr -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     8: 00000010     0 FUNC    GLOBAL DEFAULT    1 bar
$

The reason is the call to `md_flush_pending_output', which in the case
of `mips*-*-*' targets expands to `mips_emit_delays', which in turn
calls `mips_no_prev_insn', which calls `mips_clear_insn_labels', which
clears the list of outstanding labels.  That list is in turn consulted
in `mips_align', called in the interpretation of alignment directives,
and the labels adjusted to the current location.

A call to `md_flush_pending_output' is only made from `s_mips_end' and
then only if `-mpdr' is in effect, which is the default for `*-*-linux*'
and some other `mips*-*-*' targets.  A call to `md_flush_pending_output'
is never made from `ecoff_directive_end', which is used in place of
`s_mips_end' when `-mdebug' is in effect.  Consequently if `-mno-pdr' or
`-mdebug' is in effect the list of outstanding labels makes it through
to any alignment directive that follows and the labels are differently
interpreted depending on the command-lines options used.  And we want
code produced to be always the same.

Call `md_flush_pending_output' unconditionally then in `s_mips_end' and
add such a call from `ecoff_directive_end' as well, as long as the macro
is defined.  While `ecoff_directive_end' is shared among targets, the
only one other than `mips*-*-*' actually using it is `alpha*-*-*' and it
does not define `md_flush_pending_output'.  So the semantics isn't going
to change for it and neither it has to have its `s_alpha_end' updated
or have code in `ecoff_directive_end' conditionalized.

gas/
* ecoff.c (ecoff_directive_end) [md_flush_pending_output]: Call
`md_flush_pending_output'.
* config/tc-mips.c (s_mips_end) [md_flush_pending_output]: Call
`md_flush_pending_output' unconditionally.
* testsuite/gas/mips/debug-label-end-1.d: New test.
* testsuite/gas/mips/debug-label-end-2.d: New test.
* testsuite/gas/mips/debug-label-end-3.d: New test.
* testsuite/gas/mips/debug-label-end.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoAlign .gnu_debuglink sections on a 4-byte boundary.
Nick Clifton [Wed, 22 Feb 2017 17:28:33 +0000 (17:28 +0000)]
Align .gnu_debuglink sections on a 4-byte boundary.

PR binutils/21193
* opncls.c (bfd_create_gnu_debuglink_section): Give the newly
created section 4-byte alignment.

7 years agoFix gas/all/err-sizeof.s for cris*-*-*
Hans-Peter Nilsson [Wed, 22 Feb 2017 13:17:33 +0000 (14:17 +0100)]
Fix gas/all/err-sizeof.s for cris*-*-*

7 years agoSkip ARM vcmp-noprefix-imm test on non-ELF targets
Nick Clifton [Wed, 22 Feb 2017 11:57:49 +0000 (11:57 +0000)]
Skip ARM vcmp-noprefix-imm test on non-ELF targets

7 years agogas: require an operand to .startof.()/.sizeof.()
Jan Beulich [Wed, 22 Feb 2017 09:37:52 +0000 (10:37 +0100)]
gas: require an operand to .startof.()/.sizeof.()

7 years agoaarch64: actually copy first operand in convert_bfc_to_bfm()
Jan Beulich [Wed, 22 Feb 2017 09:36:05 +0000 (10:36 +0100)]
aarch64: actually copy first operand in convert_bfc_to_bfm()

Commit 93562a343c ("[AArch64] PR target/20666, fix wrong encoding of
new introduced BFC pseudo") changed the destination operand to 0,
making the whole function invocation a no-op. We really want to copy
operand 0 (a register) to operand 1 (an immediate before coming here),
even if right now this likely is only a latent bug.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Feb 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix a regression by: Code cleanup: Split dwarf2_ranges_read to a callback
Jan Kratochvil [Tue, 21 Feb 2017 23:13:03 +0000 (00:13 +0100)]
Fix a regression by: Code cleanup: Split dwarf2_ranges_read to a callback

On some Fedora 23 systems an internal error has been printed.

gdb/ChangeLog
2017-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (dwarf2_record_block_ranges): Add forgotten BASEADDR.

7 years agoPowerPC ld segfault on script discarding dynamic sections
Alan Modra [Tue, 21 Feb 2017 21:40:58 +0000 (08:10 +1030)]
PowerPC ld segfault on script discarding dynamic sections

bfd/
* elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault
on .got or .plt output section being discarded by script.
* elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise.  Move
vxworks splt temp.
gold/
* powerpc.cc (Target_powerpc::make_iplt_section): Check that
output_section exists before attempting add_output_section_data.
(Target_powerpc::make_brlt_section): Likewise.

7 years agoDefault initialize enum flags to 0
Simon Marchi [Tue, 21 Feb 2017 16:48:49 +0000 (11:48 -0500)]
Default initialize enum flags to 0

... so that we don't need to do it manually, and potentially forget.
For example, this allows to do:

  my_flags flags;

  ...

  flags |= some_flag;

gdb/ChangeLog:

* common/enum-flags.h (enum_flags::enum_flags): Initialize
m_enum_value to 0 in default constructor.

7 years ago[ppc64] Add POWER8/ISA 2.07 atomic sequences single-stepping support
Edjunior Barbosa Machado [Tue, 21 Feb 2017 14:14:56 +0000 (11:14 -0300)]
[ppc64] Add POWER8/ISA 2.07 atomic sequences single-stepping support

gdb/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* rs6000-tdep.c (LOAD_AND_RESERVE_MASK): Rename from LWARX_MASK.
(STORE_CONDITIONAL_MASK): Rename from STWCX_MASK.
(LBARX_INSTRUCTION, LHARX_INSTRUCTION, LQARX_INSTRUCTION,
STBCX_INSTRUCTION, STHCX_INSTRUCTION, STQCX_INSTRUCTION): New defines.
(IS_LOAD_AND_RESERVE_INSN, IS_STORE_CONDITIONAL_INSN): New macros.
(ppc_displaced_step_copy_insn): Use IS_LOAD_AND_RESERVE_INSN.
(ppc_deal_with_atomic_sequence): Use IS_LOAD_AND_RESERVE_INSN and
IS_STORE_CONDITIONAL_INSN.

gdb/testsuite/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* gdb.arch/ppc64-isa207-atomic-inst.exp: New testcase based on
gdb.arch/ppc64-atomic-inst.exp.  Add tests for lbarx/stbcx, lharx/sthcx
and lqarx/stqcx.
* gdb.arch/ppc64-isa207-atomic-inst.S: New file.
* gdb.arch/ppc64-isa207-atomic-inst.c: Likewise.

7 years agoFix test names starting with uppercase in gdb.arch/ppc64-atomic-inst.exp
Edjunior Barbosa Machado [Tue, 21 Feb 2017 13:59:29 +0000 (10:59 -0300)]
Fix test names starting with uppercase in gdb.arch/ppc64-atomic-inst.exp

gdb/testsuite/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* gdb.arch/ppc64-atomic-inst.exp: Fix test names starting with
uppercase.

7 years agoFix compile time warning message in linker testsuite test.
Nick Clifton [Tue, 21 Feb 2017 11:00:21 +0000 (11:00 +0000)]
Fix compile time warning message in linker testsuite test.

* testsuite/ld-ifunc/pr18808b.c (bar): Fix compile time warning
about non-void function returning without a result.

7 years agoFix recent compiler warnings.
Jan Kratochvil [Tue, 21 Feb 2017 08:14:37 +0000 (09:14 +0100)]
Fix recent compiler warnings.

gcc-4.8.5-11.el7.x86_64

dwarf2read.c: In function â€˜pc_bounds_kind dwarf2_get_pc_bounds(die_info*, CORE_ADDR*, CORE_ADDR*, dwarf2_cu*, partial_symtab*)’:
dwarf2read.c:12134:7: error: â€˜range_end’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
dwarf2read.c:12133:7: error: â€˜range_beginning’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

gdb/ChangeLog
2017-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2_rnglists_process: Initialize range_beginning and range_end.

7 years agoAlpha DT_RELA
Alan Modra [Mon, 20 Feb 2017 07:27:43 +0000 (17:57 +1030)]
Alpha DT_RELA

* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only emit
DT_RELA, DT_RELASZ, and DT_RELAENT when DT_RELASZ is non-zero.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Feb 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoDWARF-5: NEWS
Jan Kratochvil [Mon, 20 Feb 2017 19:53:22 +0000 (20:53 +0100)]
DWARF-5: NEWS

a NEWS entry.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Changes since GDB 7.12): Add DWARF-5.

7 years agoDWARF-5: DW_FORM_data16
Jan Kratochvil [Mon, 20 Feb 2017 19:53:22 +0000 (20:53 +0100)]
DWARF-5: DW_FORM_data16

DWARF-5 has new form DW_FORM_data16.  The problem is that GDB cannot pass
16-byte constant as a constant value as that would require GDB to use GCC
extension __int128.

Formerly such data was coded as DW_FORM_block* so GDB still decodes
DW_FORM_data16 like DW_FORM_block*.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (skip_one_die, read_attribute_value)
(dwarf2_const_value_attr, dump_die_shallow)
(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
(skip_form_bytes, attr_form_is_constant): Handle DW_FORM_data16.

gdb/testsuite/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.dwarf2/formdata16.c: New file.
* gdb.dwarf2/formdata16.exp: New file.
* lib/dwarf.exp (Dwarf): Add DW_FORM_data16.

7 years agoDWARF-5: Macros
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)]
DWARF-5: Macros

DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (read_file_scope): Rename DW_MACRO_GNU_*.
(dwarf_parse_macro_header): Accept DWARF version 5.
(dwarf_decode_macro_bytes, dwarf_decode_macros): Rename DW_MACRO_GNU_*.

7 years agoDWARF-5: call sites
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)]
DWARF-5: call sites

this patch updates all call sites related DWARF-5 renames.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
* common/common-exceptions.h (enum errors): Likewise.
* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg)
(dwarf_expr_context::execute_stack_op): Likewise.
* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
Likewise.
* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
(show_entry_values_debug, call_site_to_target_addr)
(func_addr_to_tail_call_list, func_verify_no_selftailcall)
(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
(entry_data_value_free_closure, value_of_dwarf_reg_entry)
(value_of_dwarf_block_entry, indirect_pieced_value)
(symbol_needs_eval_context::push_dwarf_reg_entry_value):
(disassemble_dwarf_expression): Likewise.
* dwarf2read.c (process_die, inherit_abstract_dies)
(read_call_site_scope): Likewise.
* gdbtypes.h (struct func_type, struct call_site_parameter)
(struct call_site): Likewise.
* stack.c (read_frame_arg): Likewise.
* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.

gdb/doc/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
DW_TAG_GNU_* and DW_AT_GNU_*.

gdb/testsuite/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.

7 years agoDWARF-5 basic functionality
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)]
DWARF-5 basic functionality

this is a kitchen-sink patch for everything that did not fit into its own
patch.

DWO is not yet implemented.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* defs.h (read_unsigned_leb128): New declaration.
* dwarf2loc.c (decode_debug_loclists_addresses): New function.
(decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*.
(dwarf2_find_location_expression): Call also
decode_debug_loclists_addresses.  Handle DWARF-5 ULEB128 length.
* dwarf2loc.h (dwarf2_version): New declaration.
* dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str,
rnglists.
(dwarf2_elf_names): Add .debug_loclists, .debug_line_str,
.debug_rnglists.
(struct dwop_section_names): Add loclists_dwo.
(dwop_section_names): Add .debug_loclists.dwo.
(struct comp_unit_head): Add unit_type, signature, type_offset_in_tu.
(struct dwarf2_per_cu_data): Add dwarf_version.
(struct dwo_sections): Add loclists.
(struct attr_abbrev): Add implicit_const.
(read_indirect_line_string): New declaration.
(read_unsigned_leb128): Delete declaration.
(rcuh_kind): New definition.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(dwarf2_locate_sections): Handle loclists, line_str and rnglists.
(read_comp_unit_head): Change parameter abfd to section, add parameter
section_kind.  Handle DWARF-5.
(error_check_comp_unit_head): Accept also DWARF version 5.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(read_and_check_type_unit_head): Delete function.
(read_abbrev_offset): Handle DWARF-5.
(create_debug_type_hash_table): Add parameter section_kind.  Process
only DW_UT_type.  Use signature and type_offset_in_tu from struct
comp_unit_head.
(create_debug_types_hash_table): Update create_debug_type_hash_table
caller.
(create_all_type_units): Call create_debug_type_hash_table.
(read_cutu_die_from_dwo, init_cutu_and_read_dies): Change
read_and_check_type_unit_head caller to read_and_check_comp_unit_head
caller.
(skip_one_die): Handle DW_FORM_implicit_const.
(dwarf2_rnglists_process): New function.
(dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5.
(abbrev_table_read_table): Handle DW_FORM_implicit_const.
(read_attribute_value): Handle DW_FORM_implicit_const,
DW_FORM_line_strp.
(read_attribute): Handle DW_FORM_implicit_const.
(read_indirect_string_at_offset_from): New function from
read_indirect_string_at_offset.
(read_indirect_string_at_offset): Call
read_indirect_string_at_offset_from.
(read_indirect_line_string_at_offset): New function.
(read_indirect_string): New function comment.
(read_indirect_line_string): New function.
(read_unsigned_leb128): Make it global.
(dwarf2_string_attr): Handle DWARF-5.
(add_include_dir_stub, read_formatted_entries): New functions.
(dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section):
Handle DWARF-5.
(per_cu_header_read_in): Update read_comp_unit_head caller.
(dwarf2_version): New function.
* symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and
rnglists.
* xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections
fields.

gdb/testsuite/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.

7 years agoCode cleanup: Refactor abbrev_table_read_table cycle
Jan Kratochvil [Mon, 20 Feb 2017 19:53:20 +0000 (20:53 +0100)]
Code cleanup: Refactor abbrev_table_read_table cycle

I find it as an improvement on its own, it prevents more code duplication in
a future patch.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (abbrev_table_read_table): Read the data only once.

7 years agoCode cleanup: Split dwarf2_ranges_read to a callback
Jan Kratochvil [Mon, 20 Feb 2017 19:53:20 +0000 (20:53 +0100)]
Code cleanup: Split dwarf2_ranges_read to a callback

DWARF-5 has .debug_rnglists which is somehow similar to .debug_ranges.

This patch converts dwarf2_ranges_read to dwarf2_ranges_process which can work
with both DWARF kinds of range lists through a callback.

It also simplifies dwarf2_record_block_ranges which can benefit from it.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (dwarf2_ranges_process): New function from
dwarf2_ranges_read.
(dwarf2_ranges_read, dwarf2_record_block_ranges): Use
dwarf2_ranges_process.

7 years agoCode cleanup: Split create_debug_types_hash_table
Jan Kratochvil [Mon, 20 Feb 2017 19:53:19 +0000 (20:53 +0100)]
Code cleanup: Split create_debug_types_hash_table

DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (create_debug_type_hash_table): New function from
create_debug_types_hash_table.
(create_debug_types_hash_table): Call create_debug_type_hash_table.
(create_all_type_units, open_and_init_dwo_file): Update
create_debug_types_hash_table callers.

7 years agoFix another memory access error in readelf when parsing a corrupt binary.
Nick Clifton [Mon, 20 Feb 2017 14:40:39 +0000 (14:40 +0000)]
Fix another memory access error in readelf when parsing a corrupt binary.

PR binutils/21156
* dwarf.c (cu_tu_indexes_read): Move into...
(load_cu_tu_indexes): ... here.  Change the variable into
tri-state.  Change the function into boolean, returning
false if the indicies could not be loaded.
(find_cu_tu_set): Return NULL if the indicies could not be
loaded.

7 years agoPE ld -r script fixes
Alan Modra [Mon, 20 Feb 2017 02:54:28 +0000 (13:24 +1030)]
PE ld -r script fixes

PR 15041
* scripttempl/pe.sc: Don't combine sections for ld -r.
* scripttempl/pep.sc: Likewise.

7 years agoFix thinko on last commit
Sergio Durigan Junior [Mon, 20 Feb 2017 13:01:04 +0000 (08:01 -0500)]
Fix thinko on last commit

On fork-child.c:trace_start_error, va_end should refer to 'ap', not
'args.  This fixes it.

Sorry about the breakage.

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

PR gdb/16188
* fork-child.c (trace_start_error): Fix thinko.  va_end should
refer to 'ap', not 'args'.

7 years agoSync ZLIB with FSF GCC sources, bringing in version 1.2.11.
Nick Clifton [Mon, 20 Feb 2017 12:52:22 +0000 (12:52 +0000)]
Sync ZLIB with FSF GCC sources, bringing in version 1.2.11.

- Fix deflate stored bug when pulling last block from window
- Permit immediate deflateParams changes before any deflate input

7 years agoPR gdb/16188: Verify PTRACE_TRACEME succeeded
Sergio Durigan Junior [Tue, 14 Feb 2017 23:27:23 +0000 (18:27 -0500)]
PR gdb/16188: Verify PTRACE_TRACEME succeeded

This patch fixes PR gdb/16188, which is about the fact that
fork_inferior doesn't verify the return value of the "traceme_fun"
callback.  On most targets, this callback is actually a wrapper to a
ptrace call that does a PTRACE_TRACEME on the forked GDB process that
will eventually become the inferior.

Thanks to Pedro, this second version of the patch is simpler and more
more logical.  Basically, two helper functions are added:
trace_start_error and trace_start_error_with_name.  The former can be
used when there is a customized error message to be printed to the
user.  The latter works like perror_with_name, so you just need to
pass the function that error'd.

Both helper functions mentioned above do basically the same thing:
print the error message to stderr and call _exit, properly terminating
the forked inferior.

Most of the patch takes care of guarding the necessary system calls
against errors on the "traceme_fun" callbacks.  It is not right to
call error on these situations, so I've replaced these calls with the
proper helper function call.

Regression-tested on BuildBot.

Thanks,

gdb/ChangeLog:
2017-02-20  Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

PR gdb/16188
* darwin-nat.c (darwin_ptrace_me): Check if calls to system
calls succeeded.
* fork-child.c (trace_start_error): New function.
(trace_start_error_with_name): Likewise.
* gnu-nat.c (gnu_ptrace_me): Check if call to PTRACE succeeded.
* inf-ptrace.c (inf_ptrace_me): Likewise.
* inferior.h (trace_start_error): New prototype.
(trace_start_error_with_name): Likewise.

7 years agofix PR number
Alan Modra [Mon, 20 Feb 2017 10:58:59 +0000 (21:28 +1030)]
fix PR number

7 years agoAlpha executables segfault when linked with -z,now
Alan Modra [Mon, 20 Feb 2017 06:50:45 +0000 (17:20 +1030)]
Alpha executables segfault when linked with -z,now

PR 21181
* elflink.c (bfd_elf_final_link): Make DT_REL/DT_RELA zero
if DT_RELSZ/DT_RELASZ is zero.

7 years agoMove .stack before debug sections
Alan Modra [Mon, 20 Feb 2017 02:55:13 +0000 (13:25 +1030)]
Move .stack before debug sections

PR 20199
* emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/elf32mt.sh: Likewise.
* emulparams/elf32rx.sh: Likewise.
* emulparams/elf32rl78.sh: Likewise.  Use OTHER_SYMBOLS to
define __rl78_abs__.
* emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/shelf32.sh: Likewise.  Use OTHER_SECTIONS for .cranges.
* emulparams/shelf64.sh: Unset OTHER_SECTIONS.
* emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
* emulparams/shelf_uclinux.sh: Likewise.
* emulparams/shlsymbian.sh: Unset STACK_ADDR.  Use OTHER_SYMBOLS
to define _stack, not OTHER_SECTIONS.
* scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
TINY_BSS_SECTION before debug sections.  Add STACK_SENTINEL.
* scripttempl/arclinux.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/armbpabi.sc: Move STACK before debug sections.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Delete STACK.
* scripttempl/epiphany_4x4.sc: Delete STACK.  Move TINY_DATA_SECTION,
TINY_BSS_SECTION, and .stack before debug sections.

7 years agoDowngrade powerpc register error to warning
Alan Modra [Mon, 20 Feb 2017 01:36:52 +0000 (12:06 +1030)]
Downgrade powerpc register error to warning

PR 21118
* NEWS: Revise powerpc register check.
* config/tc-ppc.c (ppc_optimize_expr, md_assemble): Make "invalid
register expression" a warning.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Feb 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix for aarch64 sim sxtl/uxtl insns, plus another fix for addv.
Jim Wilson [Sun, 19 Feb 2017 21:16:56 +0000 (13:16 -0800)]
Fix for aarch64 sim sxtl/uxtl insns, plus another fix for addv.

sim/aarch64/
* simulator.c (do_vec_ADDV): Mov val declaration inside each case,
with type set to input type size.
(do_vec_xtl): Change bias from 3 to 4 for byte case.

sim/testsuite/sim/aarch64/
* bit.s: Change cmp immediates to account for addv bug fix.
* cmtst.s, ldn_single.s, stn_single.s: Likewise.
* xtl.s: New.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Feb 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Feb 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoGAS: Add ECOFF `.aent' pseudo-op support
Maciej W. Rozycki [Thu, 16 Feb 2017 01:50:29 +0000 (01:50 +0000)]
GAS: Add ECOFF `.aent' pseudo-op support

Implement the ECOFF `.aent' pseudo-op for ECOFF-style `.mdebug' section
support with ELF objects and, for consistency, also with ECOFF objects.
This is so that the same MIPS source can be assembled without and with
`.mdebug' section generation enabled.

Taking the `gas/testsuite/gas/mips/aent.s' test case source as an
example and the `mips-linux' target we have:

$ as -o aent.o aent.s
$ as -mdebug -o aent.o aent.s
aent.s: Assembler messages:
aent.s:10: Error: unknown pseudo-op: `.aent'
$

because for the !ECOFF_DEBUGGING case (which is the default) the
pseudo-op is already handled by the MIPS backend with `s_mips_ent',
however no handler is present for the opposite case.

For the MIPS target this is a functional regression introduced with
commit ecb4347adecd ("Last take: approval for MIPS_STABS_ELF killing"),
<https://sourceware.org/ml/binutils/2002-06/msg00443.html>, where
support for the `.mdebug' section was added along with its associated
`-mdebug'/`-no-mdebug' command-line options, bringing an inconsistency
between the assembly syntax supported for each of these options as far
as the `.aent' pseudo-op is concerned.

Assembly language documentation available describes the pseudo-op
respectively as follows[1]:

"
.aent name, symno Sets an alternate entry point for the current
                  procedure.  Use this information when you want
                  to generate information for the debugger.  It must
                  appear inside an .ent/.end pair."

and[2]:

"
.aent name [,symno]
     Sets an alternate entry point for the current procedure.  Use this
     information when you want to generate information for the debugger.
     This directive must appear between a pair of .ent and .end directives.
     (The optional symno is for compiler use only.  It refers to a dense
     number in a .T file (symbol table).)"

Copy the approach from `s_mips_ent' then and add `.aent' support to the
`.ent' pseudo-op handler shared between the ELF and ECOFF object file
format backends, by setting BSF_FUNCTION for the symbol requested.

References:

[1] "MIPSpro Assembly Language Programmer's Guide", Silicon Graphics,
    Inc., Document Number 007-2418-004, Section 8.1 "Op-Codes", p. 96
    <http://techpubs.sgi.com/library/manuals/2000/007-2418-004/pdf/007-2418-004.pdf>

[2] "Digital UNIX Assembly Language Programmer's Guide", Digital
    Equipment Corporation, Order Number: AA-PS31D-TE, March 1996,
    Chapter 5 "Assembler Directives", p. 5-2
    <http://h41361.www4.hpe.com/docs/base_doc/DOCUMENTATION/V40G_PDF/APS31DTE.PDF>

gas/
* ecoff.c (ecoff_directive_ent, add_procedure): Handle `.aent'.
* config/obj-ecoff.c (obj_pseudo_table): Add "aent" entry.
* config/obj-elf.c (ecoff_debug_pseudo_table): Likewise.
* testsuite/gas/mips/aent-2.d: New test.
* testsuite/gas/mips/aent-mdebug.d: New test.
* testsuite/gas/mips/aent-mdebug-2.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoFix documentation of the linker's --pop-state command line option.
Nick Clifton [Fri, 17 Feb 2017 16:31:09 +0000 (16:31 +0000)]
Fix documentation of the linker's --pop-state command line option.

PR ld/20825
* ld.texinfo (Options): Add missing @item entry for --pop-state.

7 years agoFix illegal memory accesses in readelf when parsing a corrupt binary.
Nick Clifton [Fri, 17 Feb 2017 15:59:45 +0000 (15:59 +0000)]
Fix illegal memory accesses in readelf when parsing a corrupt binary.

PR binutils/21156
* readelf.c (find_section_in_set): Test for invalid section
indicies.

7 years agoAdd support to readelf for displaying GNU section types.
Nick Clifton [Fri, 17 Feb 2017 15:31:54 +0000 (15:31 +0000)]
Add support to readelf for displaying GNU section types.

* readelf.c (get_section_type_name): Add decoding of GNU section
types.

7 years agoFix potential illegal memory access in ZLIB because of an erroneous declaration of...
Nick Clifton [Fri, 17 Feb 2017 11:39:20 +0000 (11:39 +0000)]
Fix potential illegal memory access in ZLIB because of an erroneous declaration of the size of the input buffer.

* compress.c (bfd_get_full_section_contents): Remember to reduce
compressed size by the sizeof the compression header when
decompressing the contents.

7 years agoAdd support for Intel PKRU register to GDB and GDBserver.
Michael Sturm [Wed, 1 Feb 2017 11:22:27 +0000 (12:22 +0100)]
Add support for Intel PKRU register to GDB and GDBserver.

This patch adds support for the registers added by the
Memory Protection Keys for Userspace (PKU aka PKEYs) feature.
Native and remote debugging are covered by this patch.

The XSAVE area is extended with a new state containing
the 32-bit wide PKRU register. The new register is added to
amd64-avx-mpx_avx512-* tdesc, thus it is renamed accordingly. Also,
respective xstate mask X86_XSTATE_AVX_MPX_AVX512_MASK is renamed to
X86_XSTATE_AVX_MPX_AVX512_PKU_MASK to reflect the new feature set
it supports.

For more information, please refer to the
Intel(R) 64 and IA-32 Architectures Software Developer's
Manual - Septemper 2015
http://www.intel.com/content/dam/www/public/us/en/documents/
manuals/64-ia-32-architectures-software-developer-manual-325462.pdf

gdb/Changelog:
2015-12-08  Michael Sturm  <michael.sturm@intel.com>

     * NEWS: Mention addition of PKU feature.
     * amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add PKRU register.
     * amd64-linux-tdep.c (features/i386/amd64-avx-mpx-avx512-linux.c): Rename
       to...
     (features/i386/amd64-avx-mpx-avx512-pku-linux.c): ...this.
     (amd64_linux_gregset_reg_offset): Add PKRU register.
     (amd64_linux_core_read_description): Rename
     X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_pku_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx_mpx_avx512_linux.
     * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Adjust regnum
     calculation.
     (tdesc_amd64_avx_mpx_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_pku_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-mpx-avx512-pku.c): Rename to...
     (features/i386/amd64-avx-mpx-avx512-pku.c): ...this.
     (amd64_pkeys_names): New register name for raw register PKRU.
     (amd64_init_abi): Add code to initialize PKRU tdep variables if feature
     is present.
     (amd64_target_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx_mpx_avx512.
     * amd64-tdep.h (enum amd64_regnum): Add PKRU register.
     (AMD64_NUM_REGS): Adjust regnum calculation.
     * i386-linux.nat.c (GETXSTATEREGS_SUPPLIES): Extend range of
     registers supplied via XSTATE by PKRU register.
     * common/x86-xstate.h (X86_XSTATE_PKRU): New macro.
     (X86_XSTATE_AVX_MPX_AVX512_MASK): Add PKRU and renamed mask.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_AVX_MPX_AVX512_MASK.
     (X86_XSTATE_PKRU_SIZE): New macro.
     (X86_XSTATE_MAX_SIZE): Adjust size.
     (HAS_PKRU(XCR0)): New macro.
     (X86_XSTATE_SIZE): Add checkfor PKRU.
     * features/Makefile (WHICH): Rename i386/i386-avx-mpx-avx512,
     i386/i386-avx-mpx-avx512-linux, i386/amd64-avx-mpx-avx512,
     i386/amd64-avx-mpx-avx512-linux.
     (i386/i386-avx-mpx-avx512-expedite): Rename expedite.
     (i386/i386-avx-mpx-avx512-linux-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-linux-expedite): Likewise.
     (XMLTOC): Rename i386/amd64-avx-mpx-avx512-linux.xml,
     i386/amd64-avx-mpx-avx512.xml, i386/i386-avx-mpx-avx512-linux.xml,
     i386/i386-avx-mpx-avx512.xml.
     ((outdir)/i386/i386-avx-mpx-avx512.dat): Rename rule, add
     i386/32bit-pkeys.xml.
     ((outdir)/i386/i386-avx-mpx-avx512-pku-linux.dat): Likewise.
     ((outdir)/i386/amd64-avx-mpx-avx512.dat): Rename rule, add
     i386/64bit-pkeys.xml.
     ((outdir)/i386/amd64-avx-mpx-avx512-linux.dat): Likewise.
     * features/i386/32bit-pkeys.xml: New file.
     * features/i386/64bit-pkeys.xml: Likewise.
     * features/i386/amd64-avx-mpx-avx512-linux-pku.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512-linux.xml: Rename to
     amd64-avx-mpx-avx512-pku-linux.xml, add 64bit-pkeys.xml
     * features/i386/amd64-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512.xml: Rename to
     amd64-avx-mpx-avx512-pku.xml, add 64bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512-linux.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512-linux.xml: Rename to
     i386-avx-mpx-avx512-pku-linux.xml, add 32bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512.xml: Rename to
     i386-avx-mpx-avx512-pku.xml, add 32bit-pkeys.xml.
     * i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Change to use
     I386_PKEYS_NUM_REGS.
     * i386-linux-tdep.c (features/i386/i386-avx-mpx-avx512-linux.c): Rename
     include.
     (i386_linux_gregset_reg_offset): Add PKRU register.
     (i386_linux_core_read_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_linux_tdep): Rename
     initialize_tdesc_i386_avx_mpx_avx512_linux.
     * i386-linux-tdep.h (I386_LINUX_ORIG_EAX_REGNUM): Adjuste regnum
     calculation.
     (tdesc_i386_avx_mpx_avx512_linux): Rename prototype.
     (/* Format of XSAVE...): Add pkru register.
     * i386-tdep.c (i386-avx-mpx-avx512.c): Rename include.
     (i386_pkeys_names): New register name for raw register PKRU.
     (i386_pkru_regnum_p): Add function to look up register number of
     PKRU raw register.
     (i386_register_reggroup_p): Add code to exclude PKRU from general
     register group.
     (i386_validate_tdesc_p): Add code to handle PKRU feature, add PKRU
     registers if feature is present in xcr0.
     (i386_gdbarch_init): Adjust number of registers in architecture. Add code
     to initialize PKRU feature variables in tdep structure.
     (i386_target_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx_mpx_avx512.
     * i386-tdep.h (struct gdbarch_tdep): Add feature variables to tdep
     structure.
     (enum i386_regnum): Add PKRU register.
     (I386_PKEYS_NUM_REGS): New define for number of registers in PKRU feature.
     (i386_pkru_regnum_p): New prototype.
     * i387-tdep.c (xsave_pkeys_offset): New table for PKRU offsets in
     XSAVE buffer.
     (XSAVE_PKEYS_ADDR): New macro.
     (i387_supply_xsave): Add code to handle PKRU register.
     (i387_collect_xsave): Likewise.
     * i387-tdep.h (I387_NUM_PKEYS_REGS): New define for number of registers
     in PKRU feature.
     (I387_PKRU_REGNUM): New macro.
     (I387_PKEYSEND_REGNUM): Likewise.
     * regformats/i386/amd64_avx_mpx_avx512_pku_linux.dat: Regenerate from
     renamed XML file.
     * regformats/i386/amd64_avx_mpx_avx512_pku.dat: Likewise.
     * regformats/i386/i386/amd64-avx-mpx-avx512-pku.dat: Likewise.
     * regformats/i386/i386_avx_mpx_avx512_pku_linux.dat: Likewise.

testsuite/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.arch/i386-pkru.c: New file.
     * gdb.arch/i386-pkru.exp: Likewise.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx-mpx-avx512.c,
     i386-avx-mpx-avx512-linux.c, amd64-avx-mpx-avx512.c,
     amd64-avx-mpx-avx512-linux.c.
     (i386-avx-mpx-avx512-linux-ipa.o:): Rename rule and source file.
     (amd64-avx-mpx-avx512-linux-ipa.o:): Likewise.
     (i386-avx-mpx-avx512.c :): Rename rule, source files and dat files.
     (i386-avx-mpx-avx512-linux.c :): Likewise.
     (amd64-avx-mpx-avx512.c :): Likewise.
     (amd64-avx-mpx-avx512-linux.c :): Likewise.
     * configure.srv (srv_i386_regobj): Rename i386-avx-mpx-avx512.o.
     (srv_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx-mpx-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-pku-linux-ipa.o.
     (srv_i386_32bit_xmlfiles): Add 32bit-pkeys.xml.
     (srv_i386_64bit_xmlfiles): Add 64bit-pkeys.xml.
     (srv_i386_xmlfiles): Rename i386/i386-avx-mpx-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx-mpx-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx-mpx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename di386/amd64-avx-mpx-avx512-linux.xml.
     * i387-fp.c (num_pkeys_registers): New variable.
     (struct i387_xsave): Add space for pkru values.
     (i387_cache_to_fsave): Add code to handle PKRU register.
     (i387_xsave_to_cache): Likewise.
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename
     tdesc_amd64_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_amd64_avx_mpx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_desc): Rename
     tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-low.c (x86_64_regmap[]): Add PKRU register.
     (x86_linux_read_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_linux, rename
     tdesc_i386_avx_mpx_avx512_linux.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx_mpx_avx512_linux,
     rename tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_arch): Rename init_registers_amd64_avx_mpx_avx512_linux,
     rename init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-tdesc.h (init_registers_amd64_avx_mpx_avx512_linux): Renamed
     prototype.
     (tdesc_amd64_avx_mpx_avx512_linux): Likewise.
     (init_registers_i386_avx_mpx_avx512_linux): Likewise.
     (tdesc_i386_avx_mpx_avx512_linux): Likewise.

doc/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.texinfo (i386 Features): Add description of PKRU register.

Change-Id: If75ce5aba7dfd33fdbe3d8b47f04ef3f550c52be
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoAdd target description for avx-avx512.
Michael Sturm [Tue, 22 Mar 2016 15:26:09 +0000 (16:26 +0100)]
Add target description for avx-avx512.

Add a dedicated target description for the feature combination
avx-avx512 as implemented by certain IA CPU models.

The corresponding X86_XSTATE_AVX_AVX512_MASK already exists, but shared
the tdesc with X86_XSTATE_AVX_MPX_AVX512_MASK. This caused MPX registers
displayed as undefined on CPUs that only implemented
X86_XSTATE_AVX_AVX512_MASK, which is undesired. This patch solves this issue.

This patch also corrects the wrong usage of x32-avx-mpx-avx512, which is
replaced by x32-avx-avx512. The MPX feature is not implemented in x32 mode.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx-avx512-linux.c):
     New include.
     (features/i386/x32-avx-mpx-avx512-linux.c): Rename to...
     (features/i386/x32-avx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_linux_tdep): Add calls to
     initialize_tdesc_amd64_avx_avx512_linux and
     initialize_tdesc_x32_avx_avx512_linux.
     * amd64-linux.tdep.h (tdesc_amd64_avx_avx512_linux): New prototype.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linu): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-avx512.c): New include.
     (features/i386/x32-avx-mpx-avx512.c): Rename to...
     (features/i386/x32-avx-avx512.c): ...this.
     (amd64_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_tdep): Add call to
     initialize_tdesc_amd64_avx_avx512.
     (initialize_tdesc_x32_avx_mpx_avx512): Rename to...
     (initialize_tdesc_x32_avx_avx512): ...this.
     * features/Makefile (WHICH): New tdescs i386/i386-avx-avx512,
     i386/i386-avx-avx512-linux, i386/amd64-avx-avx512,
     i386/amd64-avx-avx512-linux.
     (i386/x32-avx-mpx-avx512): Rename to...
     (i386/x32-avx-avx512): ...this.
     (i386/x32-avx-mpx-avx512-linux): Rename to...
     (i386/x32-avx-avx512-linux): ...this.
     (i386/i386-avx-avx512-expedite, i386/i386-avx-avx512-linux-expedite,
     i386/amd64-avx-avx512-expedite, i386/amd64-avx-avx512-linux-expedite):
     New expedites.
     (i386/x32-avx-mpx-avx512-expedite): Rename to...
     (i386/x32-avx-avx512-expedite): ...this.
     (i386/x32-avx-mpx-avx512-linux-expedite): Rename to...
     (i386/x32-avx-avx512-linux-expedite): ...this.
     (XMLTOC): New XML files i386/amd64-avx-avx512-linux.xml,
     i386/amd64-avx-avx512.xml, i386/i386-avx-avx512-linux.xml,
     i386/i386-avx-avx512.xml.
     (i386/x32-avx-mpx-avx512-linux.xml): Rename to...
     (i386/x32-avx-avx512-linux.xml): ...this.
     (i386/x32-avx-mpx-avx512.xml): Rename to...
     (i386/x32-avx-avx512.xml): ...this.
     ($(outdir)/i386/i386-avx-avx512.dat): New rule.
     ($(outdir)/i386/i386-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx-mpx-avx512.dat):  Rename to...
     ($(outdir)/i386/x32-avx-avx512.dat): ...this.
     ($(outdir)/i386/x32-avx-mpx-avx512-linux.dat): Rename to...
     ($(outdir)/i386/x32-avx-avx512-linux.dat): ...this.
     * features/i386/amd64-avx-avx512-linux.c: New file.
     * features/i386/amd64-avx-avx512-linux.xml: Likewise.
     * features/i386/amd64-avx-avx512.c: Likewise.
     * features/i386/amd64-avx-avx512.xml: Likewise.
     * features/i386/i386-avx-avx512-linux.c: Likewise.
     * features/i386/i386-avx-avx512-linux.xml: Likewise.
     * features/i386/i386-avx-avx512.c: Likewise.
     * features/i386/i386-avx-avx512.xml: Likewise.
     * features/i386/x32-avx-mpx-avx512-linux.c: Deleted.
     * features/i386/x32-avx-avx512-linux.c: New file.
     * features/i386/x32-avx-mpx-avx512-linux.xml: Deleted.
     * features/i386/x32-avx-avx512-linux.xml: New file.
     * features/i386/x32-avx-mpx-avx512.c: Deleted.
     * features/i386/x32-avx-avx512.c: New file.
     * features/i386/x32-avx-mpx-avx512.xml: Deleted.
     * features/i386/x32-avx-avx512.xml: New file.
     * i386-linux-tdep.c (features/i386/i386-avx-avx512-linux.c): New include.
     (i386_linux_core_read_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_linux_tdep): Add call to
     initialize_tdesc_i386_avx_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx_avx512_linux): New prototype.
     * i386-tdep.c (features/i386/i386-avx-avx512.c): New include.
     (i386_validate_tdesc_p): Correct XSTATE mask used for feature_avx512.
     (i386_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_tdep): Add call to initialize_tdesc_i386_avx_avx512.
     * regformats/i386/amd64-avx-avx512-linux.dat: New file
     * regformats/i386/amd64-avx-avx512.dat: Likewise.
     * regformats/i386/i386-avx-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx-avx512.dat: Likewise.
     * regformats/i386/x32-avx-mpx-avx512-linux.dat: Deleted.
     * regformats/i386/x32-avx-avx512-linux.dat: New file.
     * regformats/i386/x32-avx-mpx-avx512.dat: Deleted.
     * regformats/i386/x32-avx-avx512.dat: New file.
     * x86-linux-nat.c (x86_linux_read_description): Add dedidated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate description.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in  (clean): Add handling of new source files
     i386-avx-avx512.c, i386-avx-avx512-linux.c, amd64-avx-avx512.c,
     amd64-avx-avx512-linux.c.
     (x32-avx-mpx-avx512.c): Rename to...
     (x32-avx-avx512.c): ...this.
     (x32-avx-mpx-avx512-linux.c): Rename to...
     (x32-avx-avx512-linux.c): ...this.
     (i386-avx-avx512-linux-ipa.o): New rule.
     (amd64-avx-avx512-linux-ipa.o): Likewise.
     (i386-avx-avx512.c): Likewise.
     (i386-avx-avx512-linux.c): Likewise.
     (amd64-avx-avx512.c): Likewise.
     (amd64-avx-avx512-linux.c): Likewise.
     (x32-avx-avx512.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512.*) to this.
     (x32-avx-avx512-linux.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512-linux.*) to this.
     * configure.srv (srv_i386_regobj): Add i386-avx-avx512.o.
     (srv_i386_linux_regobj): Add i386-avx-avx512-linux.o.
     (srv_amd64_regobj): Add amd64-avx-avx512.o, rename
     x32-avx-mpx-avx512.o to x32-avx-avx512.o.
     (srv_amd64_linux_regobj): Add amd64-avx-avx512-linux.o, rename
     x32-avx-mpx-avx512-linux.o to x32-avx-avx512-linux.o.
     (ipa_i386_linux_regobj): Add i386-avx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Add amd64-avx-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Add i386/i386-avx-avx512.xml.
     (srv_amd64_xmlfiles): Add i386/amd64-avx-avx512.xml, rename
     x32-avx-mpx-avx512.xml to x32-avx-avx512.xml.
     (srv_i386_linux_xmlfiles): Add i386/i386-avx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-avx512-linux.xml,
     rename x32-avx-mpx-avx512-linux.xml to x32-avx-avx512-linux.xml.
     * linux-amd64-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_amd64_avx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_i386_avx_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (x86_get_ipa_tdesc_idx): Rename tdesc_x32_avx_mpx_avx512_linux to
     tdesc_x32_avx_avx512_linux, add dedicated if-clause for
     tdesc_amd64_avx_avx512_linux and return appropriate mask.
     Add dedicated clause for tdesc_i386_avx_avx512_linux
     and return appropriate mask.
     (initialize_low_arch): Add init_registers_amd64_avx_avx512_linux,
     rename init_registers_x32_avx_mpx_avx512_linux, add
     init_registers_i386_avx_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Add new value for
     X86_TDESC_AVX_AVX512.
     (init_registers_amd64_avx_avx512_linux): New prototype.
     (tdesc_amd64_avx_avx512_linux): Likewise.
     (init_registers_x32_avx_mpx_avx512_linux): Rename to...
     (init_registers_x32_avx_avx512_linux): ...this.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linux): ...this.
     (init_registers_i386_avx_avx512_linux): New prototype.
     (tdesc_i386_avx_avx512_linux): Likewise.

Change-Id: I01359fab56c961a39568df50af39714ec7b31706
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoRename target descriptions to reflect actual content of description.
Michael Sturm [Fri, 27 Jan 2017 15:14:28 +0000 (16:14 +0100)]
Rename target descriptions to reflect actual content of description.

To better reflect the actual feature set covered by the IA target
descriptions, the existing descriptions are renamed. Each feature of
the extended state is added to the name of a description or xstate mask
starting from AVX.
For example, amd64-mpx-avx512-linux becomes amd64-avx-mpx-avx512-linux,
while amd64-avx-linux remains unchanged.
Likewise, the corresponding xstate masks are changed, e.g. from
X86_XSTATE_MPX_AVX512_MASK to X86_XSTATE_AVX_MPX_AVX512_MASK.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx512-linux.c): Rename
     include to...
     (features/i386/amd64-avx-mpx-avx512-linux.c): ...this.
     (features/i386/x32-avx512-linux.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, desc_x32_avx512_linux, tdesc_amd64_avx512_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx512_linux, initialize_tdesc_x32_avx512_linux.
     * amd64-linux-tdep.h (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx512.c): Rename include to...
     (features/i386/amd64-avx-mpx-avx512.c): ...this.
     (features/i386/x32-avx512.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512.c): ...this.
     (amd64_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_amd64_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx512. Rename
     initialize_tdesc_x32_avx512.
     * common/x86-xstate.h (X86_XSTATE_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_AVX512_MASK): ...this.
     (86_XSTATE_MPX_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_MPX_AVX512_MASK): ...this.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_MPX_AVX512_MASK to
     X86_XSTATE_AVX_MPX_AVX512_MASK.
     * features/Makefile (WHICH): Rename i386/i386-avx512,
     i386/i386-avx512-linux, i386/amd64-avx512, i386/amd64-avx512-linux,
     i386/x32-avx512, i386/x32-avx512-linux.
     (i386/i386-avx512-expedite, i386/i386-avx512-linux-expedite,
     i386/amd64-avx512-expedite, i386/amd64-avx512-linux-expedite,
     i386/x32-avx512-expedite, i386/x32-avx512-linux-expedite): Rename
     expedites.
     (XMLTOC): Rename i386/amd64-avx512-linux.xml, i386/amd64-avx512.xml,
     i386/i386-avx512-linux.xml, i386/i386-avx512.xml,
     i386/x32-avx512-linux.xml, i386/x32-avx512.xml.
     ($(outdir)/i386/i386-avx512.dat): Rename dat file in rule.
     ($(outdir)/i386/i386-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx512.dat): Likewise.
     ($(outdir)/i386/x32-avx512-linux.dat): Likewise.
     * features/i386/amd64-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512-linux.xml: Rename XML file.
     * features/i386/amd64-avx512.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512.xml: Rename XML file.
     * features/i386/i386-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512-linux.xml: Rename XML file.
     * features/i386/i386-avx512.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512.xml: Rename XML file.
     * features/i386/x32-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512-linux.xml: Rename XML file.
     * features/i386/x32-avx512.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512.xml: Rename XML file.
     * i386-linux-tdep.c (features/i386/i386-avx512-linux.c): Rename to...
     (features/i386/i386-avx-mpx-avx512-linux.c): ...this.
     (i386_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_i386_avx512_linux.
     (_initialize_i386_linux_tdep): Rename initialize_tdesc_i386_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.
     * i386-tdep.c (features/i386/i386-avx512.c): Rename to...
     (features/i386/i386-avx-mpx-avx512.c): ...this.
     (i386_register_reggroup_p): Rename X86_XSTATE_AVX512_MASK.
     (i386_validate_tdesc_p): Likewise.
     (i386_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     tdesc_i386_avx512.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx512.
     * regformats/i386/amd64-avx512-linux.dat: Regenerate from renamed XML
     file.
     * regformats/i386/amd64-avx512.dat: Likewise.
     * regformats/i386/i386-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx512.dat: Likewise.
     * regformats/i386/x32-avx512-linux.dat: Likewise.
     * regformats/i386/x32-avx512.dat: Likewise.
     * x86-Linux-nat.c (x86_linux_read_description): Rename
     X86_XSTATE_MPX_AVX512_MASK, X86_XSTATE_AVX512_MASK,
     tdesc_x32_avx512_linux, tdesc_amd64_avx512_linux, tdesc_i386_avx512_linux.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx512.c, i386-avx512-linux.c,
     amd64-avx512.c, amd64-avx512-linux.c, x32-avx512.c, x32-avx512-linux.c.
     (i386-avx512-linux-ipa.o): Rename rule and source files.
     (amd64-avx512-linux-ipa.o): Likewise.
     (i386-avx512.c): Rename rule, source fils and dat files.
     (i386-avx512-linux.c): Likewise.
     (amd64-avx512.c): Likewise.
     (amd64-avx512-linux.c): Likewise.
     (x32-avx512.c): Likewise.
     (x32-avx512-linux.c): Likewise.
     * configfure.srv (srv_i386_regobj): Rename i386-avx512.o.
     (i386_linux_regobj): Rename i386-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx512.o, x32-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx512-linux.o,
     x32-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Rename i386/i386-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx512.xml, i386/x32-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename i386/amd64-avx512-linux.xml,
     i386/x32-avx512-linux.xml).
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and returned
     tdesc for that case.
     (initialize_low_tracepoint): Rename init_registers_amd64_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and tdesc
     returned for that case.
     (initialize_low_tracepoint): Rename init_registers_i386_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Rename
     X86_XSTATE_AVX512_MASK and tdesc returned for that case.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx512_linux,
     tdesc_x32_avx512_linux and mask returned for these descriptions.
     Rename tdesc_i386_avx512_linux and mask returned for that description.
     (initialize_low_arch): Rename init_registers_amd64_avx512_linux,
     init_registers_x32_avx512_linux, init_registers_i386_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Rename X86_TDESC_AVX512.
     (init_registers_amd64_avx512_linux): Rename to...
     (init_registers_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (init_registers_x32_avx512_linux): Rename to...
     (init_registers_x32_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     (init_registers_i386_avx512_linux): Rename to...
     (init_registers_i386_avx_mpx_avx512_linux): ...this.
     (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.

Change-Id: Idb83be3b3b72d5487542d4b568193df2777a3d9d
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoChange xstate_bv handling to use 8 bytes of data.
Michael Sturm [Wed, 3 Feb 2016 16:55:20 +0000 (17:55 +0100)]
Change xstate_bv handling to use 8 bytes of data.

The size of the state-component bitmap as specified in
Intel(R) 64 and IA-32 Architectures Software Developer's Manual,
Chapter 13.4.2 is 8 bytes.
So far, the data types used for xstate_bv_p (gdb_byte*),
clear_bv (unsigned int) and tdep->xcr0 (uint64_t) were
inconsistent. But, since the xstate components were still
fitting into a single byte, the code still worked
as expected.
However, with the addition of the PKU feature (bit 9),
using one byte for the bitmap will no longer be sufficient.

This patch changes related code to use 64 bit data types
consistently and changes read/write acces of the XSAVE
header in the xsave buffer to use the endianess-aware
functions extract_unsigned_integer and store_unsigned_integer.
This is required to make sure that eventual differences
in endianess between host and target are taken care off.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * i387-tdep.c (i387_supply_xsave): Change type
     of clear_bv to ULONGEST. Replace gdb_byte *xstate_bv_p
     with ULONGEST xstate_bv and use extract_unsigned_integer
     and store_unsigned_integer to read/write its value from
     the xsave buffer.
     (i387_collect_xsave): Replace gdb_byte *xstate_bv_p
     with ULONGEST initial_xstate_bv and use
     extract_unsigned_integer/store_unsigned_integer to
     read/write its value from the xsave buffer.
     Change type of clear_bv to ULONGEST.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * i387-fp.c (i387_cache_to_xsave): Change type of clear_bv to
     unsigned long long.
     (i387_fxsave_to_cache): Likewise.

Change-Id: I0de254158960b4f7bcbc9fe2fb857034fa1f7ca5
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoSync up x86-gcc-cpuid.h with cpuid.h from gcc-6 branch.
Michael Sturm [Mon, 5 Dec 2016 14:03:06 +0000 (15:03 +0100)]
Sync up x86-gcc-cpuid.h with cpuid.h from gcc-6 branch.

Pedro suggested a separate patch synching with GCCs cpuid.h
instead of just adding new bits for PKU feature.

 gdb/Changelog:
     2016-11-14  Michael Sturm  <michael.sturm@intel.com>

          * nat/x86-gcc-cpuid.h: Replace with copy of cpuid.h
            from gcc-6 branch.

Change-Id: I16f8f7f2d0aa7c2e815701d15ed831a6c6b33d21
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoRelax dwarf2 expected error match
Alan Modra [Fri, 17 Feb 2017 07:28:17 +0000 (17:58 +1030)]
Relax dwarf2 expected error match

* testsuite/ld-elf/dwarf2.err: Accept other errors between the
multiple definition errors.

7 years agoRelax dwarf3 expected error match
Alan Modra [Fri, 17 Feb 2017 06:54:02 +0000 (17:24 +1030)]
Relax dwarf3 expected error match

* testsuite/ld-elf/dwarf2.err: Add missing newline at end.
* testsuite/ld-elf/dwarf3.err: Likewise.  Allow match without filename.

7 years agobfd: Rename Chunk and S3Forced
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)]
bfd: Rename Chunk and S3Forced

The direct references in objcopy kind of look like a hack to me, so
I'm calling these symbols internal too.  Certainly they aren't named
and documented as a public BFD symbol today anyway.

So ... give these bfd-internal symbols with external linkage a _bfd_
prefix to avoid collisions in the global symbol namespace.

While at it, give them names that more closely match the corresponding
option name that toggles them.

Also while at it, fix a few related comment typos.

gdb/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* srec.c (Chunk): Rename to ...
(_bfd_srec_len): ... this.
(S3Forced): Rename to ...
(_bfd_srec_forceS3): ... this.
* objcopy.c: Adjust all references.

7 years agobfd: Rename bsd_write_armap and coff_write_armap
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)]
bfd: Rename bsd_write_armap and coff_write_armap

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* archive.c (bsd_write_armap): Rename to ...
(_bfd_bsd_write_armap): ... this.
(coff_write_armap): Rename to ...
(_bfd_coff_write_armap): ... this.
* libbfd-in.h (bsd_write_armap): Rename to ...
(_bfd_bsd_write_armap): ... this.
(coff_write_armap): Rename to ...
(_bfd_coff_write_armap): ... this.
* aout-target.h, aout-tic30.c: Adjust all users.
* libbfd.h: Regenerate.

7 years agobfd: Rename warn_deprecated
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)]
bfd: Rename warn_deprecated

Give this bfd-internal symbol with external linkage a _bfd_ prefix to
avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* bfd-in.h (bfd_read, bfd_write): Adjust to rename.
(warn_deprecated): Rename to ...
(_bfd_warn_deprecated): ... this.
* libbfd.c (warn_deprecated): Rename to ...
(_bfd_warn_deprecated): ... this.
* bfd-in2.h: Regenerate.

7 years agobfd: Rename real_{ftell, fseek, fopen}
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)]
bfd: Rename real_{ftell, fseek, fopen}

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* bfdio.c (real_ftell): Rename to ...
(_bfd_real_ftell): ... this.
(real_fseek): Rename to ...
(_bfd_real_fseek): ... this.
(real_fopen): Rename to ...
(_bfd_real_fopen): ... this.
* libbfd-in.h (real_ftell): Rename to ...
(_bfd_real_ftell): ... this.
(real_fseek): Rename to ...
(_bfd_real_fseek): ... this.
(real_fopen): Rename to ...
(_bfd_real_fopen): ... this.
* cache.c, dwarf2.c, opncls.c: Adjust all callers.
* libbfd.h: Regenerate.

7 years agobfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
Pedro Alves [Fri, 17 Feb 2017 01:26:11 +0000 (01:26 +0000)]
bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* dwarf2.c, elf-attrs.c, elf32-nds32.c: Adjust all callers.
* libbfd.c (read_unsigned_leb128): Rename to ...
(_bfd_read_unsigned_leb128): ... this.
(read_signed_leb128): Rename to ...
(_bfd_read_signed_leb128): ... this.
(safe_read_leb128): Rename to ...
(_bfd_safe_read_leb128): ... this.
* libbfd-in.h (read_unsigned_leb128): Rename to ...
(_bfd_read_unsigned_leb128): ... this.
(read_signed_leb128): Rename to ...
(_bfd_read_signed_leb128): ... this.
(safe_read_leb128): Rename to ...
(_bfd_safe_read_leb128): ... this.
* libbfd.h: Renegerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Feb 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agobfd: Improve lookup of file / line information for errors
Andrew Burgess [Mon, 19 Dec 2016 15:27:59 +0000 (15:27 +0000)]
bfd: Improve lookup of file / line information for errors

When looking up file and line information (used from the linker to
report error messages) if no symbol is passed in, then use the symbol
list to look for a matching symbol.

If a matching symbol is found then use this to look up the file / line
information.

This should improve errors when looking up file / line information for
data sections.  Hopefully we should find a matching data symbol, which
should, in turn (we hope) match a DW_TAG_variable in the DWARF, this
should allow us to give accurate file / line errors for data symbols.

As the hope is to find a matching DW_TAG_variable in the DWARF then we
ignore section symbols, and prefer global symbols to locals.

bfd/ChangeLog:

* dwarf2.c (_bfd_dwarf2_find_nearest_line): Perform symbol lookup
before trying to fine matching file and line information.

ld/ChangeLog:

* testsuite/ld-elf/shared.exp: Update expected results.
* testsuite/ld-elf/dwarf2.err: Likewise

7 years agobfd/dwarf: Improve use of previously loaded dwarf information
Andrew Burgess [Thu, 15 Dec 2016 15:22:49 +0000 (15:22 +0000)]
bfd/dwarf: Improve use of previously loaded dwarf information

When parsing DWARF data in order to report file/line type error messages
we perform section placement to make section addresses unique within
relocatable object files.

Currently, if we reuse previously loaded (and cached) dwarf data then we
neglect to perform section placement, the result is that the section
addresses will not be unique, and we might, incorrectly associate an
address with the wrong debug information, and so report an incorrect
file and line number.

Further we neglect to check that that bfd for which we are looking up
debug information is actually the bfd for which the previous debug
information was loaded, it is possible that we will reuse previously
loaded debug information for a different bfd.

And finally, due to following of gnu_debuglink links in one bfd to
another, the process of checking that the cached debug information is
valid requires us to track the original bfd in the cached debug
information.  The original debug information here is either the bfd that
we're interested in, not the bfd we finally load the debug information
from.

bfd/ChangeLog:

* dwarf2.c (struct dwarf2_debug): Add orig_bfd member.
(_bfd_dwarf2_slurp_debug_info): If stashed debug information does
not match current bfd, then reload debug information.  Record bfd
we're loading debug info for in the stash.  If we have debug
informatin in the cache then perform section placement before
returning.

ld/ChangeLog:

* testsuite/ld-elf/dwarf.exp (build_tests): Add new tests.
* testsuite/ld-elf/dwarf2.err: New file.
* testsuite/ld-elf/dwarf2a.c: New file.
* testsuite/ld-elf/dwarf2b.c: New file.
* testsuite/ld-elf/dwarf3.c: New file.
* testsuite/ld-elf/dwarf3.err: New file.

7 years agold: Add additional checking for warnings/errors in testsuite
Andrew Burgess [Tue, 7 Feb 2017 22:31:46 +0000 (22:31 +0000)]
ld: Add additional checking for warnings/errors in testsuite

This commit adds new actions to the run_cc_link_tests mechanism in the
linker testsuite.

Previously this procedure could take a parameter containing a regular
expression that would be matched against warnings from the linker.

After this commit the warnings parameter is removed, instead, the
actions list can contain the actions 'warning', 'error',
'warning_output', or 'error_output'.  The action names are chosen to
match the actions already present in the run_dump_test procedure.

These new actions allow for the current warning checking, but also allow
for checking of errors using a regular expression.  More interestingly,
the *_output actions allow for the warning/error patterns to be placed
in a separate file.

The small number of tests that make use of the warning parameter have
been updated to the new mechanism.  Later commits will make use of the
new features added in this commit.

ld/ChangeLog:

* testsuite/lib/ld-lib.exp (run_cc_link_tests): Add warning,
error, warning_output, and error_output actions.  Remove separate
warnings parameter.
* testsuite/ld-elf/shared.exp (build_tests): Updated to use
'warning' action.
* testsuite/ld-plugin/lto.exp (lto_link_tests): Likewise.

7 years agold testsuite function pointer comparisons vs. hppa
Alan Modra [Thu, 16 Feb 2017 11:49:10 +0000 (22:19 +1030)]
ld testsuite function pointer comparisons vs. hppa

ld/testsuite/ld-elf/check-ptr-eq.c fails for hppa, since function
pointers may point at plabels.  It isn't valid to cast two function
pointers to void* and then compare the void pointers.

* testsuite/ld-elf/check-ptr-eq.c (check_ptr_eq): Change params
from void pointers to function pointers.
* testsuite/ld-elf/pr18718.c: Update to suit.
* testsuite/ld-elf/pr18720a.c: Update to suit.

7 years agohppa -z relro again
Alan Modra [Tue, 14 Feb 2017 00:15:51 +0000 (10:45 +1030)]
hppa -z relro again

I misunderstood the hppa alias problem.  File offsets of segments need
to be such that no page is mapped twice with different permissions.
(Which still seems to me like something the kernel could fix, but
anyhow, this is not so difficult to achieve in ld.)

PR 21000
bfd/
* elf-bfd.h (struct elf_backend_data): Add no_page_alias.
* elfxx-target.h (elf_backend_no_page_alias): Define.
(elfNN_bed): Init new field.
* elf.c (assign_file_positions_for_load_sections): If no_page_alias
ensure PT_LOAD segment starts on a new page.
* elf32-hppa.c (elf_backend_no_page_alias): Define.
ld/
* testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets.
* testsuite/ld-elf/loadaddr2.d: Likewise.
* testsuite/ld-elf/loadaddr3a.d: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.

7 years agoPR21132, hppa-linux pie support doesn't work
Alan Modra [Thu, 16 Feb 2017 01:53:12 +0000 (12:23 +1030)]
PR21132, hppa-linux pie support doesn't work

This fixes a long-standing hppa bug seen when generating PIEs, and I
think possible to trigger with forced local symbols in shared
libraries.  Not allocating enough space for PLT relocs results in ld
writing outside of the buffer.

PR 21132
* elf32-hppa.c (allocate_plt_static): Allocate space for relocs
if pic.

7 years agoFix more powerpc testsuite source errors
Alan Modra [Thu, 16 Feb 2017 04:43:56 +0000 (15:13 +1030)]
Fix more powerpc testsuite source errors

* testsuite/ld-powerpc/vxworks1-lib.s: Correct addi to addic.
* testsuite/ld-powerpc/vxworks1-lib.dd: Adjust to suit.

7 years ago[Patch] Add BFD_LINKER_CREATED to BFD_FLAGS_SAVED
Jiong Wang [Thu, 16 Feb 2017 09:40:03 +0000 (09:40 +0000)]
[Patch] Add BFD_LINKER_CREATED to BFD_FLAGS_SAVED

bfd/
* bfd.c (BFD_FLAGS_SAVED): Add BFD_LINKER_CREATED.
* bfd-in2.h: Regenerated.

Bug exposed by https://sourceware.org/ml/binutils/2017-02/msg00128.html

7 years agoPR gdb/21164: maint print {symbols,msymbols,psymbols} without args crash
Sergio Durigan Junior [Wed, 15 Feb 2017 20:08:19 +0000 (15:08 -0500)]
PR gdb/21164: maint print {symbols,msymbols,psymbols} without args crash

This is a fix for PR gdb/21164.  The problem started to happen after:

 commit 34c41c681f4a0a0dfe0405c7d2aecf458520557a
 Author:     Doug Evans <xdje42@gmail.com>
 AuthorDate: Mon Dec 19 08:33:46 2016 -0800

    New syntax for mt print symbols,msymbols,psymbols.

This change introduced new syntax for the mentioned commands, and
improved the parsing of arguments by using 'gdb_buildargv'.  However,
it is necessary to check if the argv being built is not NULL, which
can happen if the user doesn't provide any arguments to these
commands.

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

PR gdb/21164
* psymtab.c (maintenance_print_psymbols): Verify if 'argv' is not
NULL before using it.
* symmisc.c (maintenance_print_symbols): Likewise.
(maintenance_print_msymbols): Likewise.

gdb/testsuite/ChangeLog:

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

PR gdb/21164
* gdb.base/maint.exp: Add testcases for when the commands do
not have arguments.