binutils-gdb.git
4 years agoPR26445 UBSAN: elf32-csky.c:4115 left shift of negative value
Alan Modra [Mon, 31 Aug 2020 00:20:49 +0000 (09:50 +0930)]
PR26445 UBSAN: elf32-csky.c:4115 left shift of negative value

PR 26445
* elf32-csky.c (csky_relocate_contents): Make relocation a bfd_vma,
and similarly for variables dealing with overflow.

4 years agocrx: ubsan: cannot be represented
Alan Modra [Sun, 30 Aug 2020 23:37:03 +0000 (09:07 +0930)]
crx: ubsan: cannot be represented

* config/tc-crx.c: Formatting.
(CRX_PRINT): Wrap params in parentheses.  Remove parens from uses
throughout file.
(reset_vars, get_register, get_copregister, get_optype, get_opbits),
(get_opflags, get_number_of_operands, parse_operand, gettrap),
(handle_LoadStor, getconstant, check_range, getreg_image),
(parse_operands, parse_insn, print_operand, print_constant),
(exponent2scale, mask_reg, process_label_constant, set_operand),
(assemble_insn, print_insn): Delete unnecessary forward declaration.
(print_insn): Make static.
(print_constant): Make "constant" unsigned.
(assemble_insn): Tidy REVERSE_MATCH index calc.
* expr.c (generic_bignum_to_int32): Cast elements to valueT.

4 years agoPR26442 UBSAN: elf32-crx.c:512 cannot be represented in int
Alan Modra [Sun, 30 Aug 2020 23:02:32 +0000 (08:32 +0930)]
PR26442 UBSAN: elf32-crx.c:512 cannot be represented in int

PR 26442
* elf32-crx.c (crx_elf_final_link_relocate): Calculate reloc_bits
without undefined behaviour.  Tidy excess casts.

4 years agoPR26509 UBSAN: tc-z80.c:3656 shift exponent is too large
Alan Modra [Sun, 30 Aug 2020 22:43:19 +0000 (08:13 +0930)]
PR26509 UBSAN: tc-z80.c:3656 shift exponent is too large

PR 26509
* config/tc-z80.c (is_overflow): Use 1UL in mask shift expression.

4 years agomn10300: ubsan: shift exponent too large
Alan Modra [Sun, 30 Aug 2020 22:39:23 +0000 (08:09 +0930)]
mn10300: ubsan: shift exponent too large

* elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate
alignment from reloc addend after reloc type R_MN10300_ALIGN is
found.

4 years agotic4x-coff: ubsan: various shift UB
Alan Modra [Sun, 30 Aug 2020 14:13:54 +0000 (23:43 +0930)]
tic4x-coff: ubsan: various shift UB

* config/tc-tic4x.c (tic4x_gen_to_words): Rewrite mantissa
overflow test without UB.  Avoid other UB shifts by making them
unsigned.

4 years ago[gdb/testsuite] Add nopie to gdb.base/eh_return.exp
Tom de Vries [Mon, 31 Aug 2020 08:42:01 +0000 (10:42 +0200)]
[gdb/testsuite] Add nopie to gdb.base/eh_return.exp

When running test-case gdb.base/eh_return.exp with target board
unix/-fPIE/-pie, we run into:
...
(gdb) break *0x88e^M
Breakpoint 1 at 0x88e: file eh_return.c, line 54.^M
(gdb) PASS: gdb.base/eh_return.exp: setting breakpoint at *0x88e
run ^M
Starting program: eh_return ^M
Warning:^M
Cannot insert breakpoint 1.^M
Cannot access memory at address 0x88e^M
^M
(gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint
...

The problem is that gdb does not support setting breakpoints on unrelocated
addresses.

Fix this by using nopie for the test-case.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-08-31  Tom de Vries  <tdevries@suse.de>

* gdb.base/eh_return.exp: Use nopie.

4 years agoCSKY: Refine operand format error reporting.
Cooper Qu [Mon, 31 Aug 2020 03:27:54 +0000 (11:27 +0800)]
CSKY: Refine operand format error reporting.

Rename SET_ERROR_NUMBER to SET_ERROR_STRING, and add SET_ERROR_INTEGER
to report error message which pass an integer argument.

gas/
* config/tc-csky.c (csky_error_state): New member 'arg_int'.
(SET_ERROR_NUMBER): Rename to SET_ERROR_STRING.
(SET_ERROR_INTEGER): New.
(err_formats): Add error format for ERROR_FREG_OVER_RANGE and
ERROR_VREG_OVER_RANGE.
(csky_show_error): Pass an integer argument for some error
numbers.
(parse_exp): Call SET_ERROR_STRING instead of SET_ERROR_NUMBER.
(parse_rt): Likewise.
(parse_type_ctrlreg): Likewise.
(csky_get_reg_val): Likewise.
(is_reglist_legal): Likewise.
(is_freglist_legal): Likewise.
(is_reglist_dash_comma_legal): Likewise.
(is_reg_lshift_illegal): Likewise.
(is_psr_bit): Likewise.
(parse_type_cpreg): Likewise.
(parse_type_cpcreg): Likewise.
(parse_type_areg): Likewise.
(parse_type_freg): Likewise.
(parse_ldst_imm): Likewise and call SET_ERROR_INTEGER.
(get_operand_value): Likewise.
(parse_operands_op): Likewise and call is_imm_within_range,
is_imm_within_range_ext and is_oimm_within_range.
(md_assemble): Likewise.
(is_imm_within_range): New.
(is_imm_within_range_ext): Rename from is_imm_over_range.
(is_oimm_within_range): Rename from is_oimm_over_range.
(v2_work_add_sub): Call SET_ERROR_INTEGER.
(csky_rolc): call is_imm_within_range instead of
is_imm_over_range.

opcodes/
* csky-dis.c (csky_output_operand): Assign dis_info.value for
OPRND_TYPE_VREG.

4 years agoCSKY: Add warning when -mdsp and -mcpu=ck803ern are both added.
Cooper Qu [Mon, 31 Aug 2020 02:55:06 +0000 (10:55 +0800)]
CSKY: Add warning when -mdsp and -mcpu=ck803ern are both added.

gas/
* config/tc-csky.c (md_begin): Add warning when -mdsp and
  -mcpu=ck803ern are both added.
  (parse_ldst_imm): Fix error message.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 31 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agold: Add $NOSANTIZE_CFLAGS to more linker tests
H.J. Lu [Sun, 30 Aug 2020 14:27:02 +0000 (07:27 -0700)]
ld: Add $NOSANTIZE_CFLAGS to more linker tests

* testsuite/ld-elf/dwarf.exp: Append $NOSANTIZE_CFLAGS to CFLAGS.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.

4 years agochangelog PR fix
Alan Modra [Sun, 30 Aug 2020 13:29:13 +0000 (22:59 +0930)]
changelog PR fix

for the lack of a space

4 years agoreadelf: ubsan: shift exponent 32 is too large
Alan Modra [Sun, 30 Aug 2020 10:57:27 +0000 (20:27 +0930)]
readelf: ubsan: shift exponent 32 is too large

When compiled on a 32-bit host, a temp var is too small for possible
64-bit values to be calculated.

* readelf.c (print_gnu_build_attribute_name): Make "bytes"
unsigned long long.

4 years agocr16 disassembly error of disp20 fields
Alan Modra [Sun, 30 Aug 2020 10:10:31 +0000 (19:40 +0930)]
cr16 disassembly error of disp20 fields

When looking at the UB errors, I noticed that cbitb_test.d disassembly
wasn't reproducing the input assembly.  That turned out to be an error
in make_argument case arg_cr.  This fixes that and makes some general
tidies.

opcodes/
* cr16-dis.c: Formatting.
(parameter): Delete struct typedef.  Use dwordU instead
throughout file.
(make_argument <arg_idxr>): Simplify detection of cbitb, sbitb
and tbitb.
(make_argument <arg_cr>): Extract 20-bit field not 16-bit.
gas/
* testsuite/gas/cr16/cbitb_test.d: Update expected output.
* testsuite/gas/cr16/cbitw_test.d: Likewise.
* testsuite/gas/cr16/sbitb_test.d: Likewise.
* testsuite/gas/cr16/sbitw_test.d: Likewise.
* testsuite/gas/cr16/storb_test.d: Likewise.
* testsuite/gas/cr16/storw_test.d: Likewise.
* testsuite/gas/cr16/tbitb_test.d: Likewise.
* testsuite/gas/cr16/tbitw_test.d: Likewise.

4 years agoPR26437, PR26438 UBSAN: tc-cr16.c left shifts and overflows
Alan Modra [Sun, 30 Aug 2020 10:07:57 +0000 (19:37 +0930)]
PR26437, PR26438 UBSAN: tc-cr16.c left shifts and overflows

Always use unsigned constants in expressions generating masks.  The
following trys mightily to avoid UB (but hits it anyway with bits=32
and 0x7fffffff << 1), and worse, for 32-bit int, 64-bit long, bits=32
doesn't generate 0xffffffff.
    max = ((((1 << (bits - 1)) - 1) << 1) | 1);
results in -1, or max = 0xffffffffffffffff.

This patch fixes that problem, a possible shift exponent of -1U,
removes some dead code, and makes general tidies.

PR26437
PR26438
* config/tc-cr16.c: Include limits.h, formatting.
(CR16_PRINT): Wrap params in parentheses.  Remove parens from uses
throughout file.
(getconstant): Handle zero nbits.
(print_operand): Simplify handling of index regs.
(check_range): Use int32_t variables.  Correct range checks.

4 years agoPR26435, PR26436 UBSAN: elf32-cr16.c:928 left shift
Alan Modra [Sun, 30 Aug 2020 10:07:15 +0000 (19:37 +0930)]
PR26435, PR26436 UBSAN: elf32-cr16.c:928 left shift

PR 26435
PR 26436
* elf32-cr16.c (cr16_elf_final_link_relocate): Calculate reloc_bits
without undefined behaviour.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 30 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoInclude members in the variable table used when resolving DW_AT_specification tags.
Nick Clifton [Sat, 29 Aug 2020 07:03:15 +0000 (08:03 +0100)]
Include members in the variable table used when resolving DW_AT_specification tags.

PR 26520
* dwarf2.c (scan_unit_for_symbols): Add member entries to the
variable table.

4 years agocorrect pr number in changelog
Alan Modra [Sat, 29 Aug 2020 04:27:27 +0000 (13:57 +0930)]
correct pr number in changelog

4 years agoPR26446 UBSAN: tc-csky.c:2618,4022 index out of bounds
Alan Modra [Sat, 29 Aug 2020 01:40:54 +0000 (11:10 +0930)]
PR26446 UBSAN: tc-csky.c:2618,4022 index out of bounds

PR 26446
* csky-opc.h (MAX_OPRND_NUM): Define to 5.
(union csky_operand): Use MAX_OPRND_NUM to size oprnds array.

4 years agoPR26481 UBSAN: tc-pj.c:281 index out of bounds
Alan Modra [Sat, 29 Aug 2020 01:16:59 +0000 (10:46 +0930)]
PR26481 UBSAN: tc-pj.c:281 index out of bounds

PR 26481
* config/tc-pj.c (md_assemble): Don't loop past end of
opcode->arg array.

4 years agoPR26459 UBSAN: elfnn-ia64.c:1945 null pointer bsearch
Alan Modra [Sat, 29 Aug 2020 01:00:07 +0000 (10:30 +0930)]
PR26459 UBSAN: elfnn-ia64.c:1945 null pointer bsearch

PR 26495
* elfnn-ia64.c (get_dyn_sym_info): Don't bsearch or look at last
element when count is zero.  bfd_realloc when shrinking.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Aug 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAdjust "maint info program-spaces" to per-inferior target stack
Pedro Alves [Fri, 28 Aug 2020 23:11:35 +0000 (00:11 +0100)]
Adjust "maint info program-spaces" to per-inferior target stack

By inspection, I noticed that print_program_space is calling
target_pid_to_str on the wrong target stack.  Most targets print a
process pid the same way, so it isn't actually visible.

gdb/ChangeLog:

* progspace.c (print_program_space): Use all_inferiors.  Switch to
the inferior before calling target_pid_to_str.

4 years agoFix gdb.base/advance-until-multiple-locations.exp with some compilers
Pedro Alves [Fri, 28 Aug 2020 17:44:39 +0000 (18:44 +0100)]
Fix gdb.base/advance-until-multiple-locations.exp with some compilers

The tests in gdb.base/advance-until-multiple-locations.exp that expect
the program to stop at a caller fail on some systems, depending on
compiler.  E.g., with Clang 10, I see:

 advance ovld_func
 0x00000000004011a3 in test () at /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc:51
 51        ovld_func ();
 (gdb) FAIL: gdb.base/advance-until-multiple-locations.exp: advance_overload: second advance stops at caller

And Tom de Vries saw:

 ...
 (gdb) until ovld_func^M
 main () at advance-until-multiple-locations.cc:61^M
 61      }^M
 (gdb) FAIL: gdb.base/advance-until-multiple-locations.exp:until_overload: until ovld_func
 ...

Which exact line the program stops is not important.  All we care
about here is that the program stopped at the caller function.

So fix it by adjusting the patterns to match the frame header/function
reported by the breakpoint hits instead of the source lines text.

Tested against:

 - gcc {4.8, 4.9, 7.3.1, 9.3.0, trunk-20200828}
 - clang {5.0.2, 10}

gdb/testsuite/ChangeLog:

* gdb.base/advance-until-multiple-locations.exp
(advance_overload, until_overload): Adjust to match the
frame/function header instead of the source line text.

4 years agoFix two out-of-date comments
Tom Tromey [Fri, 28 Aug 2020 17:07:36 +0000 (11:07 -0600)]
Fix two out-of-date comments

While looking at psymtabs again, I noticed a couple of outdated
comments.  These days, psymtabs can be destroyed, as they are no
longer obstack-allocated.

gdb/ChangeLog
2020-08-28  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_end_psymtab): Update comment.
* dbxread.c (dbx_end_psymtab): Update comment.

4 years agoFix a bogus error message from the DWARF LEB129 decoder when trying to read a signed...
Nick Clifton [Fri, 28 Aug 2020 15:04:49 +0000 (16:04 +0100)]
Fix a bogus error message from the DWARF LEB129 decoder when trying to read a signed LEB128 value containing the largest possible signed negative integer value.

PR 26548
* dwarf.c (read_leb128): When checking for overflow of a signed
read, use a signed shift.

4 years agoPR26449, PR26450 UBSAN: frv-ibld.c:135 left shift
Alan Modra [Fri, 28 Aug 2020 14:13:16 +0000 (23:43 +0930)]
PR26449, PR26450 UBSAN: frv-ibld.c:135 left shift

Eh well, I guess the code didn't quite live up to the comment.

PR 26449
PR 26450
* cgen-ibld.in (insert_1): Use 1UL in forming mask.
(extract_normal): Likewise.
(insert_normal): Likewise, and move past zero length test.
(put_insn_int_value): Handle mask for zero length, use 1UL.
* bpf-ibld.c, * epiphany-ibld.c, * fr30-ibld.c, * frv-ibld.c,
* ip2k-ibld.c, * iq2000-ibld.c, * lm32-ibld.c, * m32c-ibld.c,
* m32r-ibld.c, * mep-ibld.c, * mt-ibld.c, * or1k-ibld.c,
* xc16x-ibld.c, * xstormy16-ibld.c: Regenerate.

4 years agoPR26460 UBSAN: tc-ia64.c:6107 index out of bounds
Alan Modra [Fri, 28 Aug 2020 13:39:29 +0000 (23:09 +0930)]
PR26460 UBSAN: tc-ia64.c:6107 index out of bounds

PR 26460
* config/tc-ia64.c (parse_operands): Don't access past end of
idesc->operands.

4 years agoPR26418 UBSAN: cache.c:386 null pointer fwrite
Alan Modra [Fri, 28 Aug 2020 13:36:47 +0000 (23:06 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite

And some more.

PR 26418
* ecofflink.c (bfd_ecoff_write_accumulated_debug): Don't write
zero size buffers.

4 years agogas: Handle bad -gdwarf options, just like bad --gdwarf options.
Mark Wielaard [Wed, 26 Aug 2020 19:46:04 +0000 (21:46 +0200)]
gas: Handle bad -gdwarf options, just like bad --gdwarf options.

parse_args uses getopt_long_only so it can handle long options both
with double and single dash. But this means that some single dash
options like -gdwarf-1 don't generate an error (unlike --gdwarf-1).

This is especially confusing since there is also --gdwarf2, but no
--gdwarf4 (it is --gdwarf-4). When giving -gdwarf4 the option is
silently interpreted as -g (which set dwarf_version to 2). This causes
some confusion for people who don't expect this and suddenly get
DWARF2 instead of DWARF4 as they might expect.

So make it so that the -gdwarf<unknown> creates an error, just like
--gdwarf<unknown> would.

4 years agoMSP430: Fix alignment of __*_array_start symbols in default linker script
Jozef Lawrynowicz [Fri, 28 Aug 2020 12:56:53 +0000 (13:56 +0100)]
MSP430: Fix alignment of __*_array_start symbols in default linker script

__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.

This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.

Some MSP430 linker scripts do not align the __*_array start symbols, so
this added warning will catch that problem and help the user avoid
the potential incorrect execution of the program.

ld/ChangeLog:

* emultempl/msp430.em (input_section_exists): New.
(check_array_section_alignment): New.
(gld${EMULATION_NAME}_finish): New.
* scripttempl/elf32msp430.sc: Add ALIGN directives before the
definition of __*_array_start symbols.
* testsuite/ld-msp430-elf/finiarray-warn.ld: New test.
* testsuite/ld-msp430-elf/finiarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray-nowarn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray.s: New test.
* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
* testsuite/ld-msp430-elf/preinitarray-warn.ld: New test.
* testsuite/ld-msp430-elf/preinitarray-warn.r: New test.

4 years agoLD: Add new %pU vfinfo format for printing linker script name
Jozef Lawrynowicz [Fri, 28 Aug 2020 12:56:53 +0000 (13:56 +0100)]
LD: Add new %pU vfinfo format for printing linker script name

The %pT vfinfo format prints the linker script name with a line number,
however sometimes it may be necessary to print the linker script name
without any associated line number.

ld/ChangeLog:

* ldmisc.c (vfinfo): Support new "%pU" format specifier.

4 years agoPR26418 UBSAN: cache.c:386 null pointer fwrite
Alan Modra [Fri, 28 Aug 2020 12:15:49 +0000 (21:45 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite

The previous "fix" tested the wrong value.

PR 26418
* ecofflink.c (WRITE): Really don't write zero size chunks.

4 years agoPrevent the linker from overestimating the alignment requirement of common symbols...
Tuckker [Fri, 28 Aug 2020 12:27:16 +0000 (13:27 +0100)]
Prevent the linker from overestimating the alignment requirement of common symbols on targets with octets that are larger than one byte.

PR 26543
* linker.c (bfd_generic_define_common_symbol): Force the alignment
to 1 if the section has now alignment requirement.

4 years ago[gdb/breakpoint] Handle setting breakpoint on label without address
Tom de Vries [Fri, 28 Aug 2020 10:02:20 +0000 (12:02 +0200)]
[gdb/breakpoint] Handle setting breakpoint on label without address

Consider test-case test.c:
...
$ cat test.c
int main (void) {
  return 0;
 L1:
  (void)0;
}
...

Compiled with debug info:
...
$ gcc test.c -g
...

When attempting to set a breakpoint at L1, which is a label without address:
...
 <1><f4>: Abbrev Number: 2 (DW_TAG_subprogram)
    <f5>   DW_AT_name        : main
 <2><115>: Abbrev Number: 3 (DW_TAG_label)
    <116>   DW_AT_name        : L1
    <119>   DW_AT_decl_file   : 1
    <11a>   DW_AT_decl_line   : 5
 <2><11b>: Abbrev Number: 0
...
we run into an internal-error:
...
$ gdb -batch a.out -ex "b main:L1"
linespec.c:3233: internal-error: void \
  decode_line_full(const event_location*, int, program_space*, symtab*, \
  int, linespec_result*, const char*, const char*): \
  Assertion `result.size () == 1 || canonical->pre_expanded' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

Fix this by detecting the error condition in decode_line_full instead, and
throwing an error, such that we have instead:
...
(gdb) b main:L1
Location main:L1 not available
(gdb)
...

Unfortunately, to call event_location_to_string, which is used to get the
location name in the error message, we need to pass a non-const struct
event_location, because the call may cache the string in the struct (See
EL_STRING).  So, we change the prototype of decode_line_full accordingly, and
everywhere this propages to.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-08-28  Tom de Vries  <tdevries@suse.de>

PR breakpoint/26544
* breakpoint.c (parse_breakpoint_sals): Remove const from struct
event_location.
(create_breakpoint): Same.
(base_breakpoint_decode_location): Same.
(bkpt_create_sals_from_location): Same.
(bkpt_decode_location): Same.
(bkpt_probe_create_sals_from_location): Same.
(bkpt_probe_decode_location): Same.
(tracepoint_create_sals_from_location): Same.
(tracepoint_decode_location): Same.
(tracepoint_probe_decode_location): Same.
(strace_marker_create_sals_from_location): Same.
(strace_marker_decode_location): Same.
(create_sals_from_location_default): Same.
(decode_location_default): Same.
* breakpoint.h (struct breakpoint_ops): Same.
(create_breakpoint): Same.
* linespec.h (decode_line_full): Same.
* linespec.c (decode_line_full): Same.  Throw error if
result.size () == 0.

gdb/testsuite/ChangeLog:

2020-08-28  Tom de Vries  <tdevries@suse.de>

* gdb.base/label-without-address.c: New test.
* gdb.base/label-without-address.exp: New file.

4 years agoCSKY: Support attribute section.
Cooper Qu [Wed, 26 Aug 2020 03:21:14 +0000 (11:21 +0800)]
CSKY: Support attribute section.

bfd
        * elf32-csky.c (csky_archs): Fix arch names.
        (csky_find_arch_with_name): New.
        (elf32_csky_merge_attributes): New.
        (csky_elf_merge_private_bfd_data): Add process of merge
        attribute section.
        (elf32_csky_obj_attrs_arg_type): New.
        (elf32_csky_obj_attrs_handle_unknown): New.
        (elf_backend_obj_attrs_vendor): Define.
        (elf_backend_obj_attrs_section): Define.
        (elf_backend_obj_attrs_arg_type): Define.
        (elf_backend_obj_attrs_section_type): Define.

binutils/
        * readelf.c (get_csky_section_type_name): New.
        (get_section_type_name): Add handler for CSKY.
        (display_csky_attribute): New.
        (process_arch_specific): Add handler for CSKY.
        * testsuite/binutils-all/strip-3.d: Remove .csky.attributes
        section.

elfcpp/
        * elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES.

gas/
        * gas/config/tc-csky.c (md_begin): Set attributes.
        (isa_flag): Change type to unsigned 64 bits.
        (struct csky_cpu_info): Likewise.
        (struct csky_macro_info): Likewise.
        (set_csky_attribute): New.
        * testsuite/gas/csky/802j.d: Ignore .csky.attributes section.
        * testsuite/gas/csky/all.d: Likewise.
        * testsuite/gas/csky/bsr1.d: Likewise.
        * testsuite/gas/csky/csky_vdsp.d: Likewise.
        * testsuite/gas/csky/cskyv2_all.d: Likewise.
        * testsuite/gas/csky/cskyv2_ck803r2.d: Likewise.
        * testsuite/gas/csky/cskyv2_ck860.d: Likewise.
        * testsuite/gas/csky/cskyv2_dsp.d: Likewise.
        * testsuite/gas/csky/cskyv2_elrw.d: Likewise.
        * testsuite/gas/csky/cskyv2_float.d: Likewise.
        * testsuite/gas/csky/enhance_dsp.d: Likewise.
        * testsuite/gas/csky/java.d: Likewise.
        * testsuite/gas/csky/v1_float.d: Likewise.
        * testsuite/gas/csky/v2_float_part1.d: Likewise.
        * testsuite/gas/csky/v2_float_part2.d: Likewise.
        * testsuite/gas/csky/v2_tls_gd.d: Likewise.
        * testsuite/gas/csky/v2_tls_ie.d: Likewise.
        * testsuite/gas/csky/v2_tls_ld.d: Likewise.
        * testsuite/gas/csky/v2_tls_le.d: Likewise.
        * testsuite/gas/elf/elf.exp: Add handler for CSKY.
        * testsuite/gas/elf/section2.e-csky: New.

include/
        * elf/csky.h (SHT_CSKY_ATTRIBUTES): Define.
        (Tag_CSKY_ARCH_NAME): New enum constant.
        (Tag_CSKY_CPU_NAME): Likewise.
        (Tag_CSKY_ISA_FLAGS): Likewise.
        (Tag_CSKY_DSP_VERSION): Likewise.
        (Tag_CSKY_VDSP_VERSION): Likewise.
        (Tag_CSKY_FPU_VERSION): Likewise.
        (Tag_CSKY_FPU_ABI): Likewise.
        (Tag_CSKY_FPU_ROUNDING): Likewise.
        (Tag_CSKY_FPU_DENORMAL): Likewise.
        (Tag_CSKY_FPU_Exception): Likewise.
        (Tag_CSKY_FPU_NUMBER_MODULE): Likewise.
        (Tag_CSKY_FPU_HARDFP): Likewise.
        (Tag_CSKY_MAX): Likewise.
        (VAL_CSKY_DSP_VERSION_EXTENSION): Likewise.
        (VAL_CSKY_DSP_VERSION_2): Likewise.
        (VAL_CSKY_VDSP_VERSION_1): Likewise.
        (VAL_CSKY_VDSP_VERSION_2): Likewise.
        (VAL_CSKY_FPU_ABI_SOFT): Likewise.
        (VAL_CSKY_FPU_ABI_SOFTFP): Likewise.
        (VAL_CSKY_FPU_ABI_HARD): Likewise.
        (VAL_CSKY_FPU_HARDFP_HALF): Likewise.
        (VAL_CSKY_FPU_HARDFP_SINGLE): Likewise.
        (VAL_CSKY_FPU_HARDFP_DOUBLE): Likewise.
        * opcode/csky.h (CSKY_ISA_VDSP_V2): Define.
        CSKYV1_ISA_E1: Change to long constant type.
        CSKYV2_ISA_E1: Likewise.
        CSKYV2_ISA_1E2: Likewise.
        CSKYV2_ISA_2E3: Likewise.
        CSKYV2_ISA_3E7: Likewise.
        CSKYV2_ISA_7E10: Likewise.
        CSKYV2_ISA_3E3R1: Likewise.
        CSKYV2_ISA_3E3R2: Likewise.
        CSKYV2_ISA_10E60: Likewise.
        CSKY_ISA_TRUST: Likewise.
        CSKY_ISA_CACHE: Likewise.
        CSKY_ISA_NVIC: Likewise.
        CSKY_ISA_CP: Likewise.
        CSKY_ISA_MP: Likewise.
        CSKY_ISA_MP_1E2: Likewise.
        CSKY_ISA_JAVA: Likewise.
        CSKY_ISA_MAC: Likewise.
        CSKY_ISA_MAC_DSP: Likewise.
        CSKY_ISA_DSP: Likewise.
        CSKY_ISA_DSP_1E2: Likewise.
        CSKY_ISA_DSP_ENHANCE: Likewise.
        CSKY_ISA_FLOAT_E1: Likewise.
        CSKY_ISA_FLOAT_1E2: Likewise.
        CSKY_ISA_FLOAT_1E3: Likewise.
        CSKY_ISA_FLOAT_3E4: Likewise.
        CSKY_ISA_VDSP: Likewise.

ld/
        * emulparams/cskyelf.sh: Support attribute section.
        * testsuite/ld-csky/tls-le-v1.d: Match .csky.attributes section.
        * ld/testsuite/ld-csky/tls-le.d: Likewise.
        * testsuite/ld-elf/non-contiguous.ld: Ignore .csky.attributes
        section.

opcodes/
        * csky-dis.c (CSKY_DEFAULT_ISA): Define.
        (csky_dis_info): Add member isa.
        (csky_find_inst_info): Skip instructions that do not belong to
        current CPU.
        (csky_get_disassembler): Get infomation from attribute section.
        (print_insn_csky): Set defualt ISA flag.
        * csky.h (CSKY_ISA_VDSP_2): Rename from CSKY_ISA_VDSP_V2.
        * csky-opc.h (struct csky_opcode): Change isa_flag16 and
        isa_flag32'type to unsigned 64 bits.

4 years agoFixes for testsuite failures introduced by the changes made for PR 19011.
Nick Clifton [Fri, 28 Aug 2020 08:43:13 +0000 (09:43 +0100)]
Fixes for testsuite failures introduced by the changes made for PR 19011.

PR19011
bfd * cofflink.c (_bfd_coff_generic_relocate_section): Provide a value
for undefined symbols which will not generate extra warning
messages about truncated relocs.

ld * testsuite/lib/ld-lib.exp (ld_link_defsyms): For PE based targets
define the __main and ___main symbols in terms of the main symbol.

4 years agomingw plugin test regressions due to commit 514b4e191d5f
Alan Modra [Fri, 28 Aug 2020 01:21:28 +0000 (10:51 +0930)]
mingw plugin test regressions due to commit 514b4e191d5f

Fixes new failures due to image base change.

PR 19011
* testsuite/ld-plugin/plugin.exp: Use modified CFLAGS throughout
file.  Add --image-base for pecoff.

4 years agoRISC-V: Treat R_RISCV_CALL and R_RISCV_CALL_PLT as the same in check_relocs.
Nelson Chu [Wed, 26 Aug 2020 08:19:13 +0000 (01:19 -0700)]
RISC-V: Treat R_RISCV_CALL and R_RISCV_CALL_PLT as the same in check_relocs.

In fact, we can treate these two relocation as the same one in the
riscv_elf_check_relocs.  I have heard that RISC-V lld had made this
improvement, and so had GNU AARCH64, they only need R_AARCH64_CALL26
for calls rather than two seperate relocations.

Beside, the following PLT issue for RISC-V 32-bit glibc seems to be
fixed by applying at least this patch.

<https://sourceware.org/pipermail/libc-alpha/2020-August/117214.html>

I have ran the toolchain regression, and everything seems fine for now.

bfd/
* elfnn-riscv.c (riscv_elf_check_relocs): Treat R_RISCV_CALL
and R_RISCV_CALL_PLT as the same in the riscv_elf_check_relocs.
(riscv_elf_relocate_section): Remove the R_RISCV_CALL for the
unresolved reloc checks.

ld/
testsuite/ld-riscv-elf/lib-nopic-01a.s: Use R_RISCV_JAL rather
than R_RISCV_CALL.
testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Aug 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix advance/until and multiple locations (PR gdb/26524)
Pedro Alves [Thu, 27 Aug 2020 20:03:53 +0000 (21:03 +0100)]
Fix advance/until and multiple locations (PR gdb/26524)

If you do "advance LINESPEC", and LINESPEC expands to more than one
location, GDB just errors out:

   if (sals.size () != 1)
     error (_("Couldn't get information on specified line."));

For example, advancing to a line in an inlined function, inlined three
times:

 (gdb) b 21
 Breakpoint 1 at 0x55555555516f: advance.cc:21. (3 locations)
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000055555555516f in inline_func at advance.cc:21
 1.2                         y   0x000055555555517e in inline_func at advance.cc:21
 1.3                         y   0x000055555555518d in inline_func at advance.cc:21
 (gdb) advance 21
 Couldn't get information on specified line.
 (gdb)

Similar issue with the "until" command, as it shares the
implementation with "advance".

Since, as the comment in gdb.base/advance.exp says, "advance <location>"
is really just syntactic sugar for "tbreak <location>;continue",
fix this by making GDB insert a breakpoint at all the resolved
locations.

A new testcase is included, which exercises both "advance" and
"until", in two different cases expanding to multiple locations:

  - inlined functions
  - C++ overloads

This also exercises the inline frames issue fixed by the previous
patch.

gdb/ChangeLog:

PR gdb/26524
* breakpoint.c (until_break_fsm) <location_breakpoint,
caller_breakpoint>: Delete fields.
<breakpoints>: New field.
<until_break_fsm>: Adjust to save a breakpoint vector instead of
two individual breakpoints.
(until_break_fsm::should_stop): Loop over breakpoints in the
breakpoint vector.
(until_break_fsm::clean_up): Adjust to clear the breakpoints
vector.
(until_break_command): Handle location expanding into multiple
sals.

gdb/testsuite/ChangeLog:

PR gdb/26523
PR gdb/26524
* gdb.base/advance-until-multiple-locations.cc: New.
* gdb.base/advance-until-multiple-locations.exp: New.

4 years agoFix advance/until and inline frames (PR gdb/26523)
Pedro Alves [Thu, 27 Aug 2020 20:03:53 +0000 (21:03 +0100)]
Fix advance/until and inline frames (PR gdb/26523)

If you do "tbreak LINENO; c" to advance to an inlined function, GDB
presents the stop at the inline frame instead of at the non-artificial
stack frame:

 (gdb) list 21
 18      static inline __attribute__ ((always_inline)) int
 19      inline_func (int i)
 20      {
 21        return i + 1;
 22      }

 (gdb) tbreak 21
 Temporary breakpoint 3 at 0x55555555516f: advance.cc:21.
 (gdb) c
 Continuing.

 Temporary breakpoint 3, inline_func (i=0) at advance.cc:21
 21        return i + 1;

The logic for this is in stopped_by_user_bp_inline_frame:

 /* Loop over the stop chain and determine if execution stopped in an
    inlined frame because of a breakpoint with a user-specified
    location set at FRAME_BLOCK.  */

 static bool
 stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)

If however, you do "advance LINENO" or "until LINENO" instead, GDB
presents the stop at the non-artificial frame:

 (gdb) advance 21
 main () at advance.cc:43
 43        i = inline_func (i);
 (gdb)

"advance" and "until" should really behave like user breakpoints here,
since their location is also user-specified.  As the comment in
gdb.base/advance.exp says, "advance <location>" is really just
syntactic sugar for "tbreak <location>; continue".

Fix this by making stopped_by_user_bp_inline_frame also consider
advance/until breakpoints.

A testcase covering this will be included in the next patch.

gdb/ChangeLog:

PR gdb/26523
* inline-frame.c (stopped_by_user_bp_inline_frame): Also consider
bp_until breakpoints user-specified locations.  Update intro
comment.

4 years agoreadelf: MSP430: Fix incorrect usage of "msp430x" in function names
Jozef Lawrynowicz [Thu, 27 Aug 2020 19:48:35 +0000 (20:48 +0100)]
readelf: MSP430: Fix incorrect usage of "msp430x" in function names

The "X" in "MSP430X" indicates an extension to the original MSP430 ISA, but
these functions are generically used for all MSP430 ISAs, so the names should
not use the "X" suffix.

binutils/ChangeLog:

* readelf.c (get_msp430x_section_type_name): Rename to ...
(get_msp430_section_type_name): ... this.
(get_section_type_name): Use get_msp430_section_type_name.
(display_msp430x_attribute): Rename to ...
(display_msp430_attribute): ... this.
(process_arch_specific): Use display_msp430_attribute.

4 years agold/emultempl/msp430.em: Remove unused variable
Jozef Lawrynowicz [Thu, 27 Aug 2020 17:17:43 +0000 (18:17 +0100)]
ld/emultempl/msp430.em: Remove unused variable

ld/ChangeLog:

* emultempl/msp430.em: Remove unused variable "buf".

4 years agogdb/testsuite: use multi_line in gdb.dwarf2/dw2-reg-undefined.exp
Simon Marchi [Thu, 27 Aug 2020 18:42:12 +0000 (14:42 -0400)]
gdb/testsuite: use multi_line in gdb.dwarf2/dw2-reg-undefined.exp

Use multi_line to make the expected pattern more readable.

gdb/testsuite/ChangeLog:

*  gdb.dwarf2/dw2-reg-undefined.exp: Use multi_line.

Change-Id: Ia8e42d156c0c30265121eb890e1db17a692dbaf0

4 years agogdb: fix whitespace issues in ChangeLog files
Simon Marchi [Thu, 27 Aug 2020 16:54:00 +0000 (12:54 -0400)]
gdb: fix whitespace issues in ChangeLog files

Change-Id: I423867477d4342673e629dac71a80592fd879ea1

4 years agogdb/testsuite: make test names unique in gdb.arch/*.exp
Andrew Burgess [Wed, 26 Aug 2020 13:05:45 +0000 (14:05 +0100)]
gdb/testsuite: make test names unique in gdb.arch/*.exp

Make the test names unique in gdb.arch/*.exp by either modifying the
test names or using with_test_prefix.

I have also fixed a typo 'forth' -> 'fourth' throughout gdb.arch/*.

Finally, I replaced code like this:

  gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
           "Breakpoint .* at .*${srcfile}.*" \
           "set first breakpoint in main"

With this:

  gdb_breakpoint [gdb_get_line_number "first breakpoint here"]

In those files that I was already modifying for the other reasons
given above.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-byte.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-dword.exp: Likewise.
* gdb.arch/amd64-pseudo.c: Fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-stap-special-operands.exp: Make test names
unique.
* gdb.arch/amd64-tailcall-ret.exp: Likewise.
* gdb.arch/amd64-word.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/i386-byte.exp: Make test names unique, use
gdb_breakpoint.
* gdb.arch/i386-word.exp: Likewise.

4 years agoFix PR binutils/26356 on hppa*-*-hpux*.
John David Anglin [Thu, 27 Aug 2020 15:25:03 +0000 (15:25 +0000)]
Fix PR binutils/26356 on hppa*-*-hpux*.

PR 26356
* som.c (som_bfd_copy_private_section_data): Issue error when a
subspace is specified without its containing space.
* testsuite/binutils-all/objcopy.exp (objcopy --reverse-bytes): Add
"-j $PRIVATE$" to command on hppa*-*-hpux*.
* testsuite/lib/utils-lib.exp (default_binutils_run): Remove existing
dollar-sign quotes before quoting.  Do this prior to generating log
output.

4 years agoCorrects the broken line number incrementation in the Windows resource parser
Ralf Habacker [Thu, 27 Aug 2020 14:59:53 +0000 (15:59 +0100)]
Corrects the broken line number incrementation in the Windows resource parser

When the tokens MCLINE, MCENDLINE, and MCCOMMENT were created, the
line number was not increased, which led to an incorrect value in
the error output.

PR 26088
* mclex.c (skip_until_eol): if eol was found, increment line number

4 years agogdb: add gdb_bfd_sections for range-based iteration
Simon Marchi [Thu, 27 Aug 2020 12:58:43 +0000 (08:58 -0400)]
gdb: add gdb_bfd_sections for range-based iteration

I wanted to make a nicer / type-safe interface for
bfd_map_over_sections, avoiding the `void *` data parameter.

My first shot was to make a wrapper for bfd_map_over_sections,
gdb_bfd_map_over_sections that took a gdb::function_view.

However, I think that a range adapter gives nicer and simpler code, as a
simple for loop is easier to read than a callback / lambda function.  So
here it is, it uses next_iterator and next_adapter, so it's not much
code.

As an example, I ported maintenance_info_sections and friends to use it.
The maint_print_section_data type could probably be removed now, but I
didn't want to do too much in one patch.

gdb/ChangeLog:

* gdb_bfd.h (gdb_bfd_section_iterator, gdb_bfd_section_range,
gdb_bfd_sections): New.
* maint.c (print_bfd_section_info): Change param type to
maint_print_section_data.
(print_objfile_section_info): Likewise.
(print_bfd_section_info_maybe_relocated): Likewise.
(maintenance_info_sections): Use gdb_bfd_sections.

Change-Id: Ib496f6b0a0eb7aadb10da1dd381304014d934ea0

4 years agoRemove commit 9fb2400ce6
Nick Clifton [Thu, 27 Aug 2020 12:52:45 +0000 (13:52 +0100)]
Remove commit  9fb2400ce6

4 years agoFix linker testcase for alpha-linux affected by fix for PR 26416
Nick Clifton [Thu, 27 Aug 2020 12:47:02 +0000 (13:47 +0100)]
Fix linker testcase for alpha-linux affected by fix for PR 26416

PR 26416
* testsuite/ld-alpha/tlsbinr.rd: Update expected output.
* testsuite/ld-alpha/tlsbinr.dd: Likewise.
* testsuite/ld-alpha/tlsbinr.sd: Likewise.

4 years agoPR26469 UBSAN: elflink.c:8742 shift exponent 6148914691236511722
Alan Modra [Thu, 27 Aug 2020 12:14:41 +0000 (21:44 +0930)]
PR26469 UBSAN: elflink.c:8742 shift exponent 6148914691236511722

PR 26469
* elflink.c: Include limits.h.
(CHAR_BIT): Provide fallback define.
(set_symbol_value): Correct complex reloc comment.
(undefined_reference): Set bfd_error.
(BINARY_OP_HEAD, BINARY_OP_TAIL): Split out from..
(BINARY_OP): ..this.
(eval_symbol): Limit shifts.  Force unsigned for left shift.
Catch divide by zero.
* configure.ac (AC_CHECK_HEADERS): Combine, sort and add limits.h.
* configure: Regenerate.
* config.in: Regenerate.

4 years agoPR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615
Alan Modra [Thu, 27 Aug 2020 04:16:45 +0000 (13:46 +0930)]
PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615

PR 26467
* cgen.c (weak_operand_overflow_check): Handle opmask for
operand length zero.  Use 1UL constant.

4 years agoPR26462 UBSAN: reloc.c:473 shift exponent 4294967295
Alan Modra [Thu, 27 Aug 2020 03:55:31 +0000 (13:25 +0930)]
PR26462 UBSAN: reloc.c:473 shift exponent 4294967295

PR 26462
* reloc.c (bfd_check_overflow): Return early if zero bitsize.

4 years agoarm-symbianelf segfault
Alan Modra [Thu, 27 Aug 2020 03:20:20 +0000 (12:50 +0930)]
arm-symbianelf segfault

Yes, the target is marked obsolete due to this and other segfaults,
but this one is easy enough to fix.

* elf32-arm.c (elf32_arm_final_link_relocate): Don't segfault
on sym_sec not being output.

4 years agoRe: commit eae0b5c3b2d6b
Alan Modra [Thu, 27 Aug 2020 12:24:16 +0000 (21:54 +0930)]
Re: commit eae0b5c3b2d6b

PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Correct "dynamic".

4 years agobinutils, ld: dequote libctf error messages
Nick Alcock [Wed, 29 Jul 2020 12:50:10 +0000 (13:50 +0100)]
binutils, ld: dequote libctf error messages

These are not identifiers and should not be quoted.  (Also, quoting them
just looks odd.)

Adjust diagnostics tests accordingly.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (dump_ctf_errs): Unquote CTF error messages.
* readelf.c (dump_ctf_errs): Likewise.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ldlang.c (dump_ctf_errs): Unquote CTF error messages.
(ldlang_open_ctf): Likewise.
(lang_merge_ctf): Likewise.
(lang_write_ctf): Likewise.
* testsuite/ld-ctf/diag-ctf-version-f.d: Adjust.
* testsuite/ld-ctf/diag-cttname-invalid.d: Adjust.
* testsuite/ld-ctf/diag-decompression-failure.d: Adjust.
* testsuite/ld-ctf/diag-parname.d: Adjust.
* testsuite/ld-ctf/diag-unsupported-flag.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number.d: Adjust.

4 years agolibctf, binutils, include, ld: gettextize and improve error handling
Nick Alcock [Mon, 27 Jul 2020 15:45:15 +0000 (16:45 +0100)]
libctf, binutils, include, ld: gettextize and improve error handling

This commit follows on from the earlier commit "libctf, ld, binutils:
add textual error/warning reporting for libctf" and converts every error
in libctf that was reported using ctf_dprintf to use ctf_err_warn
instead, gettextizing them in the process, using N_() where necessary to
avoid doing gettext calls unless an error message is actually generated,
and rephrasing some error messages for ease of translation.

This requires a slight change in the ctf_errwarning_next API: this API
is public but has not been in a release yet, so can still change freely.
The problem is that many errors are emitted at open time (whether
opening of a CTF dict, or opening of a CTF archive): the former of these
throws away its incompletely-initialized ctf_file_t rather than return
it, and the latter has no ctf_file_t at all. So errors and warnings
emitted at open time cannot be stored in the ctf_file_t, and have to go
elsewhere.

We put them in a static local in ctf-subr.c (which is not very
thread-safe: a later commit will improve things here): ctf_err_warn with
a NULL fp adds to this list, and the public interface
ctf_errwarning_next with a NULL fp retrieves from it.

We need a slight exception from the usual iterator rules in this case:
with a NULL fp, there is nowhere to store the ECTF_NEXT_END "error"
which signifies the end of iteration, so we add a new err parameter to
ctf_errwarning_next which is used to report such iteration-related
errors.  (If an fp is provided -- i.e., if not reporting open errors --
this is optional, but even if it's optional it's still an API change.
This is actually useful from a usability POV as well, since
ctf_errwarning_next is usually called when there's been an error, so
overwriting the error code with ECTF_NEXT_END is not very helpful!
So, unusually, ctf_errwarning_next now uses the passed fp for its
error code *only* if no errp pointer is passed in, and leaves it
untouched otherwise.)

ld, objdump and readelf are adapted to call ctf_errwarning_next with a
NULL fp to report open errors where appropriate.

The ctf_err_warn API also has to change, gaining a new error-number
parameter which is used to add the error message corresponding to that
error number into the debug stream when LIBCTF_DEBUG is enabled:
changing this API is easy at this point since we are already touching
all existing calls to gettextize them.  We need this because the debug
stream should contain the errno's message, but the error reported in the
error/warning stream should *not*, because the caller will probably
report it themselves at failure time regardless, and reporting it in
every error message that leads up to it leads to a ridiculous chattering
on failure, which is likely to end up as ridiculous chattering on stderr
(trimmed a bit):

CTF error: `ld/testsuite/ld-ctf/A.c (0): lookup failure for type 3: flags 1: The parent CTF dictionary is unavailable'
CTF error: `ld/testsuite/ld-ctf/A.c (0): struct/union member type hashing error during type hashing for type 80000001, kind 6: The parent CTF dictionary is unavailable'
CTF error: `deduplicating link variable emission failed for ld/testsuite/ld-ctf/A.c: The parent CTF dictionary is unavailable'
ld/.libs/lt-ld-new: warning: CTF linking failed; output will have no CTF section: `The parent CTF dictionary is unavailable'

We only need to be told that the parent CTF dictionary is unavailable
*once*, not over and over again!

errmsgs are still emitted on warning generation, because warnings do not
usually lead to a failure propagated up to the caller and reported
there.

Debug-stream messages are not translated.  If translation is turned on,
there will be a mixture of English and translated messages in the debug
stream, but rather that than burden the translators with debug-only
output.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (dump_ctf_archive_member): Move error-
reporting...
(dump_ctf_errs): ... into this separate function.
(dump_ctf): Call it on open errors.
* readelf.c (dump_ctf_archive_member): Move error-
reporting...
(dump_ctf_errs): ... into this separate function.  Support
calls with NULL fp. Adjust for new err parameter to
ctf_errwarning_next.
(dump_section_as_ctf): Call it on open errors.

include/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ctf-api.h (ctf_errwarning_next): New err parameter.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ldlang.c (lang_ctf_errs_warnings): Support calls with NULL fp.
Adjust for new err parameter to ctf_errwarning_next.  Only
check for assertion failures when fp is non-NULL.
(ldlang_open_ctf): Call it on open errors.
* testsuite/ld-ctf/ctf.exp: Always use the C locale to avoid
breaking the diags tests.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ctf-subr.c (open_errors): New list.
(ctf_err_warn): Calls with NULL fp append to open_errors.  Add err
parameter, and use it to decorate the debug stream with errmsgs.
(ctf_err_warn_to_open): Splice errors from a CTF dict into the
open_errors.
(ctf_errwarning_next): Calls with NULL fp report from open_errors.
New err param to report iteration errors (including end-of-iteration)
when fp is NULL.
(ctf_assert_fail_internal): Adjust ctf_err_warn call for new err
parameter: gettextize.
* ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter.
(LCTF_VBYTES): Adjust.
(ctf_err_warn_to_open): New.
(ctf_err_warn): Adjust.
(ctf_bundle): Used in only one place: move...
* ctf-create.c: ... here.
(enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number
down as needed.  Don't emit the errmsg.  Gettextize.
(membcmp): Likewise.
(ctf_add_type_internal): Likewise.
(ctf_write_mem): Likewise.
(ctf_compress_write): Likewise.  Report errors writing the header or
body.
(ctf_write): Likewise.
* ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not
ctf_dprintf, and gettextize, as above.
(ctf_arc_write): Likewise.
(ctf_arc_bufopen): Likewise.
(ctf_arc_open_internal): Likewise.
* ctf-labels.c (ctf_label_iter): Likewise.
* ctf-open-bfd.c (ctf_bfdclose): Likewise.
(ctf_bfdopen): Likewise.
(ctf_bfdopen_ctfsect): Likewise.
(ctf_fdopen): Likewise.
* ctf-string.c (ctf_str_write_strtab): Likewise.
* ctf-types.c (ctf_type_resolve): Likewise.
* ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict.
(get_vbytes_v1): Pass down the ctf dict.
(get_vbytes_v2): Likewise.
(flip_ctf): Likewise.
(flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and
gettextize, as above.
(upgrade_types_v1): Adjust calls.
(init_types): Use ctf_err_warn, not ctf_dprintf, as above.
(ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors
emitted into individual dicts into the open errors if this turns
out to be a failed open in the end.
* ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err
argument.  Gettextize.  Don't emit the errmsg.
(ctf_dump_funcs): Likewise.  Collapse err label into its only case.
(ctf_dump_type): Likewise.
* ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err
argument.  Gettextize.  Don't emit the errmsg.
(ctf_link_one_type): Likewise.
(ctf_link_lazy_open): Likewise.
(ctf_link_one_input_archive): Likewise.
(ctf_link_deduplicating_count_inputs): Likewise.
(ctf_link_deduplicating_open_inputs): Likewise.
(ctf_link_deduplicating_close_inputs): Likewise.
(ctf_link_deduplicating): Likewise.
(ctf_link): Likewise.
(ctf_link_deduplicating_per_cu): Likewise. Add some missed
ctf_set_errnos to obscure error cases.
* ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new
err argument.  Gettextize.  Don't emit the errmsg.
(ctf_dedup_populate_mappings): Likewise.
(ctf_dedup_detect_name_ambiguity): Likewise.
(ctf_dedup_init): Likewise.
(ctf_dedup_multiple_input_dicts): Likewise.
(ctf_dedup_conflictify_unshared): Likewise.
(ctf_dedup): Likewise.
(ctf_dedup_rwalk_one_output_mapping): Likewise.
(ctf_dedup_id_to_target): Likewise.
(ctf_dedup_emit_type): Likewise.
(ctf_dedup_emit_struct_members): Likewise.
(ctf_dedup_populate_type_mapping): Likewise.
(ctf_dedup_populate_type_mappings): Likewise.
(ctf_dedup_emit): Likewise.
(ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error
status setting.
(ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide
unknown-type-kind messages (which signify file corruption).

4 years agolibctf, binutils: initial work towards libctf gettextization
Nick Alcock [Thu, 30 Jul 2020 16:43:12 +0000 (17:43 +0100)]
libctf, binutils: initial work towards libctf gettextization

We gettextize under our package name, which we change to a more
reasonable 'libctf'.  Our internationalization support is mostly
provided by ctf-intl.h, which is a copy of opcodes/opintl.h with
the non-gettext_noop N_() expansion debracketed to avoid pedantic
compiler warnings.

The libctf error strings returned by ctf_errmsg are marked up for
internationalization.

(We also adjust binutils's Makefile a tiny bit to allow for the
fact that libctf now uses functions from libintl.)

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* Makefile.am (readelf_LDADD): Move $(LIBINTL) after $(LIBCTF_NOBFD).
* Makefile.in: Regenerated.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* configure.ac: Adjust package name to simply 'libctf': arbitrarily
declare this to be version 1.2.0.
* Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
* Makefile.in: Regenerated.
* configure: Regenerated.
* ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
* ctf-impl.h: Include it.
* ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
(ctf_errmsg): Actually translate them.

4 years agoChange the default characteristics of DLLs built by the linker to more secure settings.
Jeremy Drake [Thu, 27 Aug 2020 11:58:27 +0000 (12:58 +0100)]
Change the default characteristics of DLLs built by the linker to more secure settings.

PR 19011
* emultempl/pe.em (DEFAULT_DLL_CHARACTERISTICS): Define.
(pe_dll_characteristics): Initialise to DEFAULT_DLL_CHARACTERISTICS.
(add_options): Add options to disable DLL characteristics.
(list_options): List the new options.
(handle_options): Handle the new options.
* emultempl/pep.em: Similar changes to above.
(NT_EXE_IMAGE_BASE): Default to an address above 4G.
(NT_DLL_IMAGE_BASE, NT_DLL_AUTO_IMAGE_BASE,
(NT_DLL_AUTO_IMAGE_MASK): Likewise.
* ld.texi: Document the new options.
* pe-dll.c (pe_dll_enable_reloc_section): Change to default to
true.
(generate_reloc): Do nothing if there is no reloc section.
(pe_exe_fill_sections): Only assign the reloc section contents if
the section exists.
* testsuite/ld-pe/pe.exp: Add the --disable-reloc-section flag to
the .secrel32 tests.
* testsuite/ld-scripts/provide-8.d: Expect for fail on PE targets.
* NEWS: Mention the change in DLL generation.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Aug 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoUpdate gnulib to current trunk
Christian Biesinger [Wed, 26 Aug 2020 22:37:28 +0000 (15:37 -0700)]
Update gnulib to current trunk

This fixes two issues on Windows: Update.
https://sourceware.org/pipermail/gdb-patches/2020-June/169978.html

gnulib/ChangeLog:

2020-08-26  Christian Biesinger  <cbiesinger@google.com>
    Pedro Alves  <palves@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/alloca.in.h (if): Update.
* import/assure.h (affirm): Update.
* import/at-func.c: Update.
* import/attribute.h: New file.
* import/btowc.c: New file.
* import/canonicalize-lgpl.c: Update.
* import/count-one-bits.h (COUNT_ONE_BITS_GENERIC): Update.
(COUNT_ONE_BITS): Update.
(intrinsic): Update.
(__popcnt64): Update.
(popcount_supported): Update.
* import/ctype.in.h: New file.
* import/dirent-private.h (WIN32_FIND_DATA): Update.
* import/dirent.in.h (_GL_ATTRIBUTE_PURE): Update.
* import/dirname.h: Update.
* import/dosname.h: Remove.
* import/error.h (_GL_ATTRIBUTE_FORMAT): Update.
* import/extra/update-copyright: Update.
* import/fchdir.c: Update.
* import/fcntl.in.h (GNULIB_defined_rpl_fcntl): Update.
(GNULIB_defined_fcntl): Update.
* import/filename.h (HAS_DEVICE): Update.
(IS_ABSOLUTE_PATH): Update.
(IS_PATH_WITH_DIR): Update.
(FILE_SYSTEM_PREFIX_LEN): Update.
(_IS_DRIVE_LETTER): Update.
(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE): Update.
(IS_ABSOLUTE_FILE_NAME): Update.
(IS_RELATIVE_FILE_NAME): Update.
(IS_FILE_NAME_WITH_DIR): Update.
* import/filenamecat-lgpl.c (mfile_name_concat): Update.
* import/fnmatch.c (WIDE_CHAR_SUPPORT): Update.
(btowc): Update.
(iswctype): Update.
(mempcpy): Update.
(strnlen): Update.
(towlower): Update.
(wcscat): Update.
(wcslen): Update.
(wctype): Update.
(wmemchr): Update.
(wmempcpy): Update.
(SIZE_MAX): Update.
(isblank): Update.
(__libc_use_alloca): Update.
(alloca): Update.
(alloca_account): Update.
(STREQ): Update.
(CHAR_CLASS_MAX_LENGTH): Update.
(IS_CHAR_CLASS): Update.
(ISWCTYPE): Update.
(if): Update.
(HANDLE_MULTIBYTE): Update.
(internal_function): Update.
(FOLD): Update.
(CHAR): Update.
(UCHAR): Update.
(INT): Update.
(FCT): Update.
(EXT): Update.
(END): Update.
(L_): Update.
(BTOWC): Update.
(STRLEN): Update.
(STRCAT): Update.
(MEMPCPY): Update.
(MEMCHR): Update.
(WIDE_CHAR_VERSION): Update.
(STRUCT): Update.
(FINDIDX): Update.
(findidx): Update.
(ALLOCA_LIMIT): Update.
(SHLIB_COMPAT): Update.
* import/fnmatch_loop.c (struct STRUCT): Update.
(FCT): Update.
(EXT): Update.
(END): Update.
(str): Update.
(NEW_PATTERN): Update.
* import/getcwd.c: Update.
* import/getlogin_r.c (GetUserName): Update.
* import/getprogname.c (getprogname): Update.
* import/getrandom.c: New file.
* import/gettimeofday.c: Remove.
* import/glob.in.h (_Restrict_): Update.
* import/inttypes.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/isblank.c: New file.
* import/isnanl-nolibm.h (__has_builtin): Update.
* import/libc-config.h (versioned_symbol): Update.
(compat_symbol): Update.
* import/limits.in.h (_GL_ALREADY_INCLUDING_LIMITS_H): Update.
* import/m4/btowc.m4: New file.
* import/m4/ctype.m4: New file.
* import/m4/exponentl.m4: Update.
* import/m4/fnmatch.m4: Update.
* import/m4/getrandom.m4: New file.
* import/m4/glob.m4: Update.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-common.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/inttypes.m4: Update.
* import/m4/isblank.m4: New file.
* import/m4/isnanl.m4: Update.
* import/m4/largefile.m4: Update.
* import/m4/mbtowc.m4: New file.
* import/m4/memmem.m4: Update.
* import/m4/minmax.m4: New file.
* import/m4/signal_h.m4: Update.
* import/m4/stdio_h.m4: Update.
* import/m4/stdlib_h.m4: Update.
* import/m4/string_h.m4: Update.
* import/m4/strnlen.m4: New file.
* import/m4/sys_random_h.m4: New file.
* import/m4/sys_socket_h.m4: Update.
* import/m4/sys_stat_h.m4: Update.
* import/m4/time_h.m4: Update.
* import/m4/unistd_h.m4: Update.
* import/m4/wchar_h.m4: Update.
* import/m4/wint_t.m4: Update.
* import/m4/wmemchr.m4: New file.
* import/m4/wmempcpy.m4: New file.
* import/math.in.h (__has_builtin): Update.
* import/mbrtowc.c (FALLTHROUGH): Update.
* import/mbtowc-impl.h: New file.
* import/mbtowc.c: New file.
* import/minmax.h: New file.
* import/open.c (open): Update.
* import/openat-proc.c (openat_proc_name): Update.
* import/openat.c (rpl_openat): Update.
(openat_needs_fchdir): Update.
* import/openat.h (FCHOWNAT_INLINE): Update.
(CHOWNAT_INLINE): Update.
(FCHMODAT_INLINE): Update.
(CHMODAT_INLINE): Update.
* import/opendir.c (WIN32_FIND_DATA): Update.
(GetFullPathName): Update.
(FindFirstFile): Update.
* import/readdir.c (FindNextFile): Update.
* import/rename.c (MoveFileEx): Update.
* import/rewinddir.c (FindFirstFile): Update.
* import/rmdir.c: Update.
* import/signal.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/stat-w32.c (_WIN32_WINNT): Update.
(LoadLibrary): Update.
(GetFinalPathNameByHandle): Update.
(GetProcAddress): Update.
(DWORD): Update.
(GetFileInformationByHandleExFunc): Update.
(GetFinalPathNameByHandleFunc): Update.
* import/stat.c (WIN32_FIND_DATA): Update.
(CreateFile): Update.
(FindFirstFile): Update.
* import/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_FUNCDECL_RPL_1): Update.
(_GL_CXXALIAS_RPL_1): Update.
(_GL_CXXALIAS_SYS_CAST): Update.
* import/stdlib.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/string.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_WARN_ON_USE): Update.
(_GL_WARN_ON_USE_CXX): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS): Update.
(mbstok_r): Update.
* import/strnlen.c: New file.
* import/sys_random.in.h: New file.
* import/sys_socket.in.h (GNULIB_defined_socklen_t): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS_CAST): Update.
* import/sys_stat.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(lchmod): Update.
(_GL_CXXALIAS_RPL_1): Update.
(stat): Update.
* import/tempname.c (__set_errno): Update.
(__secure_getenv): Update.
(__try_tempname): Update.
(__getpid): Update.
(__gettimeofday): Update.
(RANDOM_BITS): Update.
(uint64_t): Update.
(RANDOM_VALUE_MAX): Update.
(BASE_62_DIGITS): Update.
(BASE_62_POWER): Update.
(try_tempname_len): Update.
(try_file): Update.
(try_dir): Update.
(try_nocreate): Update.
(gen_tempname_len): Update.
(__gen_tempname): Update.
(try_tempname): Update.
* import/tempname.h (gen_tempname_len): Update.
(try_tempname_len): Update.
* import/time.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS): Update.
* import/unistd.in.h (if): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_CXXALIASWARN): Update.
(_GL_WARN_ON_USE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
* import/verify.h: Update.
* import/warn-on-use.h (_GL_WARN_ON_USE_CXX): Update.
* import/wchar.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_CXXALIASWARN): Update.
(_GL_WARN_ON_USE): Update.
(_GL_CXXALIAS_SYS_CAST2): Update.
(_GL_CXXALIASWARN1): Update.
* import/windows-rwlock.c (CreateEvent): Update.
* import/wmemchr-impl.h: New file.
* import/wmemchr.c: New file.
* import/wmempcpy.c: New file.
* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add gettimeofday.
(GNULIB_COMMIT_SHA1): Update gnulib revision.

4 years agold: Add $NOSANTIZE_CFLAGS to more linker tests
H.J. Lu [Wed, 26 Aug 2020 18:28:26 +0000 (11:28 -0700)]
ld: Add $NOSANTIZE_CFLAGS to more linker tests

-fsanitize= can be used to build binutils with

$ CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined" .../configure --disable-werror

Since not all linker tests are compatible with -fsanitize=, pass
$NOSANTIZE_CFLAGS to disable -fsanitize= for such tests.

* testsuite/ld-elf/indirect.exp: Append $NOSANTIZE_CFLAGS to CC.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
* testsuite/ld-elfvers/vers.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-elfweak/elfweak.exp: Likewise.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-scripts/crossref.exp: Likewise.

4 years agoFix sanitization problems in the BFD library when running the linker testsuite for...
Nick Clifton [Wed, 26 Aug 2020 16:43:39 +0000 (17:43 +0100)]
Fix sanitization problems in the BFD library when running the linker testsuite for the AVR target.

PR 26433
* elf32-avr.c (avr_final_link_relocate):  Fix undefined shift
behaviour.
(avr_elf32_load_records_from_section): Use bfd_get_16 and
bfd_get_32 to load values from potentially unaligned pointers.

4 years agoFix sanitization problems running the linker testsuite for the alpha-elf target.
Nick Clifton [Wed, 26 Aug 2020 15:26:13 +0000 (16:26 +0100)]
Fix sanitization problems running the linker testsuite for the alpha-elf target.

PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Test for and
ignore local symbols.
(elf64_alpha_relax_got_load): Do not check for local dynamic
symbols.
(OP_LDA, OP_LDAH, OP_LDQ, OP_BR, OP_BSR): Use unsigned constant
values.
(INSN_A) Cast the A parameter to unsigned.
(INSN_AB): Define in terms of INSN_A.
(INSN_ABC): Likewise.
(INSN_ABO): Likewise.
(INSN_AD): Likewise.

4 years agoFix a sanitization problem running the linker testsuite for the AArch64 target.
Nick Clifton [Wed, 26 Aug 2020 14:50:36 +0000 (15:50 +0100)]
Fix a sanitization problem running the linker testsuite for the AArch64 target.

PR 26411
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Use an
unsigned long constant when creating a mask to test for alignment
issues.

4 years agoopcodes: Add missing entries to ebpf_isa_attr
Jose E. Marchesi [Wed, 26 Aug 2020 14:48:39 +0000 (16:48 +0200)]
opcodes: Add missing entries to ebpf_isa_attr

opcodes/

* disassemble.c (enum epbf_isa_attr): Add ISA_XBPFBE, ISA_EBPFMAX.

4 years agoAdd support to readelf for the OpenBSD segment types.
Nick Clifton [Wed, 26 Aug 2020 14:13:41 +0000 (15:13 +0100)]
Add support to readelf for the OpenBSD segment types.

PR 26405
binutils* readelf.c (get_segment_type): Handle OpenBSD segment types.

include * elf/common.h (PT_OPENBSD_BOOTDATA): Define.
(PT_OPENBSD_RANDOMIZE): Define.
(PT_OPENBSD_WXNEEDED): Define.

4 years agoPR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 10:58:40 +0000 (20:28 +0930)]
PR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch

PR 26508
* config/tc-xtensa.c (xg_get_trampoline_chain): Return early
when n_entries is zero.

4 years agoPR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 10:55:04 +0000 (20:25 +0930)]
PR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch

PR 26507
* elf32-xtensa.c (find_removed_literal): Don't bsearch empty map.

4 years agoPR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 10:50:11 +0000 (20:20 +0930)]
PR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy

PR 26506
* elf32-xtensa.c (elf_xtensa_combine_prop_entries): Return early
when section is empty.

4 years agoPR26499 UBSAN: eelf32_spu.c:537 member access null pointer
Alan Modra [Wed, 26 Aug 2020 10:42:42 +0000 (20:12 +0930)]
PR26499 UBSAN: eelf32_spu.c:537 member access null pointer

Another &p->field.

PR 26499
* emultempl/spuelf.em (spu_elf_relink): Check for NULL tmp_file_list.

4 years agoPR26498 UBSAN: elf32-spu.c:2292 left shift overflow
Alan Modra [Wed, 26 Aug 2020 10:32:07 +0000 (20:02 +0930)]
PR26498 UBSAN: elf32-spu.c:2292 left shift overflow

PR 26498
* elf32-spu.c (find_function_stack_adjust): Use unsigned vars to
avoid UB left shift.

4 years agoPR 26484-26488, 26490 UBSAN &h->elf null pointer
Alan Modra [Wed, 26 Aug 2020 10:13:18 +0000 (19:43 +0930)]
PR 26484-26488, 26490 UBSAN &h->elf null pointer

PR 26484
PR 26485
PR 26486
PR 26487
PR 26488
PR 26490
* elf64-ppc.c (is_tls_get_addr): Avoid UB &h->elf when h is NULL.
(ppc64_elf_tls_setup): Likewise.
(branch_reloc_hash_match): Likewise.
(build_plt_stub): Likewise.
(ppc64_elf_relocate_section): Likewise.

4 years agoPR26478 UBSAN: mmo.c:2941 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 09:02:30 +0000 (18:32 +0930)]
PR26478 UBSAN: mmo.c:2941 null pointer memcpy

PR 26478
* mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.

4 years agoPR26475 UBSAN: elfxx-mips.c:12180 null pointer memset
Alan Modra [Wed, 26 Aug 2020 08:52:07 +0000 (18:22 +0930)]
PR26475 UBSAN: elfxx-mips.c:12180 null pointer memset

Another memset(0,0,0)

PR 26475
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Check
sstubs->contents != NULL.

4 years agoPR26458 UBSAN: elf32-i386.c:3615 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 01:30:22 +0000 (11:00 +0930)]
PR26458 UBSAN: elf32-i386.c:3615 left shift of negative value

Happens when poking symbol index -2 into r_info.  (The index is
updated before writing out to file.)

PR 26458
* elf/common.h (ELF32_R_INFO): Cast symbol index to unsigned.

4 years agoPR26453 UBSAN: som.c:2885 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 08:28:40 +0000 (17:58 +0930)]
PR26453 UBSAN: som.c:2885 null pointer memcpy

PR 26453
* som.c (som_prep_for_fixups): Return early when no symbols.

4 years agoPR26448 UBSAN: symbols.c:1586 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 08:09:58 +0000 (17:39 +0930)]
PR26448 UBSAN: symbols.c:1586 left shift of negative value

Besides avoiding the UB, this also makes right shifts inside
expression symbols unsigned, consistent with the way gas evaluates
expressions in source.

PR 26448
* symbols.c: Include limits.h.
(resolve_symbol_value <O_left_shift, O_right_shift>): Do an
unsigned shift.  Warn if shift count larger than valueT size.

4 years agoPR26447 UBSAN: expr.c:1936 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 05:25:39 +0000 (14:55 +0930)]
PR26447 UBSAN: expr.c:1936 left shift of negative value

PR 26447
* expr.c (expr <O_left_shift>): Do an unsigned shift.

4 years agoPR26431 UBSAN: pe-dll.c:568 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 04:53:42 +0000 (14:23 +0930)]
PR26431 UBSAN: pe-dll.c:568 null pointer bsearch

PR 26431
* pe-dll.c (auto_export): Don't call bsearch with zero count.

4 years agoPR26418 UBSAN: cache.c:386 null pointer fwrite
Alan Modra [Wed, 26 Aug 2020 04:48:53 +0000 (14:18 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite

PR 26418
* ecofflink.c (WRITE): Don't write size 0 chunks.

4 years agoasan: alpha-vms: mmember access within null pointer
Alan Modra [Wed, 26 Aug 2020 02:02:51 +0000 (11:32 +0930)]
asan: alpha-vms: mmember access within null pointer

* bfdio.c (bfd_get_file_size): Don't segv on NULL adata.

4 years agoPR26415 UBSAN: vms-misc.c:636 left shift cannot be represented
Alan Modra [Wed, 26 Aug 2020 01:56:35 +0000 (11:26 +0930)]
PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented

An unsigned short value is promoted to int, thus triggering UB on a
left shift of a positive value that results in a negative int.

PR 26415
* vms-misc.c (vms_time_t_to_vms_time): Don't use unsigned short vars.

4 years agoPR26412 UBSAN: objcopy.c:3026 null pointer fwrite
Alan Modra [Wed, 26 Aug 2020 00:41:38 +0000 (10:11 +0930)]
PR26412 UBSAN: objcopy.c:3026 null pointer fwrite

PR 26412
* objcopy.c (copy_object): Don't fwrite NULL contents.

4 years agobpf: add xBPF ISA
David Faust [Wed, 26 Aug 2020 13:39:00 +0000 (15:39 +0200)]
bpf: add xBPF ISA

This patch adds support for xBPF, another ISA targetting the BPF
virtual architecture. For now, the primary difference between eBPF
and xBPF is that xBPF supports indirect calls through the
'call %reg' form of the call instruction.

bfd/
* archures.c (bfd_mach_xbpf): Define.
* bfd-in2.h: Regenerate.
* cpu-bpf.c (bfd_xbpf_arch) New.
(bfd_bpf_arch) Update next in list field to point to xbpf arch.

cpu/
* bpf.cpu (arch bpf): Add xbpf mach and isas.
(define-xbpf-isa) New pmacro.
(all-isas) Add xbpfle,xbpfbe.
(endian-isas): New pmacro.
(mach xbpf): New.
(model xbpf-def): Likewise.
(h-gpr): Add xbpf mach.
(f-dstle, f-srcle, dstle, srcle): Add xbpfle isa.
(f-dstbe, f-srcbe, dstbe, srcbe): Add xbpfbe isa.
(define-alu-insn-un): Use new endian-isas pmacro.
(define-alu-insn-bin, define-alu-insn-mov): Likewise.
(define-endian-insn, define-lddw): Likewise.
(dlind, dxli, dxsi, dsti): Likewise.
(define-cond-jump-insn, define-call-insn): Likewise.
(define-atomic-insns): Likewise.

gas/
* config/tc-bpf.c: Add option -mxbpf to select xbpf isa.
* testsuite/gas/bpf/indcall-1.d: New file.
* testsuite/gas/bpf/indcall-1.s: Likewise.
* testsuite/gas/bpf/indcall-bad-1.l: Likewise.
* testsuite/gas/bpf/indcall-bad-1.s: Likewise.
* testsuite/gas/bpf/bpf.exp: Run new tests.

opcodes/
* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-opc.h: Likewise.
* disassemble.c (disassemble_init_for_target): Set bits for xBPF
ISA when appropriate.

4 years agowindres: AUTOCHECKBOX default style must have WS_TABSTOP style
Katayama Hirofumi [Wed, 26 Aug 2020 10:57:02 +0000 (11:57 +0100)]
windres: AUTOCHECKBOX default style must have WS_TABSTOP style

PR 26340
* rcparse.y (AUTOCHECKBOX): Add WS_TABSTOP to the base style.

4 years agogdb: Add ARC target and maintainer to MAINTAINERS
Shahab Vahedi [Wed, 5 Aug 2020 15:58:45 +0000 (17:58 +0200)]
gdb: Add ARC target and maintainer to MAINTAINERS

This patch updates gdb/MAINTAINERS with ARC as a target and
myself as the maintainer.  There is no mention of "-Werror"
because that is enabled by default for gdb/ targets now.

gdb/ChangeLog:

* MAINTAINERS: Add ARC target and maintainer.

4 years agoRe: CSKY: Add new arch CK860
Alan Modra [Wed, 26 Aug 2020 02:10:28 +0000 (11:40 +0930)]
Re: CSKY: Add new arch CK860

bfd-in2.h is a generated file.  Put the new machine where it belongs.

* archures.c (bfd_mach_ck860): Define.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 26 Aug 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoarc: Add GNU/Linux support for ARC
Anton Kolesov [Wed, 6 Jul 2016 17:36:49 +0000 (20:36 +0300)]
arc: Add GNU/Linux support for ARC

ARC Linux targets differences from baremetal:

- No support for hardware single instruction stepping.
- Different access rules to registers.
- Use of another instruction for breakpoints.

v2: Changes after Tom's remarks [1]
 arc-linux-tdep.c
  - Use true/false instead of TRUE/FALSE.
  - arc_linux_sw_breakpoint_from_kind (): Break long lines into two.
  - arc_linux_sw_breakpoint_from_kind (): Remove starting blank line.
  - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0)
 arc-tdep.c
  - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0)
 gdb/configure.tgt
  - arc*-*-linux*): Remove "build_gdbserver=yes".

v3: Changes after Simon's remarks [2]
  arc-linux-tdep.c
  - Use "return trap_size" instead of cryptic "return 2".
  - Removed unnecessary curly braces.
  - Removed "void" from "_initialize_arc_linux_tdep (void)".

v5: Changes after Simon's remarks [3]
- Remove unnecessary empty lines.
- Replace "breakpoint uses" with "breakpoints use" in a comment.
- "return condition;" i.s.o. "if (condition) return true; else return false;"

[1] Tom's remarks
https://sourceware.org/pipermail/gdb-patches/2020-April/167887.html

[2] Simon's remarks on v2
https://sourceware.org/pipermail/gdb-patches/2020-May/168513.html

[3] Simon's remarks on v4
https://sourceware.org/pipermail/gdb-patches/2020-August/170994.html

gdb/ChangeLog:

2020-08-25  Anton Kolesov  <anton.kolesov@synopsys.com>

* configure.tgt: ARC support for GNU/Linux.
* Makefile.in (ALL_TARGET_OBJS): Likewise.
* arc-linux-tdep.c: New file.
* arc-tdep.h (ARC_STATUS32_L_MASK, ARC_STATUS32_DE_MASK): Declare.
* arc-tdep.c (arc_write_pc): Use it.

4 years agoarc: Add hardware loop detection
Shahab Vahedi [Thu, 9 Jul 2020 15:44:01 +0000 (17:44 +0200)]
arc: Add hardware loop detection

For ARC there are registers that are not part of a required set in XML
target descriptions by default, but are almost always present on ARC
targets and are universally exposed by the ptrace interface.  Hardware
loop registers being one of them.

LP_START and LP_END auxiliary registers are hardware loop start and end.
Formally, they are optional, but it is hard to find an ARC configuration
that doesn't have them.  They are always present in processors that can
run GNU/Linux.  GDB needs to know about those registers to implement
proper software single stepping, since they affect  what instruction
will be next.

This commit adds the code to check for the existance of "lp_start" and
"lp_end" in XML target descriptions. If they exist, then the function
reports that the target supports hardware loops.

gdb/ChangeLog:

* arc-tdep.c (arc_check_for_hardware_loop): New.
* arc-tdep.h (gdbarch_tdep): New field has_hw_loops.

gdb/doc/ChangeLog:

* gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.

4 years agoarc: Add inclusion of "gdbarch.h" in "arc-tdep.h"
Shahab Vahedi [Mon, 3 Aug 2020 18:41:42 +0000 (20:41 +0200)]
arc: Add inclusion of "gdbarch.h" in "arc-tdep.h"

The "arc-tdep.h" makes use of definitions in "gdbarch.h", but it
does not include it explicitly.  I have piggy backed this fix
in another commit [1], but I was asked to do it separately [2].

[1] arc: Add hardware loop detection
https://sourceware.org/pipermail/gdb-patches/2020-July/170800.html

[2] Simon's remarks to "arc: Add hardware loop detection"
https://sourceware.org/pipermail/gdb-patches/2020-August/170993.html

gdb/ChangeLog:

* arc-tdep.h: Include "gdbarch.h".

4 years agoarc: Add ARCv2 XML target along with refactoring
Shahab Vahedi [Thu, 9 Jul 2020 15:43:13 +0000 (17:43 +0200)]
arc: Add ARCv2 XML target along with refactoring

A few changes have been made to make the register support simpler,
more flexible and extendible.  The trigger for most of these changes
are the remarks [1] made earlier for v2 of this patch.  The noticeable
improvements are:

- The arc XML target features are placed under gdb/features/arc
- There are two cores (based on ISA) and one auxiliary feature:
  v1-core: ARC600, ARC601, ARC700
  v2-core: ARC EM, ARC HS
  aux: common in both
- The XML target features represent a minimalistic sane set of
  registers irrespective of application (baremetal or linux).
- A concept of "feature" class has been introduced in the code.
  The "feature" object is constructed from BFD and GDBARCH data.
  It contains necessary information (ISA and register size) to
  determine which XML target feature to use.
- A new structure (ARC_REGISTER_FEATURE) is added that allows
  providing index, names, and the necessity of registers. This
  simplifies the sanity checks and future extendibility.
- Documnetation has been updated to reflect ARC features better.
- Although the feature names has changed, there still exists
  backward compatibility with older names through
  find_obsolete_[core,aux]_names() functions.

The last two points were inspired from RiscV port.

[1]
https://sourceware.org/pipermail/gdb-patches/2020-May/168511.html

gdb/ChangeLog:

* arch/arc.h
  (arc_gdbarch_features): New class to stir the selection of target XML.
  (arc_create_target_description): Use FEATURES to choose XML target.
  (arc_lookup_target_description): Use arc_create_target_description
  to create _new_ target descriptions or return the already created
  ones if the FEATURES is the same.
* arch/arc.c: Implementation of prototypes described above.
* gdb/arc-tdep.h (arc_regnum enum): Add more registers.
  (arc_gdbarch_features_init): Initialize the FEATURES struct.
* arc-tdep.c (*_feature_name): Make feature names consistent.
  (arc_register_feature): A new struct to hold information about
  registers of a particular target/feature.
  (arc_check_tdesc_feature): Check if XML provides registers in
  compliance with ARC_REGISTER_FEATURE structs.
  (arc_update_acc_reg_names): Add aliases for r58 and r59.
  (determine_*_reg_feature_set): Which feature name to look for.
  (arc_gdbarch_features_init): Given MACH and ABFD, initialize FEATURES.
  (mach_type_to_arc_isa): Convert from a set of binutils machine types
  to expected ISA enums to be used in arc_gdbarch_features structs.
* features/Makefile (FEATURE_XMLFILES): Add new files.
* gdb/features/arc/v1-aux.c: New file.
* gdb/features/arc/v1-aux.xml: Likewise.
* gdb/features/arc/v1-core.c: Likewise.
* gdb/features/arc/v1-core.xml: Likewise.
* gdb/features/arc/v2-aux.c: Likewise.
* gdb/features/arc/v2-aux.xml: Likewise.
* gdb/features/arc/v2-core.c: Likewise.
* gdb/features/arc/v2-core.xml: Likewise.
* NEWS (Changes since GDB 9): Announce obsolence of old feature names.

gdb/doc/ChangeLog:

* gdb.texinfo (Synopsys ARC): Update the documentation for ARC
Features.

gdb/testsuite/ChangeLog:

* gdb.arch/arc-tdesc-cpu.xml: Use new feature names.

4 years agogdb/testsuite: fix gdb.threads/stepi-random-signal.exp pattern (gdb/26532)
Simon Marchi [Tue, 25 Aug 2020 15:06:43 +0000 (11:06 -0400)]
gdb/testsuite: fix gdb.threads/stepi-random-signal.exp pattern (gdb/26532)

Commit 1eb8556f5a8b ("gdb: add infrun_debug_printf macro") changed the
debug output format for `set debug infrun 1`.  The test
gdb.threads/stepi-random-signal.exp uses that debug output, and was
updated, but not correctly.  It results in this failure:

    FAIL: gdb.threads/stepi-random-signal.exp: stepi (no random signal)

Fix it by adjusting the pattern in the test.

gdb/testsuite/ChangeLog:

PR gdb/26532
* gdb.threads/stepi-random-signal.exp: Update pattern.

Change-Id: If5fa525e9545e32a286effe6a6184358374bd37c

4 years agogdb/testsuite: fix gdb.base/ui-redirect.exp pattern (gdb/26532)
Simon Marchi [Tue, 25 Aug 2020 15:06:27 +0000 (11:06 -0400)]
gdb/testsuite: fix gdb.base/ui-redirect.exp pattern (gdb/26532)

Commit 1eb8556f5a8b ("gdb: add infrun_debug_printf macro") changed the
debug output format for `set debug infrun 1`.  It broke test
gdb.base/ui-redirect.exp, which I missed:

    FAIL: gdb.base/ui-redirect.exp: debugging: continue

Fix it by adjusting the pattern in the test to the new reality.

gdb/testsuite/ChangeLog:

PR gdb/26532
* gdb.base/ui-redirect.exp: Update pattern.

Change-Id: Ie8a8f6675e35a0cab55109b1534b44eb51baec9d

4 years agoFix ChangeLog entry for commit b04aa1fc8c9d4a79e6293a3a1df7507052afedf3
Gary Benson [Tue, 25 Aug 2020 14:53:33 +0000 (15:53 +0100)]
Fix ChangeLog entry for commit b04aa1fc8c9d4a79e6293a3a1df7507052afedf3

4 years agoFix the linker's handling of DWARF-5 line number tables.
Mark Wielaard [Tue, 25 Aug 2020 14:33:00 +0000 (15:33 +0100)]
Fix the linker's handling of DWARF-5 line number tables.

When building with gcc with -gdwarf-5 ld tests (including ld-elf/dwarf.exp)
fail because they try to read the .debug_ranges section. But DWARF5
introduces a new .debug_rnglists section that encodes the address ranges
more efficiently. Implement reading the debug_rnglists in bfd/dwarf2.c.
Which makes all tests pass again and fixes several gcc testsuite tests
when defaulting to DWARF5.

*  dwarf2.c (struct dwarf2_debug_file): Add dwarf_rnglists_buffer
and dwarf_rnglists_size fields.
(dwarf_debug_sections): Add debug_rnglists.
(dwarf_debug_section_enum): Likewise.
(read_debug_rnglists): New function.
(read_rangelist): New function to call either read_ranges or
read_rnglists. Rename original function to...
(read_ranges): ...this.
(read_rnglists): New function.