Commit Graph

103056 Commits

Author SHA1 Message Date
Cooper Qu
e2e82b115c 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.
2020-08-31 11:32:18 +08:00
Cooper Qu
dd221981c4 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.
2020-08-31 11:16:21 +08:00
GDB Administrator
18856f435e Automatic date update in version.in 2020-08-31 00:00:07 +00:00
H.J. Lu
42afa120eb 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.
2020-08-30 07:28:17 -07:00
Alan Modra
d0ed6fddfa changelog PR fix
for the lack of a space
2020-08-30 23:00:26 +09:30
Alan Modra
54b8331d0b 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.
2020-08-30 20:49:32 +09:30
Alan Modra
2781f857e6 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.
2020-08-30 20:49:32 +09:30
Alan Modra
c930281005 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.
2020-08-30 20:49:18 +09:30
Alan Modra
34d8e6d0c5 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.
2020-08-30 19:37:15 +09:30
GDB Administrator
c44ea3aef6 Automatic date update in version.in 2020-08-30 00:00:07 +00:00
Nick Clifton
e6f04d55f6 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.
2020-08-29 08:03:15 +01:00
Alan Modra
55b8e31a7a correct pr number in changelog 2020-08-29 13:58:47 +09:30
Alan Modra
0c0577f6a8 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.
2020-08-29 13:17:57 +09:30
Alan Modra
8a267ea847 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.
2020-08-29 13:17:13 +09:30
Alan Modra
736c9875c0 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.
2020-08-29 13:16:42 +09:30
GDB Administrator
9b5f4ffe1b Automatic date update in version.in 2020-08-29 00:00:09 +00:00
Pedro Alves
f7c7700d32 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.
2020-08-29 00:55:58 +01:00
Pedro Alves
8f57f34310 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.
2020-08-28 18:44:39 +01:00
Tom Tromey
e0814aae5f 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.
2020-08-28 11:07:36 -06:00
Nick Clifton
08d7da7dc9 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.
2020-08-28 16:04:49 +01:00
Alan Modra
a1e60a1bdc 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.
2020-08-28 23:52:26 +09:30
Alan Modra
ed2ed4dcf4 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.
2020-08-28 23:15:21 +09:30
Alan Modra
07319accdf 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.
2020-08-28 23:15:20 +09:30
Mark Wielaard
4a5700b62f 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.
2020-08-28 15:26:01 +02:00
Jozef Lawrynowicz
64b63c2993 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.
2020-08-28 14:01:10 +01:00
Jozef Lawrynowicz
87870682f3 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.
2020-08-28 14:00:54 +01:00
Alan Modra
7ca371dba5 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.
2020-08-28 21:59:29 +09:30
Tuckker
1e597a8997 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.
2020-08-28 13:27:16 +01:00
Tom de Vries
626d23209f [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.
2020-08-28 12:02:20 +02:00
Cooper Qu
0861f561eb 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.
2020-08-28 17:23:24 +08:00
Nick Clifton
6194b866b7 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.
2020-08-28 09:43:13 +01:00
Alan Modra
16f9c644c7 mingw plugin test regressions due to commit 514b4e191d
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.
2020-08-28 13:12:20 +09:30
Nelson Chu
3b1450b38c 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.
2020-08-28 09:37:35 +08:00
GDB Administrator
f2f08254b1 Automatic date update in version.in 2020-08-28 00:00:10 +00:00
Pedro Alves
df63178325 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.
2020-08-27 21:03:53 +01:00
Pedro Alves
b2b38aa45b 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.
2020-08-27 21:03:53 +01:00
Jozef Lawrynowicz
b019121604 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.
2020-08-27 20:58:03 +01:00
Jozef Lawrynowicz
82b946165d ld/emultempl/msp430.em: Remove unused variable
ld/ChangeLog:

	* emultempl/msp430.em: Remove unused variable "buf".
2020-08-27 20:10:52 +01:00
Simon Marchi
48b076bbca 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
2020-08-27 14:42:38 -04:00
Simon Marchi
fc5d6901ad gdb: fix whitespace issues in ChangeLog files
Change-Id: I423867477d4342673e629dac71a80592fd879ea1
2020-08-27 12:54:57 -04:00
Andrew Burgess
c2015ce4a4 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.
2020-08-27 16:32:40 +01:00
John David Anglin
9e7ed8b080 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.
2020-08-27 15:25:03 +00:00
Ralf Habacker
6b5473c97e 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
2020-08-27 15:59:53 +01:00
Simon Marchi
b886559f31 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
2020-08-27 08:58:43 -04:00
Nick Clifton
ec10b3bb91 Remove commit 9fb2400ce6 2020-08-27 13:52:45 +01:00
Nick Clifton
9fb2400ce6 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.
2020-08-27 13:47:02 +01:00
Alan Modra
4b69ce9b91 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.
2020-08-27 22:05:00 +09:30
Alan Modra
6fbd4a8e8b 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.
2020-08-27 21:56:33 +09:30
Alan Modra
cd570d497e PR26462 UBSAN: reloc.c:473 shift exponent 4294967295
PR 26462
	* reloc.c (bfd_check_overflow): Return early if zero bitsize.
2020-08-27 21:56:33 +09:30
Alan Modra
2ac865acf0 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.
2020-08-27 21:56:33 +09:30