Commit Graph

9594 Commits

Author SHA1 Message Date
Alan Modra
15a32af52f power10 on ppc32
We don't support power10 on ppc32, mainly because some instructions
have 34-bit fields for which we don't have relocations on ppc32.
If you try to assemble typical code, you'll see errors saying
"reloc ... not supported by object file format".  Also, on 32-bit
hosts with binutils configured without a 64-bit bfd, you'll see errors
saying "bignum invalid" when using large offsets.  But let's not kill
output of prefix insns entirely on 32-bit hosts.

	* config/tc-ppc.c (md_assemble): Emit prefix insn by parts when
	valueT is smaller than 64 bits.
2020-09-09 22:51:07 +09:30
Cooper Qu
6a1ed9106f CSKY: Change mvtc and mulsw's ISA flag.
gas/
	* config/tc-csky.c (CSKYV2_ISA_DSP): CSKY_ISA_DSPE60.
	(CSKY_ISA_860): Likewise.

include/
	* opcode/csky.h (CSKY_ISA_DSPE60): Define.

opcodes/
	* csky-opc.h (csky_v2_opcodes): Change mvtc and mulsw's
	ISA flag.
2020-09-09 19:26:34 +08:00
Cooper Qu
a2061b9f29 CSKY: Support option -mfloat-abi.
The option corresponds to GCC to control the float calling conversion,
and the value will be stored in .csky.attributes section.

Co-Authored-By: Lifang Xia <lifang_xia@c-sky.com>

gas/
	* config/tc-csky.c (float_abi): New.
	(md_longopts): Add mfloat-abi.
	(struct sky_option_value_table): New.
	(csky_float_abis): New, the possible values for -mfloat-abi.
	(parse_float_abi): New funtion.
	(md_show_usage): Show help information for -mfloat-abi.
	(set_csky_attribute): Store float-abi value.
2020-09-09 19:26:24 +08:00
Cooper Qu
1feede9b38 CSKY: Add FPUV3 instructions, which supported by ck860f.
Co-Authored-By: Lifang Xia <lifang_xia@c-sky.com>

gas/
	* config/tc-csky.c (float_work_fpuv3_fmovi): New function,
	helper function to encode fpuv3 fmovi instructions.
	(float_work_fpuv3_fstore): New function.
	(struct literal): Add new member 'offset'.
	(csky_cpus): New cpu CK860f.
	(enter_literal): Return literal pool pointer instead of offset.
	(parse_rt): Adjust the change of enter_literal.
	(parse_rtf): Likewise.
	(v1_work_lrw): Likewise.
	(v1_work_jbsr): Likewise.
	(v2_work_lrw): Likewise.
	(v2_work_jbsr): Likewise.
	(v2_work_jsri): Likewise.
	(vdsp_work_vlrw): Likewise.
	(is_freglist_legal): Add handler for FPUV3.
	(parse_type_freg): Likewise.
	(is_imm_within_range): Set e.X_add_number if it is a signed and
	negtive number.
	(get_operand_value): Add handler for OPRND_TYPE_IMM9b,
	OPRND_TYPE_HFLOAT_FMOVI, OPRND_TYPE_SFLOAT_FMOVI
	and OPRND_TYPE_DFLOAT_FMOVI.
	(float_to_half): Convert float number to harf float.

opcodes/
	* csky-dis.c (csky_output_operand): Add handlers for
	OPRND_TYPE_HFLOAT_FMOVI, OPRND_TYPE_SFLOAT_FMOVI and
	OPRND_TYPE_DFLOAT_FMOVI. Refine OPRND_TYPE_FREGLIST_DASH
	to support FPUV3 instructions.
	* csky-opc.h (enum operand_type): New enum OPRND_TYPE_IMM9b,
	OPRND_TYPE_HFLOAT_FMOVI, OPRND_TYPE_SFLOAT_FMOVI and
	OPRND_TYPE_DFLOAT_FMOVI.
	(OPRND_MASK_4_5, OPRND_MASK_6, OPRND_MASK_6_7, OPRND_MASK_6_8,
	 OPRND_MASK_7, OPRND_MASK_7_8, OPRND_MASK_17_24,
	 OPRND_MASK_20, OPRND_MASK_20_21, OPRND_MASK_20_22,
	 OPRND_MASK_20_23, OPRND_MASK_20_24, OPRND_MASK_20_25,
	 OPRND_MASK_0_3or5_8, OPRND_MASK_0_3or6_7, OPRND_MASK_0_3or25,
	 OPRND_MASK_0_4or21_24, OPRND_MASK_5or20_21,
	 OPRND_MASK_5or20_22, OPRND_MASK_5or20_23, OPRND_MASK_5or20_24,
	 OPRND_MASK_5or20_25, OPRND_MASK_8_9or21_25,
	 OPRND_MASK_8_9or16_25, OPRND_MASK_4_6or20, OPRND_MASK_5_7or20,
	 OPRND_MASK_4_5or20or25, OPRND_MASK_4_6or20or25,
	 OPRND_MASK_4_7or20or25, OPRND_MASK_6_9or17_24,
	 OPRND_MASK_6_7or20, OPRND_MASK_6or20, OPRND_MASK_7or20,
	 OPRND_MASK_5or8_9or16_25, OPRND_MASK_5or8_9or20_25): Define.
	(csky_v2_opcodes): Add FPUV3 instructions.

include/
	* opcode/csky.h (CSKY_ISA_FLOAT_7E60): Define.
2020-09-09 19:25:40 +08:00
Jozef Lawrynowicz
7d81bc937c MSP430: Support relocations for subtract expressions in .uleb128 directives
Link-time relaxations of branches are common for MSP430, given that GCC
can generate pessimal branch instructions, and the
-mcode-region=either/-mdata-region=either options to shuffle sections
can further change the type of branch instruction required.

These relaxations can result in invalid code when .uleb128
directives, used in the .gcc_except_table section, are used to calculate
the distance between two labels. A value for the .uleb128 directive is
calculated at assembly-time, and can't be updated at link-time, even if
relaxation causes the distance between the labels to change.

This patch adds relocations for subtract expressions in .uleb128
directives, to allow the linker to re-calculate the value of these
expressions after relaxation has been performed.

bfd/ChangeLog:
	* bfd-in2.h (bfd_reloc_code_real): Add
	BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* elf32-msp430.c (msp430_elf_ignore_reloc): New.
	(elf_msp430_howto_table): Add R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	(msp430_reloc_map): Add R_MSP430_GNU_{SET,SUB}_ULEB128.
	(msp430x_reloc_map): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.
	(write_uleb128): New.
	(msp430_final_link_relocate): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	* libbfd.c (_bfd_write_unsigned_leb128): New.
	* libbfd.h (_bfd_write_unsigned_leb128): New prototype.
	Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* reloc.c: Document BFD_RELOC_MSP430_{SET,SUB}_ULEB128.

binutils/ChangeLog:
	* readelf.c (target_specific_reloc_handling): Handle
	R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.

gas/ChangeLog:
	* config/tc-msp430.c (msp430_insert_uleb128_fixes): New.
	(msp430_md_end): Call msp430_insert_uleb128_fixes.

include/ChangeLog:
	* elf/msp430.h (elf_msp430_reloc_type): Add
	R_MSP430_GNU_{SET,SUB}_ULEB128.
	(elf_msp430x_reloc_type): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.

ld/ChangeLog:
	* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
	* testsuite/ld-msp430-elf/uleb128.s: New test.
	* testsuite/ld-msp430-elf/uleb128_430.d: New test.
	* testsuite/ld-msp430-elf/uleb128_430x.d: New test.
2020-09-08 16:18:38 +01:00
Alex Coplan
f1363b0fb4 aarch64: Add -mcpu option for Cortex-R82
This adds support for the Arm Cortex-R82 CPU in AArch64 GAS. For more
information about this processor, see [0].

[0] : https://developer.arm.com/ip-products/processors/cortex-r/cortex-r82

gas/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* config/tc-aarch64.c (aarch64_cpus): Add Cortex-R82.
	* doc/c-aarch64.texi: Document -mcpu=cortex-r82.
2020-09-08 14:22:59 +01:00
Alex Coplan
38cf07a6c0 aarch64: Add support for Armv8-R system registers
This patch adds support for the system registers introduced in Armv8-R
AArch64.

gas/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* config/tc-aarch64.c (parse_sys_reg): Also pass sysreg name to
	validation function.
	(parse_sys_ins_reg): Likewise.
	(print_operands): Pass CPU features to aarch64_print_operand().
	* testsuite/gas/aarch64/v8-r-bad-sysregs.d: New test.
	* testsuite/gas/aarch64/v8-r-bad-sysregs.l: Error output.
	* testsuite/gas/aarch64/v8-r-bad-sysregs.s: Input.
	* testsuite/gas/aarch64/v8-r-sysregs-need-arch.d: New test.
	* testsuite/gas/aarch64/v8-r-sysregs-need-arch.l: Error output.
	* testsuite/gas/aarch64/v8-r-sysregs.d: New test.
	* testsuite/gas/aarch64/v8-r-sysregs.s: Input for previous two tests.

include/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* opcode/aarch64.h (aarch64_sys_ins_reg_supported_p): Also take
	system register name in order to simplify validation for v8-R.
	(aarch64_print_operand): Also take CPU feature set, as disassembly for
	system registers now depends on arch variant.

opcodes/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* aarch64-dis.c (print_operands): Pass CPU features to
	aarch64_print_operand().
	* aarch64-opc.c (aarch64_print_operand): Use CPU features to determine
	preferred disassembly of system registers.
	(SR_RNG): Refactor to use new SR_FEAT2 macro.
	(SR_FEAT2): New.
	(SR_V8_1_A): New.
	(SR_V8_4_A): New.
	(SR_V8_A): New.
	(SR_V8_R): New.
	(SR_EXPAND_ELx): New.
	(SR_EXPAND_EL12): New.
	(aarch64_sys_regs): Specify which registers are only on
	A-profile, add R-profile system registers.
	(ENC_BARLAR): New.
	(PRBARn_ELx): New.
	(PRLARn_ELx): New.
	(aarch64_sys_ins_reg_supported_p): Reject EL3 registers for
	Armv8-R AArch64.
2020-09-08 14:21:44 +01:00
Alex Coplan
03fb3142c7 aarch64: Add support for Armv8-R DFB alias
This adds support for the DFB alias introduced in Armv8-R AArch64.

gas/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* testsuite/gas/aarch64/dfb.d: New test.
	* testsuite/gas/aarch64/dfb.s: Input.

opcodes/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* aarch64-tbl.h (aarch64_feature_v8_r): New.
	(ARMV8_R): New.
	(V8_R_INSN): New.
	(aarch64_opcode_table): Add dfb.
	* aarch64-opc-2.c: Regenerate.
	* aarch64-asm-2.c: Regenerate.
	* aarch64-dis-2.c: Regenerate.
2020-09-08 14:18:38 +01:00
Alex Coplan
95830c988a aarch64: Add base support for Armv8-R
This patch adds the basic infrastructure needed to support Armv8-R in
AArch64 binutils: new command-line flags, new feature bits, a new BFD
architecture, and support for differentiating between architecture
variants in the disassembler.

The new command-line options added by this patch are -march=armv8-r in
GAS and -m aarch64:armv8-r in objdump.

The disassembler support is necessary since Armv8-R AArch64 introduces a
system register (VSCTLR_EL2) which shares an encoding with a different
system register (TTBR0_EL2) in Armv8-A. This also allows us to use the
correct preferred disassembly for the new DFB alias introduced in
Armv8-R.

bfd/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* archures.c (bfd_mach_aarch64_8R): New.
	* bfd-in2.h: Regenerate.
	* cpu-aarch64.c (bfd_aarch64_arch_v8_r): New.
	(bfd_aarch64_arch_ilp32): Update tail pointer.

gas/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* config/tc-aarch64.c (aarch64_archs): Add armv8-r.
	* doc/c-aarch64.texi: Document -march=armv8-r.

include/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* opcode/aarch64.h (AARCH64_FEATURE_V8_A): New.
	(AARCH64_FEATURE_V8_R): New.
	(AARCH64_ARCH_V8): Include new A-profile feature bit.
	(AARCH64_ARCH_V8_R): New.

opcodes/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

	* aarch64-dis.c (arch_variant): New.
	(determine_disassembling_preference): Disassemble according to
	arch variant.
	(select_aarch64_variant): New.
	(print_insn_aarch64): Set feature set.
2020-09-08 14:14:11 +01:00
Mark Wielaard
d2a5455807 gas: Output directory and file names in .debug_line_str for DWARF5
* dwarf2dbg.c (add_line_strp): New function.
	(out_dir_and_file_list): Take line_seg and sizeof_offset as
	arguments, Use DW_FORM_line_strp for dir and file. Call
	add_line_strp and set symbol offset for DWARF2_LINE_VERSION 5.
	(out_debug_line): Call out_dir_and_file_list with line_seg and
	sizeof_offset.
	* gas/testsuite/gas/elf/dwarf-5-file0.d: Expect indirect line
	strings.
2020-09-07 14:03:20 +01:00
Mark Wielaard
bdd3b953e2 gas: Output .debug_rnglists for DWARF 5.
* dwarf2dbg.c (DWARF2_RNGLISTS_VERSION): New constant.
	(out_debug_ranges): Add ranges_sym argument and set it.
	(out_debug_rnglists): New function.
	(out_debug_info): Change ranges_seg argument to ranges_sym
	and use it to set DW_AT_ranges value.
	(dwarf2_finish): Remove ranges_seg, add ranges_sym. For
	DWARF2_VERSION 5 call out_debug_rnglists.
2020-09-07 13:04:45 +01:00
Mark Wielaard
b0b3ea7e10 gas: Make sure to only add an md5 to a .file when requested.
* dwarf2dbg.c (dwarf2_directive_filename): Initialize with_md5 to
	FALSE.
	* gas/testsuite/gas/elf/dwarf-5-file0.s: Add a random bignum.
2020-09-07 12:08:07 +01:00
Mark Wielaard
dd216e07a1 gas: Use DW_FORM_sec_offset for DWARF version 4 or higher.
Older DWARF versions used DW_FORM_data4 or DW_FORM_data8 for offsets
into sections for e.g. DW_AT_stmt_list ot DW_AT_ranges. But version 4
introduced a dedicated form for such section offsets. Make sure to emit
the proper form for newer DWARF versions.

gas/ChangeLog:

	* dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_sec_offset for DWARF
	version 4 or higher.
2020-09-03 18:00:03 +02:00
Alan Modra
c77a6ef610 ubsan: expr.c:1725,1741 signed integer overflow
* expr.c (add_to_result, subtract_from_result): Use unsigned
	addition and subtraction.
2020-09-02 16:30:43 +09:30
Alan Modra
01a6f9da64 ubsan: tc-z80.c:3656 shift exponent 32 is too large
* config/tc-z80.c (is_overflow): Avoid too large shift.
2020-09-02 16:30:43 +09:30
Alan Modra
6228e2790a ubsan: tc-sparc.c:1146 left shift cannot be represented
* config/tc-sparc.c (in_signed_range): Use an unsigned type for
	sign mask.
2020-09-02 16:30:43 +09:30
Alan Modra
1929210d46 ubsan: tc-nios2.c:1403 shift exponent 32 is too large
* config/tc-nios2.c (md_apply_fix): Avoid too large shift.
2020-09-02 16:30:43 +09:30
Alan Modra
7697028a6c ubsan: tc-mips.c:9606 shift exponent 32 is too large
* config/tc-mips.c (load_register): Avoid too large shift.
2020-09-02 16:30:43 +09:30
Alan Modra
602e9f0ae7 ubsan: tc-d30v.c left shift cannot be represented
* config/tc-d30v.c (parallel_ok): Use 1UL for left shift expression.
2020-09-02 16:30:43 +09:30
Alan Modra
17e782e94f ubsan: rx-parse.y:1743 shift exponent 32 is too large
* config/rx-parse.y (rx_intop): Avoid too large shifts.
	(rx_intop, rx_uintop, rx_disp3op, rx_disp5op, displacement),
	(rtsd_immediate): Use correctly typed unsigned variables.
2020-09-02 16:30:43 +09:30
Alan Modra
4dda287bf6 ubsan: obj-macho.c:503 left shift cannot be represented
* config/obj-macho.c (obj_mach_o_zerofill): Correct type of
	constant shifted left.
2020-09-02 16:30:43 +09:30
Alan Modra
251150adb1 ubsan: bfin-lex.l:503 left shift cannot be represented
* config/bfin-lex.l: Use an unsigned type for "value".
2020-09-02 16:30:42 +09:30
Alan Modra
f6e6b05211 32-bit host pdp11 breakage
If bfd_vma is 32 bits, gcc complains about shift counts exceeding
width of the type.

	* config/tc-pdp11.c (md_number_to_chars): Condition nbytes=8 code
	on BFD64.
2020-09-02 16:30:42 +09:30
Cooper Qu
4211a34001 CSKY: Add CPU CK803r3.
Move divul and divsl to CSKYV2_ISA_3E3R3 instruction set, which is
enabled by ck803r3, and it's still a part of enhance DSP instruction
set.

gas/
	* config/tc-csky.c (csky_cpus): Add ck803r3.
	(CSKY_ISA_803R3): Define.
	(CSKY_ISA_803R2): Refine, use CSKY_ISA_803R1.

include/
	* opcode/csky.h (CSKYV2_ISA_3E3R3): Define.

opcodes/
	* csky-opc.h (csky_v2_opcodes): Move divul and divsl
	to CSKYV2_ISA_3E3R3 instruction set.
2020-09-02 14:21:31 +08:00
Cooper Qu
8119cc3837 CSKY: Fix Encode of mulsws.
gas/
	* testsuite/gas/csky/cskyv2_dsp.d : Fix Encode of mulsws.

opcodes/
	* csky-opc.h (csky_v2_opcodes): Fix Encode of mulsws.
2020-09-02 14:21:21 +08:00
Cooper Qu
e61ef79e3a CSKY: Refine literals pool dump process and float register parser.
gas/
	* config/tc-csky.c (struct literal): New member bignum.
	(dump_literals): Handle big constant.
	(enter_literal): Likewise.
	(parse_type_freg): Handle vector register.
2020-09-02 14:21:02 +08:00
H.J. Lu
4c8584be76 ELF: Document the .tls_common directive
Document the .tls_common directive added by

commit b8871f357f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 22 09:18:52 2016 -0800

    Properly implement STT_COMMON

	* doc/as.texi: Document the .tls_common directive.
2020-09-01 07:47:00 -07:00
Alan Modra
7af677524e PR26420, PR26421, PR26425, PR26427 UBSAN: tc-arm.c left shifts
PR 26420
	PR 26421
	PR 26425
	PR 26427
	* config/tc-arm.c (struct arm_it): Make size, size_req, cond and
	uncond_value unsigned.
	(parse_vfp_reg_list): Make setmask unsigned, vpr_str_len size_t.
	(parse_big_immediate): Cast generic_bignum elements to unsigned.
	(encode_thumb32_immediate): Shift left 0xffU.
	(double_to_single): Make sign unsigned.  Tidy.
	(move_or_literal_pool): Cast LITTLE_NUM elements to uint64_t or
	valueT.
	(vfp_or_neon_is_neon): Adjust inst.uncond_value expression.
	(md_assemble): Likewise.
	(handle_pred_state): Make cond unsigned.
	(thumb32_negate_data_op): Make variables unsigned.
	(md_apply_fix): Make value and newval unsigned, adjust uses.
2020-09-01 16:02:48 +09:30
Alan Modra
06de2e0da2 PR26510 UBSAN: tc-z8k.c left shift of negative value
This also fixes the packing of the nibble buffer, which contains
rubbish in the top 4 bits of each element.

	PR 26510
	* config/tc-z8k.c (buffer): Use unsigned char.
	(apply_fix): Use unsigned char* pointers.
	(build_bytes): Likewise and mask nibbles when packing.
2020-08-31 20:28:13 +09:30
Alan Modra
8e82201777 PR26503 UBSAN: tc-v850.c:1447 left shift cannot be represented
PR 26503
	* config/tc-v850.c (parse_register_list): Shift 1u left.
2020-08-31 20:28:13 +09:30
Alan Modra
94f360ea2f PR26502 UBSAN: tc-tic6x.c left shift of negative value
PR 26502
	* config/tc-tic6x.c (md_apply_fix): Use unsigned variables.
2020-08-31 20:28:12 +09:30
Alan Modra
8659fff005 PR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented
PR 26497
	* config/tc-sh.c (assemble_ppi): Use unsigned variables.
2020-08-31 20:28:12 +09:30
Alan Modra
548c8b2ba7 PR26495 UBSAN: tc-score.c, tc-score7.c left shift of negative value
PR 26495
	* config/tc-score.c (s3_apply_fix): Use unsigned variables.
	* config/tc-score7.c (s7_apply_fix): Likewise.
2020-08-31 20:28:12 +09:30
Alan Modra
51bf29b1f7 PR26480 UBSAN: tc-nios2.c:1634 left shift cannot be represented
PR 26480
	* config/tc-nios2.c (nios2_parse_reglist): Shift 1UL left.
2020-08-31 20:28:12 +09:30
Alan Modra
baeb994f3f PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented
PR 26479
	* config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting.
2020-08-31 20:28:11 +09:30
Alan Modra
e0fd91ef81 PR26472, PR26473, PR26474 UBSAN: tc-mips.c shift left UB
PR 26472
	PR 26473
	PR 26474
	* config/tc-mips.c (operand_reg_mask): Shift 1u left.
	(load_register): Shift 0xffffU left.
2020-08-31 20:28:11 +09:30
Alan Modra
46021a61e4 PR26471 UBSAN: tc-metag.c:7038 left shift cannot be represented
PR 26471
	* config/tc-metag.c (md_chars_to_number): Make retval unsigned.
2020-08-31 20:28:11 +09:30
Alan Modra
7a5dd76f3c PR26468 UBSAN: tc-mep.c:1684 left shift of negative value
PR 26468
	* config/tc-mep.c (md_convert_frag): Use uint32_t for addend and
	other variables.
2020-08-31 20:28:11 +09:30
Alan Modra
169ec51259 PR26493 UBSAN: tc-riscv.c left shift negative and not representable
PR 26493
	* config/tc-riscv.c (riscv_ip): Cast X_add_number passed to
	VALID_* macros to unsigned.
2020-08-31 20:28:11 +09:30
Alan Modra
880fc278ca 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.
2020-08-31 20:28:09 +09:30
Alan Modra
26e3de8e0a 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.
2020-08-31 20:28:09 +09:30
Alan Modra
737d219034 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.
2020-08-31 20:28:08 +09:30
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
Alan Modra
d0ed6fddfa changelog PR fix
for the lack of a space
2020-08-30 23:00:26 +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
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
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
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