]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
3 years agoRISC-V/SiFive: Added SiFive custom cache control instructions. users/riscv/binutils-integration-branch
Nelson Chu [Mon, 27 Sep 2021 08:29:58 +0000 (01:29 -0700)] 
RISC-V/SiFive: Added SiFive custom cache control instructions.

According to the chapter 10 of the following U74-MC manual,
https://sifive.cdn.prismic.io/sifive/6d9a2510-2632-44f3-adb9-d0430f139372_sifive_coreip_U74MC_AXI4_rtl_v19_08p2p0_release_manual.pdf

and the implementations of freedom-metal,
https://github.com/sifive/freedom-metal/blob/v201908-branch/src/cache.c

* Encodings,
31-25   24-20 19-15 14-12  11-7  6-0
FUNCT7  RS2   RS1   FUNCT3 RD    OPCODE
1111110 00000 xxxxx 000    00000 1110011 CFLUSH.D.L1
1111110 00010 xxxxx 000    00000 1110011 CDISCARD.D.L1
1111110 00001 00000 000    00000 1110011 CFLUSH.I.L1

* Extension names,
xsfcflushdlone:   CFLUSH.D.L1.
xsfcdiscarddlone: CDISCARD.D.L1.
xsfcflushilone:   CFLUSH.I.L1.

* Vendor target triples,
For assembler, the target vendor is defined as TARGET_VENDOR in the
gas/config.h, but I don't see any related settings in bfd/config.h
and opcode/config.  Since we may have vendor relocations in the future,
and these relocation numbers may repeat, I add a new RISCV_TARGET_VENDOR
in the bfd/config.h for riscv.  The vendor name will be stored in the
bfd/cpu-riscv.c, so that all tools (gas, bfd, opcode, ...) can get
the vendor name from the configure setting.

If the --with-arch configure option, -march gas option and elf architecture
attributes are not set, then we will generate the default ISA string
according to the chosen target vendor.  For example, if you build the
binutils with the configure option, --target=riscv64-sifive-elf, then
the assembler will find the whole supported extension tables in the
bfd/elfxx-riscv.c, and generate the suitable ISA string.

bfd/
* configure.ac (RISCV_TARGET_VENDOR): Defined to store target_vendor,
only when the target is riscv*.
* config.in: Regenerated.
* configure: Regenerated.
* cpu-riscv.c (riscv_vendor_name): Defined to RISCV_TARGET_VENDOR.
* cpu-riscv.h (enum riscv_spec_class): Added VENDOR_SPEC_CLASS_SIFIVE.
* elfxx-riscv. (EXT_SIFIVE): Defined to choose the default extensions
for sifive.
(riscv_supported_vendor_sifive_ext): Added extensions for sifive cache
control instructions.
(riscv_supported_std_ext, riscv_all_supported_ext): Updated.
(riscv_get_default_ext_version): Updated.
(riscv_set_default_arch): Updated.
gas/
* config/tc-riscv.c (VENDOR_SIFIVE_EXT): Added.
(riscv_extended_subset_supports): Handle INSN_CLASS_XSF*.
(op_vendor_sifive_hash): Added to store sifive opcodes.
(md_begin): Init the op_vendor_sifive_hash.
(riscv_find_extended_opcode_hash): Find the opcodes from
op_vendor_sifive_hash.
* testsuite/gas/riscv/extended/sifive-insns.d: New testcase.
* testsuite/gas/riscv/extended/sifive-insns.s: Likewise.
include/
* opcode/riscv-opc-extended.h: Added opcodes for sifive cache
instructions.
* opcode/riscv.h (enum riscv_extended_insn_class): Added INSN_CLASS_XSF*.
opcodes/
* riscv-opc.c (riscv_vendor_sifive_opcodes): Added.
(riscv_extended_opcodes): Updated.

3 years agoRISC-V/rvv: Added zve* and zvl* extensions, and clarify the imply rules.
Nelson Chu [Mon, 4 Oct 2021 10:20:47 +0000 (18:20 +0800)] 
RISC-V/rvv: Added zve* and zvl* extensions, and clarify the imply rules.

* Recognized zve* and zvl* extensions.
  - zve*: zve64d, zve64f, zve64x, zve32f and zve32x.
  - zvl*: zvl32b, zvl64b, zvl128b, zvl256b, zvl512b, zvl1024b, zvl2048b,
          zvl4096b, zvl8192b, zvl16384b, zvl32768b and zvl65536b.

* Spec said that v requires f and d, zve64d requires d, zve64f and zve32f
  require f.  However, according to the issue 723,
  [https://github.com/riscv/riscv-v-spec/issues/723]

  The general rule is that extension names imply the things they require.
  Therefore, the current imply rules should be as follows,
  - v imply f and d.
  - zve64d imply d.
  - zve64f and zve32f imply f.
  - zvamo imply a.

  Besides, consider the implicit zve and zvl extensions,
  - v imply zve64d and zvl128b.
  - zve64* imply the corresponding zve32*.  For example, zve64f imply zve32f,
    and zve64x imply zve32x.
  - zve*d imply zve*f and zve*x.  For example, zve64d imply zve64f and zve64x.
  - zve*f imply zve*x.  For example, zve64f imply zve64x.
  - zve64* imply zvl64b, and zve32* imply zvl32b.
  - The larger zvl* imply all smaller zvl*.  For example, zvl128b imply zvl64b,
    and zvl32b.

  Therefore, "-march=rv64iv -misa-spec=20191213" will be
  "rv64i2p0_f2p0_d2p0_v1p0_zicsr2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0".
  Note: zicsr is the imply extension of f.

* For zve32x, the (segmant) load/store instructions are illegal when EEW is
  64.  Besides, vsew cannot be set to 64 by vsetvli when zve32* is enabled.

* For zvl*b extensions, we also need to enable either v or zve* extensions.
  Otherwise we should issue errors.

bfd/
* elfxx-riscv.c (riscv_implicit_subsets): Added imply rules for v,
zve* and zvl*b extensions.
(riscv_supported_std_z_ext): Added zve* and zvl*b extensions.
(riscv_parse_check_conflicts): The zvl*b extensions cannot be set
without v and zve* extensions.
gas/
* config/tc-riscv.c (riscv_extended_subset_supports): Handle zve*.
(my_getVsetvliExpression): vsew cannot be set to 64 by vsetvli
when zve32* is enabled.
(riscv_ip): The (segmant) loads and stores with EEW 64 cannot be
used when zve32x is enabled.
* testsuite/gas/riscv/extended/march-imply-v.d: New testcase.
* testsuite/gas/riscv/extended/march-imply-zve*.d: Likewise.
* testsuite/gas/riscv/extended/march-imply-zvl*b.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zve32x.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zve32x.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zve32x.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvl.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvl.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvamo.d: Removed
a-ext from -march since it will be added as implicit ext for zvamo.
* testsuite/gas/riscv/extended/vector-insns.d: Likewise.
include/
* opcode/riscv.h: Defined INSN_V_EEW64.
opcodes/
* riscv-opc.c (riscv_draft_opcodes): Added INSN_V_EEW64 for vector
loads and stores when the eew encodings are 64.

3 years agoRISC-V/rvv: Separate zvamo from v, and removed the zvlsseg extension name.
Nelson Chu [Tue, 15 Jun 2021 09:10:25 +0000 (17:10 +0800)] 
RISC-V/rvv: Separate zvamo from v, and removed the zvlsseg extension name.

* Separate zvamo from v extension with v1.0, but keep the implementations.

* Removed zvlsseg extension name as the vector segmant loads and stores
  are required (included) in v extension.

* Updated the versions of v and zvamo from draft v0.10 to frozen v1.0.

bfd/
* elfxx-riscv.c (riscv_supported_std_z_ext): Removed entry of zvlsseg.
gas/
* config/tc-riscv.c (riscv_extended_subset_supports): Changed
INSN_CLASS_V_OR_ZVAMO to INSN_CLASS_ZVAMO, and removed
INSN_CLASS_V_OR_ZVLSSEG.
(riscv_extended_csr_class_check): Updated since the name zvlsseg
is removed.
* testsuite/gas/riscv/extended/vector-insns-fail-zvamo.d: Changed
-march from rv32iav to rv32ia_zvamo.
* testsuite/gas/riscv/extended/vector-insns.d: Changed -march from
rv32iafv to rv32iafv_zvamo.
include/
* opcode/riscv.h (riscv_extended_insn_class): Changed
INSN_CLASS_V_OR_ZVAMO to INSN_CLASS_ZVAMO, and removed
INSN_CLASS_V_OR_ZVLSSEG.
opcodes/
* riscv-opc.c (riscv_draft_opcodes): Changed INSN_CLASS_V_OR_ZVAMO
to INSN_CLASS_ZVAMO since they are separated from v.  Also changed
INSN_CLASS_V_OR_ZVLSSEG to INSN_CLASS_V as they are included in v.

3 years agoRISC-V/rvv: Update constraints for widening and narrowing instructions.
Nelson Chu [Mon, 23 Aug 2021 07:46:53 +0000 (15:46 +0800)] 
RISC-V/rvv: Update constraints for widening and narrowing instructions.

* Since fractional LMUL is supported, we cannot just assume LMUL is 1.
  Otherwise, the old conflit checking rules may cause problems.

* Removed the overlap constraints for narrowing instructions.

gas/
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.d: Removed.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-widen.l: Updated.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-widen.s: Likewise.
opcodes/
* riscv-opc.c (match_vd_neq_vs1_neq_vm): Added for vw*.wv instructions.
(match_widen_vd_neq_vs1_neq_vs2_neq_vm): Replaced by match_vd_neq_vs1_neq_vs2_neq_vm.
(match_widen_vd_neq_vs1_neq_vm): Replaced by match_vd_neq_vs1_neq_vm.
(match_widen_vd_neq_vs2_neq_vm): Replaced by match_vd_neq_vs2_neq_vm.
(match_widen_vd_neq_vm): Replaced by match_vd_neq_vm.
(match_narrow_vd_neq_vs2_neq_vm): Same as match_widen_vd_neq_vs2_neq_vm.

3 years agoRISC-V/rvv: Added assembly pseudo and changed assembler mnemonics.
Nelson Chu [Tue, 15 Jun 2021 07:05:11 +0000 (15:05 +0800)] 
RISC-V/rvv: Added assembly pseudo and changed assembler mnemonics.

* Added pseudo instruction,

- vfabs.v vd,vs = vfsgnjx.vv vd,vs,vs

* Changed assembler mnemonics, and the older names kept as aliases,

- Changed from vle1.v to vlm.v, and vse1.v to vsm.v.
- Changed from vfredsum and vfwredsum to vfredusum and vfwredusum respectively.
- Changed from vpopc.m to vcpop.m, to be consistent with scalar instruction.
- Changed from vmandnot.mm and vmornot.mm to vmandn.mm and vmorn.mm.

gas/
* testsuite/gas/riscv/extended/vector-insns-fail-arith-floatp.l: Updated.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-floatp.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-vmsgtvx.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns.s: Likewise.
include/
* opcode/riscv-opc-extended.h: Updated.
opcodes/
* riscv-opc.c: Added pseudo vfabs.v, and changed assembler mnemonics.

3 years agoRISC-V/t-head: Add CSRs and opcodes of the T-HEAD XUANTIE CPUs
Lifang Xia [Tue, 7 Sep 2021 09:20:26 +0000 (17:20 +0800)] 
RISC-V/t-head: Add CSRs and opcodes of the T-HEAD XUANTIE CPUs

Add CSRs and opcodes of the XUANTIE CPUs, extensions named "theadc",
"xtheade" and "xtheadse".

New ARG format for operands:
"Xgm@n": encode GPR with m bit at opcode[m+n-1:n].
  "Xg5@0": encode GPR with 5 bit at opcode[4:0].
  "Xg5@8": encode GPR with 5 bit at opcode[12:8].

"XIm@n": m bits unsigned immediate at opcode[m+n-1:n].
  "XI5@0": 5 bits unsigned immediate at opcode[4:0].
  "XI4@8": 4 bits unsigned immediate at opcode[11:8].

"XSm@n": m bits signed immediate at opcode[m+n-1:n].
  "XS5@0": 5 bits signed immediate at opcode[4:0].
  "XS4@8": 4 bits signed immediate at opcode[11:8].

"XFm@n": m bits FR at opcode[m+n-1:n].
  "XF5@0": 5 bits FR at opcode[4:0].
  "XF5@0": 5 bits FR at opcode[4:0].

bfd/
* cpu-riscv.h (enum riscv_spec_class)
<VENDOR_SPEC_CLASS_THEAD>: New.
* elfxx-riscv.c (riscv_supported_vendor_thead_ext): New.
(riscv_all_supported_ext): Updated.
(riscv_get_default_ext_version): Updated.
gas/
* config/tc-riscv.c (VENDOR_THEAD_EXT): New.
(enum riscv_extended_csr_class) <CSR_CLASS_VENDOR_THEAD>: New.
(riscv_extended_subset_supports): Check subset: INSN_CLASS_THEAD*
(op_vendor_thead_hash): New, the hash of T-HEAD Xuantie's opcodes.
(riscv_csr_address): Skip check version for T-HEAD Xuantie CPUs.
(validate_riscv_extended_insn): Parsing T-HEAD opargs.
(md_begin): Init op_vendor_thead_hash.
(riscv_find_extended_opcode_hash): Search op_vendor_thead_hash.
(riscv_parse_extended_operands): Parsing T-HEAD opargs.
* testsuite/gas/riscv/extended/thead*: New testcases.
include/
* opcode/riscv-opc-extended.h: Add CSRs and opcode of the T-HEAD
XUANTIE CPUs.
* opcode/riscv.h (riscv_extended_insn_class)
<INSN_CLASS_THEADC>: New.
<INSN_CLASS_THEADC_OR_THEADE>: New.
<INSN_CLASS_THEADC_OR_THEADE_OR_THEADSE>: New.
<INSN_CLASS_THEADE>: New.
<INSN_CLASS_THEADSE>: New.
(*VENDOR_THEAD_*): T-HEAD IMM encoding.
opcodes/
* riscv-dis.c (print_extended_insn_args): Parsing T-HEAD opargs.
* riscv-opc.c (match_thead_rd1_rd2_neq_rs1): New.
(riscv_vendor_thead_opcodes): New.
(riscv_extended_opcodes): Add riscv_vendor_thead_opcodes.

3 years agoRISC-V/extended: Improve the gas/testsuite/gas/riscv/extended/extended.exp.
Nelson Chu [Mon, 13 Sep 2021 10:38:00 +0000 (18:38 +0800)] 
RISC-V/extended: Improve the gas/testsuite/gas/riscv/extended/extended.exp.

gas/
* testsuite/gas/riscv/extended/extended.exp: Updated.

3 years agoRISC-V: Support svinval extensions.
Nelson Chu [Thu, 22 Jul 2021 05:47:07 +0000 (13:47 +0800)] 
RISC-V: Support svinval extensions.

https://github.com/riscv/riscv-isa-manual/pull/668/files

There are five new instructions for svinval extension.  According to
the above draft spec, two of them (HINVAL.VVMA and HINVAL.GVMA) need
to enable the hypervisor extension.  But there is no implementation
of hypervisor extension in mainline, so let's consider the related
issues later.

                31..25  24..20 19..15 14..12 11...7 6..2  1..0
sinval.vma      0001011 rs2    rs1    000    00000  11100 11
sfence.w.inval  0001100 00000  00000  000    00000  11100 11
sfence.inval.ir 0001100 00001  00000  000    00000  11100 11
hinval.vvma     0011011 rs2    rs1    000    00000  11100 11
hinval.gvma     0111011 rs2    rs1    000    00000  11100 11

bfd/
* elfxx-riscv.c (riscv_supported_std_s_ext): Added svinval.
gas/
* config/tc-riscv.c (riscv_extended_subset_supports):
Handle INSN_CLASS_SVINVAL.
* testsuite/gas/riscv/extended/extended.exp: Updated.
* testsuite/gas/riscv/extended/svinval.d: Mew testcases.
* testsuite/gas/riscv/extended/svinval.s: Likewise.
include/
* opcode/riscv-opc-extended.h: Added encodings for svinval.
* opcode/riscv.h (riscv_extended_insn_class): Added INSN_CLASS_SVINVAL.
opcodes/
* riscv-opc.c (riscv_draft_opcodes): Added svinval instructions.

3 years agoRISC-V/zfh: Added big endian testcase for .float16 directive.
Nelson Chu [Mon, 10 May 2021 05:38:23 +0000 (13:38 +0800)] 
RISC-V/zfh: Added big endian testcase for .float16 directive.

gas/
    * testsuite/gas/riscv/extended/extended.exp: Updated.
    * testsuite/gas/riscv/extended/float16.s: Minor fix for sNaNh.
    * testsuite/gas/riscv/extended/float16-le.d: Updated and renamed
    from float16.d.
    * testsuite/gas/riscv/extended/float16-be.d: New testcase.

3 years agoRISC-V/zfh: Support .float16 directive for assembler.
Nelson Chu [Tue, 21 Apr 2020 06:42:20 +0000 (14:42 +0800)] 
RISC-V/zfh: Support .float16 directive for assembler.

This probably need to be sent to mainline rather than here.

gas/
    * config/tc-riscv.c (FLT_CHARS): Added h and H.
    (riscv_pseudo_table): Added .float16.
    * read.c (hex_float): Handle case 'h' and 'H'.
    * testsuite/gas/riscv/extended/extended.exp: Updated.
    * testsuite/gas/riscv/extended/float16.d: New testcase.
    * testsuite/gas/riscv/extended/float16.s: Likewise.

3 years agoRISC-V/zfh: Add half-precision floating-point v0.1 instructions.
Nelson Chu [Thu, 26 Mar 2020 10:38:27 +0000 (18:38 +0800)] 
RISC-V/zfh: Add half-precision floating-point v0.1 instructions.

This patch is porting from the following riscv github,
https://github.com/riscv/riscv-binutils-gdb/commits/rvv-1.0.x-zfh

And here is the draft zfh spec,
https://github.com/riscv/riscv-isa-manual/tree/zfh

bfd/
* elfxx-riscv.c (riscv_supported_std_z_ext): Added zfh.
(riscv_implicit_subset): Add implicit f and zicsr for zfh.
gas/
* config/tc-riscv.c (riscv_extended_subset_supports): Handle
INSN_CLASS*_ZFH.
(extended_macro): Handle M_FLH and M_FSH.
* testsuite/gas/riscv/extended/extended.exp: Updated.
* testsuite/gas/riscv/extended/fp-zfh-insns.d: New testcase.
* testsuite/gas/riscv/extended/fp-zfh-insns.s: Likewise.
include/
* opcode/riscv-opc-extended.h: Added zfh encoding macros
and DECLARE_INSN.
* opcode/riscv.h (enum riscv_extended_insn_class): Added INSN_CLASS*_ZFH.
(enum M_FLH, M_FSH): Added.
opcodes/
* riscv-opc.c (riscv_draft_opcodes): Added zfh instructions.

3 years agoRISC-V/rvv: Add rvv v0.10 instructions.
Nelson Chu [Fri, 19 Mar 2021 09:19:11 +0000 (17:19 +0800)] 
RISC-V/rvv: Add rvv v0.10 instructions.

2021-03-30  Jim Wilson  <jimw@sifive.com>
            Kito Cheng  <kito.cheng@sifive.com>
            Nelson Chu  <nelson.chu@sifive.com>

This patch is porting from the following riscv github,
https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x

And here is the vector draft spec,
https://github.com/riscv/riscv-v-spec

The match_func in opcodes/riscv-opc.c have many purposes.  One of them is
checking the instruction constraints.  But we got the request before that
the assembler constraint checkings break some hardware exception testcases,
which are written by assmebly code.  Therefore, we add new assembler options
and .option directives to let users can disable/enable the rvv constraints.
For now the constraints are disabled by default, but should we default
enable them for safety?  Besides, the match_func will return different
error constriant messages, so that we can report the details to users.
This should be more user-friendly.

bfd/
* elfxx-riscv.c (riscv_supported_std_ext): Updated the draft
version of v.
(riscv_supported_std_z_ext): Added draft zvamo and zvlsseg.
gas/
* config/tc-riscv.c (enum DRAFT_EXT): Added.
(enum riscv_extended_csr_class): Added CSR_CLASS_V for rvv CSRs.
(enum reg_extended_class): Added vector registers.
(op_draft_hash): Added draft hash table for rvv.
(md_begin): Init op_draft_hash and register hash for rvv.
(riscv_extended_subset_supports): Handle INSN_CLASS_V*.
(riscv_extended_csr_class_check): Handle CSR_CLASS_V.
(validate_riscv_extended_insn): Check if the rvv instructions are valid.
(riscv_find_extended_opcode_hash): Search instruction opcode from
op_draft_hash.
(vector_macro): Call macro_build to expand rvv macros into instructions.
(extended_macro_build): Handle rvv operands for macro_build.
(extended_macro): Handle M_VMSGE and M_VMSGEU.
(my_getVsetvliExpression): Similar to my_getVsetvliExpression, but used
for parsing vsetvli operands.
(riscv_parse_extended_operands): Handle rvv operands.  Pass &regno from
riscv_ip, otherwise we will get fail when parsing Vf operand for AMO VS3.
(riscv_ip): Add two new arguments to match_func, check_constraints and
&error.  We can disbale the match_func check by setting check_constraints
to zero; The part of match_func will set different error messages to the
&error, and them we can report more details to users.
(riscv_set_options, riscv_opts, s_riscv_option):  Add .option
checkconstraints and nocheckconstraints, to enable/disable the
match_func constraints checking.  Disable it by default.
(enum options, md_longopts, md_parse_option): Add assembler options
m[no-]check-constraints.
* testsuite/gas/riscv/extended/extended.exp: Updated.
* testsuite/gas/riscv/extended/extended-csr.d: New testcase for rvv CSRs.
* testsuite/gas/riscv/extended/extended-csr.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-fixp.d:
New testcase for rvv constriants.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-fixp.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-fixp.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-floatp.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-floatp.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-floatp.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-int.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-int.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-int.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-narrow.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-widen.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-widen.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-arith-widen.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-load-store.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-load-store.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-load-store.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-mask.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-mask.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-mask.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-permutation.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-permutation.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-permutation.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvamo.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvamo.l: Likewise.
* testsuite/gas/riscv/extended/vector-insns-fail-zvamo.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-vmsgtvx.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-vmsgtvx.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns-zero-imm.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns-zero-imm.s: Likewise.
* testsuite/gas/riscv/extended/vector-insns.d: Likewise.
* testsuite/gas/riscv/extended/vector-insns.s: Likewise.
include/
* opcode/riscv-opc-extended.h: Added rvv encoding macros and CSRs.
* opcode/riscv.h: Added rvv immediate encodings and fields.
(struct riscv_opcode): Updated match_func.
(enum riscv_extended_insn_class): Added INSN_CLASS_V*.
(enum M_VMSGE, M_VMSGEU): Added.
opcodes/
* riscv-dis.c (print_extended_insn_args): Handle rvv operands.
(riscv_disassemble_opcode): Updated match_func.
* riscv-opc.c (match_*): Updated since two new parameters.
(riscv_vecr_names_numeric): Added rvv register names.
(riscv_vecm_names_numeric): Added rvv mask register name.
(riscv_vsew, riscv_vlmul, riscv_vta, riscv_vma): Added for vsetvli.
(MASK_VD, MASK_VS1, MASK_VS2, MASK_VMASK): Added for rvv match_func.
(match_vs1_eq_vs2, match_vs1_eq_vs2_neq_vm, match_vd_eq_vs1_eq_vs2):
Added to check special register usage, cannot be disabled.
(match_widen_vd_neq_vs1_neq_vs2_neq_vm): The rvv constraint check,
can be disabled/enabled by m[no-]check-constraints or .option
[no]checkconstraints.
(match_widen_vd_neq_vs1_neq_vm): Likewise.
(match_widen_vd_neq_vs2_neq_vm): Likewise.
(match_widen_vd_neq_vm): Likewise.
(match_narrow_vd_neq_vs2_neq_vm): Likewise.
(match_vd_neq_vs1_neq_vs2): Likewise.
(match_vd_neq_vs1_neq_vs2_neq_vm): Likewise.
(match_vd_neq_vs2_neq_vm): Likewise.
(match_vd_neq_vm): Likewise.
(match_vls_nf_rv): Likewise.
(match_vmv_nf_rv): Likewise.
(riscv_draft_opcodes): Added rvv v0.10 instructions.
(riscv_extended_opcodes): Updated.

3 years agoRISC-V/extended: Add assembler and dis-assembler hooks for extended extensions.
Nelson Chu [Tue, 16 Mar 2021 09:23:23 +0000 (17:23 +0800)] 
RISC-V/extended: Add assembler and dis-assembler hooks for extended extensions.

To keep the original functions clean, we try to provide assembler
and dis-assembler hooks as enough as possible for extended extensions.
We probably need to add more once they are not enough in the future.
However, there are several changes that might need to be discussed
as follows,

* Change the type of enums to int directly, to extend them for
extended extensions.  Not sure if the change is good enough, but
it should be the easiler way to extend enums.

* The extended operands should be parsed in the extended hooks,
validate_riscv_extended_insn and riscv_parse_extended_operands.
Obviously, we may need to reparse the opernad string in the extended
hooks, when the original functions cannot recognize them.  But the
original functions have already pointed the parsed poniter to the
next characters.  Therefore, we should use a new pointer, opargStart,
to record the position before parsing, and then pass it to the hooks
when we need to reparse the extended operands.

* Part of the "internal: unknown" errors are reported in the extended
hooks rather than the original functions.  For example, we used to
report the "internal: unreachable" in the riscv_multi_subset_supports,
to tell developers that they forgot to handle the new defined INSN_CLASS_.
And the function returns TRUE/FALSE if the instruction is allowed or not
according to the architecture string.  The riscv_extended_subset_supports
is the extended hook of riscv_multi_subset_supports, so it also returns
a bfd_boolean to check the same thing.  But it is hard to know if the
INSN_CLASS_* is unknown from the same returned bfd_boolean, unless we add
another new flag, or we just move the error report to the hook directly.
I choose the latter for now, but it may cause the code of mainline and
integration branches are inconsistent, which may affect the difficulty
of the regular merge between these two branches.

The same inconsistent problem also happens in riscv_parse_extended_operands.
The hook only parse an operand rather than all, so it just has a switch
without a for loop.  We used to set "continue" to skip the loop in the
switch, but the extended hook doesn't need the "continue".  Perhaps we
should use a single while/for in the hooks to keep the code consistent,
then the regular merge may be more easiler.

* Rename the variables to the more meaningful names in the riscv_ip,
validate_riscv_insn and print_insn_args.
- oparg: Renamed from args, means the arguments in the opcode table.
- opargStart: Added to record the start of the argument.
- asarg: Renamed from s, means the arguments of assembly string.
- asargStart: Renamed from argsStart.

* Extract the part that parsing the instruction opcode from the
riscv_disassemble_insn, since we will need to call it for many times
to search multiple opcode tables.

gas/
* config/tc-riscv.c (enum EXTENDED_EXT_NUM): Added to choose the
right extended opcode hashes in the riscv_find_extended_opcode_hash.
(enum riscv_csr_class): Added CSR_CLASS_EXTENDED.
(enum reg_class): Added RCLASS_EXTENDED_NUM.
(enum reg_extended_class): Added to define extended registers.
(struct riscv_csr_extra): Changed enum riscv_csr_class to int,
to increase the expandability of enum.
(riscv_init_csr_hash): Likewise.
(riscv_find_opcode_hash): Handle more than one opcode hashes.
(md_begin): Included riscv-opc-extended.h to define extended CSR.
(init_ext_version_hash): Updated.
(riscv_get_default_ext_version): Likewise.
(md_assemble): Likewise.
(s_riscv_insn): Likewsie.
(riscv_after_parse_args): Likewise.
(riscv_find_extended_opcode_hash): Extended hook for
riscv_find_opcode_hash.
(riscv_extended_subset_supports): Extended hook for
riscv_multi_subset_supports.
(riscv_extended_csr_class_check): Extended hook for riscv_csr_address,
to check the CSR ISA dependency.
(extended_macro): Extended hook for macro.
(validate_riscv_extended_insn): Extended hook for validate_riscv_insn.
(extended_macro_build): Extended hook for macro_build.
(riscv_parse_extended_operands): Extended hook for riscv_ip.
(riscv_multi_subset_supports): Updated to call extended hook.
(riscv_csr_address): Likewise
(macro): Likewise.
(validate_riscv_insn): Likewise.  Also define new variables, xxx
and xxxStart, in case single letters are not enough to represent
all extended operands.
(macro_build): Likewise.
(riscv_ip): Likewise.  The asarg means assembly operand string,
and oparg means operand string defined in the opcode table.
* testsuite/gas/riscv/extended/extended.exp: New file to run
extended testcases.
include/
* opcode/riscv-opc-extended.h: New file to define encoding macros
and CSR for extended extensions.
* opcode/riscv.h: Included riscv-opc-extended.h.
(enum riscv_insn_class): Added INSN_CLASS_EXTENDED.
(struct riscv_opcode): Same as struct riscv_csr_extra.
(enum M_EXTENDED): Added to support extended pseudo macros.
opcode/
* riscv-dis.c (print_extended_insn_args): Extended hook for
print_insn_args.
(print_insn_args): Updated to call extended hook, and same as
what validate_riscv_insn does.  Also include riscv-opc-extended.h
to show extended CSR correctly.
* riscv-opc.c (riscv_extended_opcodes): Added to store all
supported extended instruction opcodes.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Oct 2021 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogold: Place .note.gnu.property section before other note sections
H.J. Lu [Mon, 25 Oct 2021 15:42:24 +0000 (08:42 -0700)] 
gold: Place .note.gnu.property section before other note sections

Place the .note.gnu.property section before all other note sections to
avoid being placed between other note sections with different alignments.

PR gold/28494
* layout.cc (Layout::create_note): Set order to ORDER_PROPERTY_NOTE
for the .note.gnu.property section.
* layout.h (Output_section_order): Add ORDER_PROPERTY_NOTE.

3 years ago[gdb/doc] Fix print inferior-events default
Tom de Vries [Tue, 26 Oct 2021 08:45:08 +0000 (10:45 +0200)] 
[gdb/doc] Fix print inferior-events default

In the docs about print inferior-events we read:
...
By default, these messages will not be printed.
...

That used to be the case, but is no longer so since commit f67c0c91715 "Enable
'set print inferior-events' and improve detach/fork/kill/exit messages".

Fix this by updating the docs.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Oct 2021 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb: change functions returning value contents to use gdb::array_view
Simon Marchi [Tue, 5 Oct 2021 00:47:06 +0000 (20:47 -0400)] 
gdb: change functions returning value contents to use gdb::array_view

The bug fixed by this [1] patch was caused by an out-of-bounds access to
a value's content.  The code gets the value's content (just a pointer)
and then indexes it with a non-sensical index.

This made me think of changing functions that return value contents to
return array_views instead of a plain pointer.  This has the advantage
that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view
are checked, making bugs more apparent / easier to find.

This patch changes the return types of these functions, and updates
callers to call .data() on the result, meaning it's not changing
anything in practice.  Additional work will be needed (which can be done
little by little) to make callers propagate the use of array_view and
reap the benefits.

[1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html

Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3

3 years agogdbsupport: add assertions in array_view
Simon Marchi [Tue, 19 Oct 2021 19:32:08 +0000 (15:32 -0400)] 
gdbsupport: add assertions in array_view

Add assertions to ensure we don't access an array_view out of bounds.
Enable these assertions only when _GLIBCXX_DEBUG is set, as we did for
gdb::optional.

Change-Id: Iffaee38252405073735ed123c8e57fde6b2c6be3

3 years agogdbserver: make target_pid_to_str return std::string
Simon Marchi [Mon, 25 Oct 2021 18:33:55 +0000 (14:33 -0400)] 
gdbserver: make target_pid_to_str return std::string

I wanted to write a warning that included two target_pid_to_str calls,
like this:

    warning (_("Blabla %s, blabla %s"),
     target_pid_to_str (ptid1),
     target_pid_to_str (ptid2));

This doesn't work, because target_pid_to_str stores its result in a
static buffer, so my message would show twice the same ptid.  Change
target_pid_to_str to return an std::string to avoid this.  I don't think
we save much by using a static buffer, but it is more error-prone.

Change-Id: Ie3f649627686b84930529cc5c7c691ccf5d36dc2

3 years agox86: Also handle stores for -muse-unaligned-vector-move
H.J. Lu [Sat, 23 Oct 2021 14:37:33 +0000 (07:37 -0700)] 
x86: Also handle stores for -muse-unaligned-vector-move

* config/tc-i386.c (encode_with_unaligned_vector_move): Also
handle stores.
* testsuite/gas/i386/unaligned-vector-move.s: Add stores.
* testsuite/gas/i386/unaligned-vector-move.d: Updated.
* testsuite/gas/i386/x86-64-unaligned-vector-move.d: Likewise.

3 years ago[gdb/testsuite] Fix duplicate in gdb.mi/mi-var-cp.exp
Tom de Vries [Mon, 25 Oct 2021 16:15:15 +0000 (18:15 +0200)] 
[gdb/testsuite] Fix duplicate in gdb.mi/mi-var-cp.exp

With test-case gdb.mi/mi-var-cp.exp I run into this duplicate:
...
PASS: gdb.mi/mi-var-cp.exp: run to mi-var-cp.cc:104 (set breakpoint)
PASS: gdb.mi/mi-var-cp.exp: create varobj for s
PASS: gdb.mi/mi-var-cp.exp: create varobj for s
DUPLICATE: gdb.mi/mi-var-cp.exp: create varobj for s
...

This is due to a duplicate test name here:
...
$ cat -n gdb/testsuite/gdb.mi/mi-var-cp.cc
  ...
   100  int reference_to_struct ()
   101  {
   102    /*: BEGIN: reference_to_struct :*/
   103    S s = {7, 8};
   104    S& r = s;
   105    /*:
   106      mi_create_varobj S s "create varobj for s"
   107      mi_create_varobj R r "create varobj for s"
...

Fix this by using "create varobj for r" instead.

Tested on x86_64-linux.

3 years agolibctf, ld: handle nonrepresentable types better
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)] 
libctf, ld: handle nonrepresentable types better

ctf_type_visit (used, among other things, by the type dumping code) was
aborting when it saw a nonrepresentable type anywhere: even a single
structure member with a nonrepresentable type caused an abort with
ECTF_NONREPRESENTABLE.  This is not useful behaviour, given that the
abort comes from a type-resolution we are only doing in order to
determine whether the type is a structure or union.  We know
nonrepresentable types can't be either, so handle that case and
pass the nonrepresentable type down.

(The added test verifies that the dumper now handles this case and
prints nonrepresentable structure members as it already does
nonrepresentable top-level types, rather than skipping the whole
structure -- or, without the previous commit, skipping the whole types
section.)

ld/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/nonrepresentable-member.*: New test.

libctf/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types.

3 years agolibctf: dump: do not stop dumping types on error
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)] 
libctf: dump: do not stop dumping types on error

If dumping of a single type fails, we obviously can't dump it; but just
as obviously this doesn't make the other types in the types section
invalid or undumpable.  So we should not propagate errors seen when
type-dumping, but rather ignore them and carry on, so we dump as many
types as we can (leaving out the ones we can't grok).

libctf/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* ctf-dump.c (ctf_dump_type): Do not abort on error.

3 years agobinutils, ld: make objdump --ctf's parameter optional
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)] 
binutils, ld: make objdump --ctf's parameter optional

ld by default (and always, unless adjusted with a hand-rolled linker
script) emits deduplicated CTF into the .ctf section.  But viewing
it needs you to explicitly tell objdump this: it doesn't default
its argument, even though what you always end up typing is
--ctf=.ctf.

This is annoying, so make the argument optional.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (usage): --ctf now has an optional argument.
(main): Adjust accordingly.
(dump_ctf): Default it.
* doc/ctf.options.texi: Adjust.

ld/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Likewise.
* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/cycle-1.d: Likewise.
* testsuite/ld-ctf/cycle-2.A.d: Likewise.
* testsuite/ld-ctf/cycle-2.B.d: Likewise.
* testsuite/ld-ctf/cycle-2.C.d: Likewise.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
* testsuite/ld-ctf/diag-cuname.d: Likewise.
* testsuite/ld-ctf/diag-parlabel.d: Likewise.
* testsuite/ld-ctf/enum-forward.d: Likewise.
* testsuite/ld-ctf/enums.d: Likewise.
* testsuite/ld-ctf/forward.d: Likewise.
* testsuite/ld-ctf/function.d: Likewise.
* testsuite/ld-ctf/nonrepresentable.d: Likewise.
* testsuite/ld-ctf/slice.d: Likewise.
* testsuite/ld-ctf/super-sub-cycles.d: Likewise.

3 years agobinutils: make objdump/readelf --ctf-parent actually useful
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)] 
binutils: make objdump/readelf --ctf-parent actually useful

This option has been present since the very early days of the
development of libctf as part of binutils, and it shows.  Back in the
earliest days, I thought we might handle ambiguous types by introducing
new ELF sections on the fly named things like .ctf.foo.c for ambiguous
types found only in foo.c, etc.  This turned out to be a terrible idea,
so we moved to using a CTF archive in the .ctf section which contained
all the CTF dictionaries -- but the --ctf-parent option in objdump and
readelf was never adjusted, and lingered as a mechanism to specify CTF
parent dictionaries in sections other than .ctf, even though the linker
has no way to produce parent dictionaries in different sections from
their children, libctf's ctf_open can't handle such split-up
parent/child dicts, and they are never found in the wild, emitted by GNU
ld or by any known third-party linking tool.

Meanwhile, the actually-useful ctf_link feature (albeit not used by ld)
which lets you remap the names of CTF archive members (so you can end up
with a parent archive member named something other than ".ctf", still
contained with all its children in a single .ctf section) had no support
in objdump or readelf: there was no way to tell them that these members
were parents, so all the types in the associated child dicts always
appeared corrupted, referencing nonexistent types from a parent objdump
couldn't find.

So adjust --ctf-parent so that rather than taking a section name it
takes a member name instead (if not specified, the name is ".ctf", which
is what GNU ld emits).  Because the option was always useless before
now, this is expected to have no backward-compatibility implications.

As part of this, we have to slightly adjust the code which skips the
archive member name if redundant: right now it skips it if it's ".ctf",
on the assumption that this name will almost always be at the start
of the objdump output and thus we'll end up with a shared dump
and then smaller, headed dumps for the per-TU child dicts; but if
the parent name has been changed, that won't be true any more.

So change the rules to "members named .ctf which appear first in the
first have their member name skipped".  Since we now need to count
members, move from ctf_archive_iter (for which passing in extra
parameters requires defining a new struct and is clumsy) to
ctf_archive_next, allowing us to just *call* dump_ctf_archive_member and
maintain a member count in the obvious way.  In the process we fix a
tiny difference between readelf and objdump: if a ctf_dump ever failed,
readelf skipped every later member, while objdump tried to keep going as
much as it could.  For a dumping tool the former is clearly preferable.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (usage): --ctf-parent now takes a name, not a section.
(dump_ctf): Don't open a separate section; use the parent_name in
ctf_dict_open instead.  Use ctf_archive_next, not ctf_archive_iter,
so we can pass down a member count.
(dump_ctf_archive_member): Add the member count; don't return
anything.  Import parents into children no matter what the
parent's name, while still avoiding displaying the header for the
common parent name of ".ctf".
* readelf.c (usage): Adjust similarly.
(dump_section_as_ctf): Likewise.
(dump_ctf_archive_member): Likewise.  Never stop iterating over
archive members, even if ctf_dump of one member fails.
* doc/ctf.options.texi: Adjust.

3 years agoobjdump doesn't accept -L option
Alan Modra [Mon, 25 Oct 2021 05:41:42 +0000 (16:11 +1030)] 
objdump doesn't accept -L option

A followup to commit ca0e11aa4b.

* objdump.c (main): Add 'L' to short options and sort them.

3 years agobfd_nonfatal_message, localise va_start
Alan Modra [Mon, 25 Oct 2021 05:12:40 +0000 (15:42 +1030)] 
bfd_nonfatal_message, localise va_start

Nothing to see here, just a little tidier.

* bucomm.c (bfd_nonfatal_message): Localise va_list args.

3 years agoubsan: _bfd_xcoff64_swap_aux_in left shift of negative value
Alan Modra [Mon, 25 Oct 2021 01:09:39 +0000 (11:39 +1030)] 
ubsan: _bfd_xcoff64_swap_aux_in left shift of negative value

* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Use bfd_vma for h.

3 years agoasan: evax_bfd_print_image buffer overflow
Alan Modra [Sun, 24 Oct 2021 23:45:59 +0000 (10:15 +1030)] 
asan: evax_bfd_print_image buffer overflow

* vms-alpha.c (evax_bfd_print_image): Sanity check printing of
"image activator fixup" section.
(evax_bfd_print_relocation_records): Sanity check buffer offsets.
(evax_bfd_print_address_fixups): Likewise.
(evax_bfd_print_reference_fixups): Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Oct 2021 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoasan: c4x, c54x coff_canonicalize_reloc buffer overflow
Alan Modra [Sun, 24 Oct 2021 09:57:06 +0000 (20:27 +1030)] 
asan: c4x, c54x coff_canonicalize_reloc buffer overflow

Sometimes the investigation of a fuzzing bug report leads into areas
you'd rather not go.  In this instance by the time I'd figured out the
real cause was a target variant that had never been properly supported
in binutils, the time needed to fix it was less than the time needed
to rip it out.

* coffcode.h (coff_set_alignment_hook): Call bfd_coff_swap_reloc_in
not coff_swap_reloc_in.
(coff_slurp_reloc_table): Likewise.  Don't use RELOC type.
(ticoff0_swap_table): Use coff_swap_reloc_v0_out and
coff_swap_reloc_v0_in.
* coffswap.h (coff_swap_reloc_v0_in, coff_swap_reloc_v0_out): New.
* coff-tic54x.c (tic54x_lookup_howto): Don't abort.
* coffgen.c (coff_get_normalized_symtab): Use PTR_ADD.
* bfd-in.h (PTR_ADD, NPTR_ADD): Avoid warnings when passing an
expression.
* bfd-in2.h: Regenerate.

3 years agoasan: arm-darwin: buffer overflow
Alan Modra [Sun, 24 Oct 2021 08:06:03 +0000 (18:36 +1030)] 
asan: arm-darwin: buffer overflow

PR 21813
* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Sanity
check PAIR reloc in other branch of condition as was done for
PR21813.  Formatting.  Delete debug printf.

3 years agoasan: aout: heap buffer overflow
Alan Modra [Sat, 23 Oct 2021 00:57:14 +0000 (11:27 +1030)] 
asan: aout: heap buffer overflow

* aoutx.h (aout_get_external_symbols): Sanity check before writing
zero index entry.  Remove outdated comment.
* pdp11.c (aout_get_external_symbols): Likewise.

3 years agoLoongArch ld support
liuzhensong [Fri, 22 Oct 2021 08:42:07 +0000 (16:42 +0800)] 
LoongArch ld support

2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
    Zhensong Liu  <liuzhensong@loongson.cn>
    Weinan Liu  <liuweinan@loongson.cn>
    Xiaolin Tang  <tangxiaolin@loongson.cn>

ld/
* Makefile.am: Add LoongArch.
* NEWS: Mention LoongArch support.
* configure.tgt: Add LoongArch.
* emulparams/elf32loongarch-defs.sh: New.
* emulparams/elf32loongarch.sh: Likewise.
* emulparams/elf64loongarch-defs.sh: Likewise.
* emulparams/elf64loongarch.sh: Likewise.
* emultempl/loongarchelf.em: Likewise.
* Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
ld/testsuite/
* ld-loongarch-elf/disas-jirl.d: New.
* ld-loongarch-elf/disas-jirl.s: Likewise.
* ld-loongarch-elf/jmp_op.d: Likewise.
* ld-loongarch-elf/jmp_op.s: Likewise.
* ld-loongarch-elf/ld-loongarch-elf.exp: Likewise.
* ld-loongarch-elf/macro_op.d: Likewise.
* ld-loongarch-elf/macro_op.s: Likewise.
* ld-loongarch-elf/syscall-0.s: Likewise.
* ld-loongarch-elf/syscall-1.s: Likewise.
* ld-loongarch-elf/syscall.d: Likewise.
* ld-srec/srec.exp: Add LoongArch.
* ld-unique/pr21529.d: Likewise.

3 years agoLoongArch gas support
liuzhensong [Fri, 22 Oct 2021 08:42:06 +0000 (16:42 +0800)] 
LoongArch gas support

2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
            Zhensong Liu  <liuzhensong@loongson.cn>
            Weinan Liu  <liuweinan@loongson.cn>
    Xiaolin Tang  <tangxiaolin@loongson.cn>

gas/
* Makefile.am: Add LoongArch.
* NEWS: Mention LoongArch support.
* config/loongarch-lex-wrapper.c: New.
* config/loongarch-lex.h: New.
* config/loongarch-lex.l: New.
* config/loongarch-parse.y: New.
* config/tc-loongarch.c: New.
* config/tc-loongarch.h: New.
* configure.ac: Add LoongArch.
* configure.tgt: Likewise.
* doc/as.texi: Likewise.
* doc/c-loongarch.texi: Likewise.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/POTFILES.in: Regenerate.
gas/testsuite/
* gas/all/gas.exp: Add LoongArch.
* gas/elf/elf.exp: Likewise.
* gas/loongarch/4opt_op.d: New.
* gas/loongarch/4opt_op.s: Likewise.
* gas/loongarch/fix_op.d: Likewise.
* gas/loongarch/fix_op.s: Likewise.
* gas/loongarch/float_op.d: Likewise.
* gas/loongarch/float_op.s: Likewise.
* gas/loongarch/imm_op.d: Likewise.
* gas/loongarch/imm_op.s: Likewise.
* gas/loongarch/jmp_op.d: Likewise.
* gas/loongarch/jmp_op.s: Likewise.
* gas/loongarch/load_store_op.d: Likewise.
* gas/loongarch/load_store_op.s: Likewise.
* gas/loongarch/loongarch.exp: Likewise.
* gas/loongarch/macro_op.d: Likewise.
* gas/loongarch/macro_op.s: Likewise.
* gas/loongarch/nop.d: Likewise.
* gas/loongarch/nop.s: Likewise.
* gas/loongarch/privilege_op.d: Likewise.
* gas/loongarch/privilege_op.s: Likewise.
* gas/loongarch/syscall.d: Likewise.
* gas/loongarch/syscall.s: Likewise.
* lib/gas-defs.exp: Add LoongArch.

3 years agoLoongArch binutils support
liuzhensong [Fri, 22 Oct 2021 08:42:05 +0000 (16:42 +0800)] 
LoongArch binutils support

2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
    Zhensong Liu  <liuzhensong@loongson.cn>
    Weinan Liu  <liuweinan@loongson.cn>
binutils/
* NEWS: Mention LoongArch support.
* readelf.c: Add LoongArch.
* testsuite/binutils-all/objdump.exp: Add LoongArch.

3 years agoLoongArch opcodes support
liuzhensong [Fri, 22 Oct 2021 08:42:04 +0000 (16:42 +0800)] 
LoongArch opcodes support

2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
    Zhensong Liu  <liuzhensong@loongson.cn>
    Weinan Liu  <liuweinan@loongson.cn>

include/
* opcode/loongarch.h: New.
* dis-asm.h: Declare print_loongarch_disassembler_options.
opcodes/
* Makefile.am: Add LoongArch.
* configure.ac: Likewise.
* disassemble.c: Likewise.
* disassemble.h: Declare print_insn_loongarch.
* loongarch-coder.c: New.
* loongarch-dis.c: New.
* loongarch-opc.c: New.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/POTFILES.in: Regenerate.

3 years agoLoongArch bfd support
liuzhensong [Fri, 22 Oct 2021 08:42:03 +0000 (16:42 +0800)] 
LoongArch bfd support

2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
    Zhensong Liu  <liuzhensong@loongson.cn>
    Weinan Liu  <liuweinan@loongson.cn>
bfd/
* Makefile.am: Add LoongArch.
* archures.c: Likewise.
* config.bfd: Likewise.
* configure.ac: Likewise.
* cpu-loongarch.c: New.
* elf-bfd.h: Add LoongArch.
* elf.c: Add LoongArch elfcore_grok_xxx.
* elfnn-loongarch.c: New.
* elfxx-loongarch.c: New.
* elfxx-loongarch.h: New.
* reloc.c: Add LoongArch BFD RELOC ENUM.
* targets.c: Add LoongArch target.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* configure: Regenerate.
* libbfd.h: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
* po/SRC-POTFILES.in: Regenerate.

include/
* elf/common.h: Add NT_LARCH_{CPUCFG,CSR,LSX,LASX}.
* elf/loongarch.h: New.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Oct 2021 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Oct 2021 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agox86: Add -muse-unaligned-vector-move to assembler
H.J. Lu [Thu, 21 Oct 2021 13:15:31 +0000 (06:15 -0700)] 
x86: Add -muse-unaligned-vector-move to assembler

Unaligned load/store instructions on aligned memory or register are as
fast as aligned load/store instructions on modern Intel processors.  Add
a command-line option, -muse-unaligned-vector-move, to x86 assembler to
encode encode aligned vector load/store instructions as unaligned
vector load/store instructions.

* NEWS: Mention -muse-unaligned-vector-move.
* config/tc-i386.c (use_unaligned_vector_move): New.
(encode_with_unaligned_vector_move): Likewise.
(md_assemble): Call encode_with_unaligned_vector_move for
-muse-unaligned-vector-move.
(OPTION_MUSE_UNALIGNED_VECTOR_MOVE): New.
(md_longopts): Add -muse-unaligned-vector-move.
(md_parse_option): Handle -muse-unaligned-vector-move.
(md_show_usage): Add -muse-unaligned-vector-move.
* doc/c-i386.texi: Document -muse-unaligned-vector-move.
* testsuite/gas/i386/i386.exp: Run unaligned-vector-move and
x86-64-unaligned-vector-move.
* testsuite/gas/i386/unaligned-vector-move.d: New file.
* testsuite/gas/i386/unaligned-vector-move.s: Likewise.
* testsuite/gas/i386/x86-64-unaligned-vector-move.d: Likewise.

3 years agoFix 'uninstall' target
Tom Tromey [Tue, 19 Oct 2021 18:44:56 +0000 (12:44 -0600)] 
Fix 'uninstall' target

This adds some missing code to the 'uninstall' targets in gdb and
gdbserver.  It also changes gdb's uninstall target so that it no
longer tries to remove any man page -- this is already done (and more
correctly) by doc/Makefile.in.

I tested this with 'make install' followed by 'make uninstall', then
examining the install tree for regular files.  Only the 'dir' file
remains, but this appears to just be how 'install-info' is intended to
work.

3 years agoRemove unused variables from gdbserver's Makefile
Tom Tromey [Tue, 19 Oct 2021 18:27:51 +0000 (12:27 -0600)] 
Remove unused variables from gdbserver's Makefile

This removes a number of unused variables from gdbserver's Makefile.
I found these while working on the subsequent patches, and figured it
would be cleaner to have a separate patch for the deletions.

3 years ago[gdb/testsuite] Fix gdb.threads/linux-dp.exp
Tom de Vries [Fri, 22 Oct 2021 15:46:43 +0000 (17:46 +0200)] 
[gdb/testsuite] Fix gdb.threads/linux-dp.exp

On openSUSE Tumbleweed with glibc-debuginfo installed I get:
...
 (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print
 where^M
 #0  print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M
 #1  0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M
 #2  0x00007ffff7d56b37 in start_thread (arg=<optimized out>) \
                          at pthread_create.c:435^M
 #3  0x00007ffff7ddb640 in clone3 () \
                          at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81^M
 (gdb) PASS: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit
...
while without debuginfo installed I get instead:
...
 (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print
 where^M
 #0  print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M
 #1  0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M
 #2  0x00007ffff7d56b37 in start_thread () from /lib64/libc.so.6^M
 #3  0x00007ffff7ddb640 in clone3 () from /lib64/libc.so.6^M
 (gdb) FAIL: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit
...

The problem is that the regexp used:
...
  "\(from .*libpthread\|at pthread_create\|in pthread_create\)"
...
expects the 'from' part to match libpthread, but in glibc 2.34 libpthread has
been merged into libc.

Fix this by updating the regexp.

Tested on x86_64-linux.

3 years ago[gdb/testsuite] Fix FAILs in gdb.mi/mi-breakpoint-changed.exp
Tom de Vries [Fri, 22 Oct 2021 15:42:37 +0000 (17:42 +0200)] 
[gdb/testsuite] Fix FAILs in gdb.mi/mi-breakpoint-changed.exp

Since commit e36788d1354 "[gdb/testsuite] Fix handling of nr_args < 3 in
mi_gdb_test" we run into:
...
PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: mi runto main
Expecting: ^(-break-insert -f pendfunc1[^M
]+)?((&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,\
  bkpt=\{number="2",type="breakpoint".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
-break-insert -f pendfunc1^M
^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",\
  addr="0x00007ffff7bd559e",func="pendfunc1",\
  file="gdb/testsuite/gdb.mi/pendshr1.c",\
  fullname="gdb/testsuite/gdb.mi/pendshr1.c",line="21",thread-groups=["i1"],\
  times="0",original-location="pendfunc1"}^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
  -break-insert -f pendfunc1 (unexpected output)
...

The regexp expects a breakpoint-created event, but that's actually suppressed
by the command:
...
DEF_MI_CMD_MI_1 ("break-insert", mi_cmd_break_insert,
                   &mi_suppress_notification.breakpoint),
...

Fix this by updating the regexp.

Likewise for the following:
...
PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
  -break-insert -f pendfunc1
Expecting: ^(-break-enable count 1 2[^M
]+)?(=breakpoint-modified,\
  bkpt=\{number="2",type="breakpoint",disp="dis",enabled="y".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
-break-enable count 1 2^M
^done^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
  -break-enable count 1 2 (unexpected out\
put)
...

Tested on x86_64-linux.

3 years agogdb/python: move gdb.Membuf support into a new file
Andrew Burgess [Thu, 16 Sep 2021 17:30:35 +0000 (18:30 +0100)] 
gdb/python: move gdb.Membuf support into a new file

In a future commit I'm going to be creating gdb.Membuf objects from a
new file within gdb/python/py*.c.  Currently all gdb.Membuf objects
are created directly within infpy_read_memory (as a result of calling
gdb.Inferior.read_memory()).

Initially I split out the Membuf creation code into a new function,
and left the new function in gdb/python/py-inferior.c, however, it
felt a little random that the Membuf creation code should live with
the inferior handling code.

So, then I moved all of the Membuf related code out into a new file,
gdb/python/py-membuf.c, the interface is gdbpy_buffer_to_membuf, which
wraps an array of bytes into a gdb.Membuf object.

Most of the code is moved directly from py-inferior.c with only minor
tweaks to layout and replacing NULL with nullptr, hence, I've left the
copyright date on py-membuf.c as 2009-2021 to match py-inferior.c.

Currently, the only user of this code is still py-inferior.c, but in
later commits this will change.

There should be no user visible changes after this commit.

3 years agogdb/python: new gdb.architecture_names function
Andrew Burgess [Wed, 15 Sep 2021 12:34:14 +0000 (13:34 +0100)] 
gdb/python: new gdb.architecture_names function

Add a new function to the Python API, gdb.architecture_names().  This
function returns a list containing all of the supported architecture
names within the current build of GDB.

The values returned in this list are all of the possible values that
can be returned from gdb.Architecture.name().

3 years agogdb: make disassembler fprintf callback a static member function
Andrew Burgess [Wed, 13 Oct 2021 17:18:12 +0000 (18:18 +0100)] 
gdb: make disassembler fprintf callback a static member function

The disassemble_info structure has four callbacks, we have three of
them as static member functions within gdb_disassembler, the fourth is
just a global static function.

However, this fourth callback, is still only used from the
disassemble_info struct, so there's no real reason for its special
handling.

This commit makes fprintf_disasm a static method within
gdb_disassembler.

There should be no user visible changes after this commit.

3 years agoRISC-V: Added ld testcase for pcgp relaxation.
Lewis Revill [Fri, 22 Oct 2021 03:32:46 +0000 (11:32 +0800)] 
RISC-V: Added ld testcase for pcgp relaxation.

Consider the the pcgp-relax-02 testcase,

        .text
        .globl _start
_start:
.L1:    auipc   a0, %pcrel_hi(data_a)
.L2:    auipc   a1, %pcrel_hi(data_b)
        addi    a0, a0, %pcrel_lo(.L1)
        addi    a1, a1, %pcrel_lo(.L2)

        .data
        .word 0x0
        .globl data_a
data_a:
        .word 0x1

        .section .rodata
        .globl data_b
data_b:
        .word 0x2

If the first auipc is deleted, but we are still building the pcgp
table (connect the high and low pcrel relocations), then there is
an aliasing issue that we need some way to disambiguate which of
the two symbols we are targeting.  Therefore, Palmer thought of a
way to use R_RISCV_DELETE to split this into two phases, so we
could resolve the addresses before creating the ambiguities.

This patch just add the ld testcase for the above case, in case we
have changed something but break this.

ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Renamed pcgp-relax
to pcgp-relax-01, and added pcgp-relax-02.
* testsuite/ld-riscv-elf/pcgp-relax-01.d: Renmaed from pcgp-relax.
* testsuite/ld-riscv-elf/pcgp-relax-01.s: Likewise.
* testsuite/ld-riscv-elf/pcgp-relax-02.d: New testcase.
* testsuite/ld-riscv-elf/pcgp-relax-02.s: Likewise.

3 years agoRISC-V: Don't separate pcgp relaxation to another relax pass.
Lewis Revill [Thu, 21 Oct 2021 03:15:47 +0000 (11:15 +0800)] 
RISC-V: Don't separate pcgp relaxation to another relax pass.

Commit abd20cb637008da9d32018b4b03973e119388a0a and
ebdcad3fddf6ec21f6d4dcc702379a12718cf0c4 introduced additional
complexity into the paths run by the RISC-V relaxation pass in order to
resolve the issue of accurately keeping track of pcrel_hi and pcrel_lo
pairs. The first commit split up relaxation of these relocs into a pass
which occurred after other relaxations in order to prevent the situation
where bytes were deleted in between a pcrel_lo/pcrel_hi pair, inhibiting
our ability to find the corresponding pcrel_hi relocation from the
address attached to the pcrel_lo.

Since the relaxation was split into two passes the 'again' parameter
could not be used to perform the entire relaxation process again and so
the second commit added a way to restart ldelf_map_segments, thus
starting the whole process again.

Unfortunately this process could not account for the fact that we were
not finished with the relaxation process so in some cases - such as the
case where code would not fit in a memory region before the
R_RISCV_ALIGN relocation was relaxed - sanity checks in generic code
would fail.

This patch fixes all three of these concerns by reverting back to a
system of having only one target relax pass but updating entries in the
table of pcrel_hi/pcrel_lo relocs every time any bytes are deleted. Thus
we can keep track of the pairs accurately, and we can use the 'again'
parameter to restart the entire target relax pass, behaving in the way
that generic code expects. Unfortunately we must still have an
additional pass to delay deleting AUIPC bytes to avoid ambiguity between
pcrel_hi relocs stored in the table after deletion. This pass can only
be run once so we may potentially miss out on relaxation opportunities
but this is likely to be rare.

https://sourceware.org/bugzilla/show_bug.cgi?id=28410

bfd/
* elfnn-riscv.c (riscv_elf_link_hash_table): Removed restart_relax.
(riscv_elf_link_hash_table_create): Updated.
(riscv_relax_delete_bytes): Moved after the riscv_update_pcgp_relocs.
Update the pcgp_relocs table whenever bytes are deleted.
(riscv_update_pcgp_relocs): Add function to update the section
offset of pcrel_hi and pcrel_lo, and also update the symbol value
of pcrel_hi.
(_bfd_riscv_relax_call): Need to update the pcgp_relocs table
when deleting codes.
(_bfd_riscv_relax_lui): Likewise.
(_bfd_riscv_relax_tls_le): Likewise.
(_bfd_riscv_relax_align): Once we've handled an R_RISCV_ALIGN,
we can't relax anything else, so set the sec->sec_flg0 to true.
Besides, we don't need to update the pcgp_relocs table at this
stage, so just pass NULL pointer as the pcgp_relocs table for
riscv_relax_delete_bytes.
(_bfd_riscv_relax_section): Use only one pass for all target
relaxations.
(_bfd_riscv_relax_delete): Likewise, we don't need to update
the pcgp_relocs table at this stage, and don't need to set
the `again' since restart_relax mechanism is abandoned.
(bfd_elfNN_riscv_restart_relax_sections): Removed.
(_bfd_riscv_relax_section): Updated.
* elfxx-riscv.h (bfd_elf32_riscv_restart_relax_sections): Removed.
(bfd_elf64_riscv_restart_relax_sections): Likewise.
ld/
* emultempl/riscvelf.em: Revert restart_relax changes and set
relax_pass to 3.
* testsuite/ld-riscv-elf/align-small-region.d: New testcase.
* testsuite/ld-riscv-elf/align-small-region.ld: Likewise.
* testsuite/ld-riscv-elf/align-small-region.s: Likewise.
* testsuite/ld-riscv-elf/restart-relax.d: Removed sine the
restart_relax mechanism is abandoned.
* testsuite/ld-riscv-elf/restart-relax.s: Likewise.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.

3 years agogdb: fix remote-sim.c build
Simon Marchi [Fri, 22 Oct 2021 04:13:43 +0000 (00:13 -0400)] 
gdb: fix remote-sim.c build

Commit 183be222907a ("gdb, gdbserver: make target_waitstatus safe")
broke the remote-sim.c build.  In fact, it does some wrong changes,
result of a bad sed invocation.

Fix it by adjusting the code to the new target_waitstatus API.

Change-Id: I3236ff7ef7681fc29215f68be210ff4263760e91

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Oct 2021 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb, gdbserver: make target_waitstatus safe
Simon Marchi [Thu, 21 Oct 2021 20:12:04 +0000 (16:12 -0400)] 
gdb, gdbserver: make target_waitstatus safe

I stumbled on a bug caused by the fact that a code path read
target_waitstatus::value::sig (expecting it to contain a gdb_signal
value) while target_waitstatus::kind was TARGET_WAITKIND_FORKED.  This
meant that the active union field was in fact
target_waitstatus::value::related_pid, and contained a ptid.  The read
signal value was therefore garbage, and that caused GDB to crash soon
after.  Or, since that GDB was built with ubsan, this nice error
message:

    /home/simark/src/binutils-gdb/gdb/linux-nat.c:1271:12: runtime error: load of value 2686365, which is not a valid value for type 'gdb_signal'

Despite being a large-ish change, I think it would be nice to make
target_waitstatus safe against that kind of bug.  As already done
elsewhere (e.g. dynamic_prop), validate that the type of value read from
the union matches what is supposed to be the active field.

 - Make the kind and value of target_waitstatus private.
 - Make the kind initialized to TARGET_WAITKIND_IGNORE on
   target_waitstatus construction.  This is what most users appear to do
   explicitly.
 - Add setters, one for each kind.  Each setter takes as a parameter the
   data associated to that kind, if any.  This makes it impossible to
   forget to attach the associated data.
 - Add getters, one for each associated data type.  Each getter
   validates that the data type fetched by the user matches the wait
   status kind.
 - Change "integer" to "exit_status", "related_pid" to "child_ptid",
   just because that's more precise terminology.
 - Fix all users.

That last point is semi-mechanical.  There are a lot of obvious changes,
but some less obvious ones.  For example, it's not possible to set the
kind at some point and the associated data later, as some users did.
But in any case, the intent of the code should not change in this patch.

This was tested on x86-64 Linux (unix, native-gdbserver and
native-extended-gdbserver boards).  It was built-tested on x86-64
FreeBSD, NetBSD, MinGW and macOS.  The rest of the changes to native
files was done as a best effort.  If I forgot any place to update in
these files, it should be easy to fix (unless the change happens to
reveal an actual bug).

Change-Id: I0ae967df1ff6e28de78abbe3ac9b4b2ff4ad03b7

3 years agogdbserver: initialize the members of lwp_info in-class
Simon Marchi [Tue, 28 Sep 2021 20:38:43 +0000 (16:38 -0400)] 
gdbserver: initialize the members of lwp_info in-class

Add a constructor to initialize the waitstatus members.  Initialize the
others in the class directly.

Change-Id: I10f885eb33adfae86e3c97b1e135335b540d7442

3 years agogdbserver: make thread_info non-POD
Simon Marchi [Tue, 28 Sep 2021 20:02:29 +0000 (16:02 -0400)] 
gdbserver: make thread_info non-POD

Add a constructor and a destructor.  The constructor takes care of the
initialization that happened in add_thread, while the destructor takes
care of the freeing that happened in free_one_thread.  This is needed to
make target_waitstatus non-POD, as thread_info contains a member of that
type.

Change-Id: I1db321b4de9dd233ede0d5c101950f1d6f1d13b7

3 years agoFix ARMv8.4 for hw watchpoint and breakpoint
Andrew Pinski [Thu, 21 Oct 2021 17:02:44 +0000 (17:02 +0000)] 
Fix ARMv8.4 for hw watchpoint and breakpoint

Just like my previoius patch for ARMv8.1 and v8.2 (49ecef2a7da2ee9df4),
this adds ARMv8.4 debug arch as being compatible for hw watchpoint
and breakpoints.

3 years agoRefactor code slightly in nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_c...
Andrew Pinski [Thu, 21 Oct 2021 16:57:36 +0000 (16:57 +0000)] 
Refactor code slightly in nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity)

Since the two locations which check the debug arch are the same code currently, it is
a good idea to factor it out to a new function and just use that function from
aarch64_linux_get_debug_reg_capacity. This is also the first step to support
ARMv8.4 debug arch.

3 years agoFixes for gdb.mi/mi-break.exp
Carl Love [Wed, 20 Oct 2021 00:02:09 +0000 (00:02 +0000)] 
Fixes for gdb.mi/mi-break.exp

Update the expected pattern for two of the tests.

Matching pattern \" doesn't work.  Use .*  to match the \* pattern.

3 years ago[gdb/tui] Fix breakpoint display functionality
Tom de Vries [Thu, 21 Oct 2021 15:48:07 +0000 (17:48 +0200)] 
[gdb/tui] Fix breakpoint display functionality

In commit 81e6b8eb208 "Make tui-winsource not use breakpoint_chain", a loop
body was transformed into a lambda function body:
...
-      for (bp = breakpoint_chain;
-           bp != NULL;
-           bp = bp->next)
+      iterate_over_breakpoints ([&] (breakpoint *bp) -> bool
...
and consequently:
- a continue was replaced by a return, and
- a final return was added.

Then in commit 240edef62f0 "gdb: remove iterate_over_breakpoints function", we
transformed back to a loop body:
...
-      iterate_over_breakpoints ([&] (breakpoint *bp) -> bool
+      for (breakpoint *bp : all_breakpoints ())
...
but without reverting the changes that introduced the two returns.

Consequently, breakpoints no longer show up in the tui source window.

Fix this by reverting the changes that introduced the two returns.

Build on x86_64-linux, tested with all .exp test-cases that contain
tuiterm_env.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28483

3 years agoFix test step-and-next-inline.cc
Carl Love [Wed, 13 Oct 2021 22:32:06 +0000 (22:32 +0000)] 
Fix test step-and-next-inline.cc

The test expect the runto_main to stop at the first line of the function.
Depending on the optimization level, gdb may stop in the prolog or after
the prolog at the first line.  To ensure the test stops at the first line
of main, have it explicitly stop at a break point on the first line of the
function.

On PowerPC, the test passes when compiled with no optimization but fails
with all levels of optimization due to gdb stopping in the prolog.

3 years agoFix latent Ada bug when accessing field offsets
Tom Tromey [Tue, 19 Oct 2021 19:10:27 +0000 (13:10 -0600)] 
Fix latent Ada bug when accessing field offsets

The "add accessors for field (and call site) location" patch caused a
gdb crash when running the internal AdaCore testsuite.  This turned
out to be a latent bug in ada-lang.c.

The immediate cause of the bug is that find_struct_field
unconditionally uses TYPE_FIELD_BITPOS.  This causes an assert for a
dynamic type.

This patch fixes the problem by doing two things.  First, it changes
find_struct_field to use a dummy value for the field offset in the
situation where the offset is not actually needed by the caller.  This
works because the offset isn't used in any other way -- only as a
result.

Second, this patch assures that calls to find_struct_field use a
resolved type when the offset is needed.  For
value_tag_from_contents_and_address, this is done by resolving the
type explicitly.  In ada_value_struct_elt, this is done by passing
nullptr for the out parameters when they are not needed (the second
call in this function already uses a resolved type).

Note that, while we believe the parent field probably can't occur at a
variable offset, the patch still updates this code path, just in case.

I've updated an existing test case to reproduce the crash.
I'm checking this in.

3 years ago-Waddress warning in ldelf.c
Alan Modra [Thu, 21 Oct 2021 08:48:34 +0000 (19:18 +1030)] 
-Waddress warning in ldelf.c

ldelf.c: In function 'ldelf_after_open':
ldelf.c:1049:43: warning: the comparison will always evaluate as 'true' for the address of 'elf_header' will never be NULL [-Waddress]
 1049 |           && elf_tdata (abfd)->elf_header != NULL
      |                                           ^~
In file included from ldelf.c:37:
../bfd/elf-bfd.h:1957:21: note: 'elf_header' declared here
 1957 |   Elf_Internal_Ehdr elf_header[1];      /* Actual data, but ref like ptr */

* ldelf.c (ldelf_after_open): Remove useless elf_header test.

3 years agoAvoid -Waddress warnings in readelf
Alan Modra [Thu, 21 Oct 2021 06:32:06 +0000 (17:02 +1030)] 
Avoid -Waddress warnings in readelf

Mainline gcc:
readelf.c: In function 'find_section':
readelf.c:349:8: error: the comparison will always evaluate as 'true' for the pointer operand in 'filedata->section_headers + (sizetype)((long unsigned int)i * 80)' must not be NULL [-Werror=address]
  349 |   ((X) != NULL                                                          \
      |        ^~
readelf.c:761:9: note: in expansion of macro 'SECTION_NAME_VALID'
  761 |     if (SECTION_NAME_VALID (filedata->section_headers + i)
      |         ^~~~~~~~~~~~~~~~~~

This will likely be fixed in gcc, but inline functions are nicer than
macros.

* readelf.c (SECTION_NAME, SECTION_NAME_VALID),
(SECTION_NAME_PRINT, VALID_SYMBOL_NAME, VALID_DYNAMIC_NAME),
(GET_DYNAMIC_NAME): Delete.  Replace with..
(section_name, section_name_valid, section_name_print),
(valid_symbol_name, valid_dynamic_name, get_dynamic_name): ..these
new inline functions.  Update use throughout file.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Oct 2021 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoPR28417, std::string no longer allows accepting nullptr_t
Alan Modra [Tue, 19 Oct 2021 23:39:57 +0000 (10:09 +1030)] 
PR28417, std::string no longer allows accepting nullptr_t

PR 28417
* incremental.cc (Sized_relobj_incr::do_section_name): Avoid
std:string undefined behaviour.
* options.h (Search_directory::Search_directory): Likewise.

3 years agoRe: PR27625, powerpc64 gold __tls_get_addr calls
Alan Modra [Tue, 19 Oct 2021 22:42:48 +0000 (09:12 +1030)] 
Re: PR27625, powerpc64 gold __tls_get_addr calls

My previous PR27625 patch had a problem or two.  For one, the error
"__tls_get_addr call lacks marker reloc" on processing some calls
before hitting a call without markers typically isn't seen.  Instead a
gold assertion fails.  Either way it would be a hard error, which
triggers on a file contained in libphobos.a when running the gcc
testsuite.  A warning isn't even appropriate since the call involved
is one built by hand without any of the arg setup relocations that
might result in linker optimisation.

So this patch reverts most of commit 0af4fcc25dd5, instead entirely
ignoring the problem of mis-optimising old-style __tls_get_addr calls
without marker relocs.  We can't handle them gracefully without
another pass over relocations before decisions are made about GOT
entries in Scan::global or Scan::local.  That seems too costly, just
to link object files from 2009.  What's more, there doesn't seem to be
any way to allow the libphobos explicit __tls_get_addr call, but not
old TLS sequences without marker relocs.  Examining instructions
before the __tls_get_addr call is out of the question: program flow
might reach the call via a branch.  Putting an R_PPC64_TLSGD marker
with zero sym on the call might be a solution, but current linkers
will then merrily optimise away the call!

PR gold/27625
* powerpc.cc (Powerpc_relobj): Delete no_tls_marker_, tls_marker_,
and tls_opt_error_ variables and accessors.  Remove all uses.

3 years agoUse std::string in print_one_catch_syscall
Tom Tromey [Sun, 3 Oct 2021 14:16:50 +0000 (08:16 -0600)] 
Use std::string in print_one_catch_syscall

This changes print_one_catch_syscall to use std::string, removing a
bit of manual memory management.

3 years agoUse unique_xmalloc_ptr in breakpoint
Tom Tromey [Sat, 2 Oct 2021 23:17:27 +0000 (17:17 -0600)] 
Use unique_xmalloc_ptr in breakpoint

This changes struct breakpoint to use unique_xmalloc_ptr in a couple
of spots, removing a bit of manual memory management.

3 years agoUse unique_xmalloc_ptr in bp_location
Tom Tromey [Sat, 2 Oct 2021 22:58:49 +0000 (16:58 -0600)] 
Use unique_xmalloc_ptr in bp_location

This changes struct bp_location to use a unique_xmalloc_ptr, removing
a bit of manual memory management.

3 years agoUse unique_xmalloc_ptr in watchpoint
Tom Tromey [Sat, 2 Oct 2021 22:49:54 +0000 (16:49 -0600)] 
Use unique_xmalloc_ptr in watchpoint

This changes struct watchpoint to use unique_xmalloc_ptr in a couple
of places, removing a bit of manual memory management.

3 years agoUse unique_xmalloc_ptr in exec_catchpoint
Tom Tromey [Sat, 2 Oct 2021 22:43:49 +0000 (16:43 -0600)] 
Use unique_xmalloc_ptr in exec_catchpoint

This changes struct exec_catchpoint to use a unique_xmalloc_ptr,
removing a bit of manual memory management.

3 years agoUse unique_xmalloc_ptr in solib_catchpoint
Tom Tromey [Sat, 2 Oct 2021 22:40:00 +0000 (16:40 -0600)] 
Use unique_xmalloc_ptr in solib_catchpoint

This changes struct solib_catchpoint to use a unique_xmalloc_ptr,
removing a bit of manual memory management.

3 years agoMake c-exp.y work with Bison 3.8+
Christian Biesinger [Fri, 8 Oct 2021 20:09:46 +0000 (16:09 -0400)] 
Make c-exp.y work with Bison 3.8+

When using Bison 3.8, we get this error:

    ../../gdb/c-exp.y:3455:1: error: 'void c_print_token(FILE*, int, YYSTYPE)' defined but not used [-Werror=unused-function]

That's because bison 3.8 removed YYPRINT support:
https://savannah.gnu.org/forum/forum.php?forum_id=10047

Accordingly, this patch only defines that function for Bison < 3.8.

Change-Id: I3cbf2f317630bb72810b00f2d9b2c4b99fa812ad

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Oct 2021 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years ago[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest
Tom de Vries [Tue, 19 Oct 2021 21:50:50 +0000 (23:50 +0200)] 
[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest

The test-case gdb.gdb/python-interrupts.exp:
- runs to captured_command_loop
- sets a breakpoint at set_active_ext_lang
- calls a python command
- verifies the command triggers the breakpoint
- sends a signal and verifies the result

The test-case is fragile, because (f.i. with -flto) it cannot be guaranteed
that captured_command_loop and set_active_ext_lang are available for setting
breakpoints.

Reimplement the test-case as unittest, using:
- execute_command_to_string to capture the output
- try/catch to catch the "Error while executing Python code" exception
- a new hook selftests::hook_set_active_ext_lang to raise the signal

Tested on x86_64-linux.

3 years agoCheck index in type::field
Tom Tromey [Mon, 18 Oct 2021 18:32:18 +0000 (12:32 -0600)] 
Check index in type::field

This changes gdb to check the index that is passed to type::field.
This caught one bug in the Ada code when running the test suite
(actually I found the bug first, then realized that the check would
have helped), so this patch fixes that as well.

Regression tested on x86-64 Fedora 34.

3 years agoFix Rust lex selftest when using libiconv
Tom Tromey [Thu, 30 Sep 2021 18:53:55 +0000 (12:53 -0600)] 
Fix Rust lex selftest when using libiconv

The Rust lex selftest fails on our Windows build.  I tracked this down
to a use of UTF-32 as a parameter to convert_between_encodings.  Here,
iconv_open succeeds, but the actual conversion of a tab character
fails with EILSEQ.  I suspect that "UTF-32" is being interpreted as
big-endian, as changing the call to use "UTF-32LE" makes it work.
This patch implements this fix.

3 years agoFix format_pieces selftest on Windows
Tom Tromey [Wed, 29 Sep 2021 18:51:15 +0000 (12:51 -0600)] 
Fix format_pieces selftest on Windows

The format_pieces selftest currently fails on Windows hosts.

The selftest doesn't handle the "%ll" -> "%I64" rewrite that the
formatter may perform, but also gdbsupport was missing a configure
check for PRINTF_HAS_LONG_LONG.  This patch fixes both issues.

3 years agoFix bug in dynamic type resolution
Tom Tromey [Fri, 24 Sep 2021 20:06:52 +0000 (14:06 -0600)] 
Fix bug in dynamic type resolution

A customer-reported problem led us to a bug in dynamic type
resolution.  resolve_dynamic_struct will recursively call
resolve_dynamic_type_internal, passing it the sub-object for the
particular field being resolved.  While it offsets the address here,
it does not also offset the "valaddr" -- the array of bytes describing
the memory.

This patch fixes the bug, by offsetting both.  A test case is included
that can be used to reproduce the bug.

3 years agoAlways use std::function for self-tests
Tom Tromey [Thu, 23 Sep 2021 19:09:48 +0000 (13:09 -0600)] 
Always use std::function for self-tests

Now that there is a register_test variant that accepts std::function,
it seems to me that the 'selftest' struct and accompanying code is
obsolete -- simply always using std::function is simpler.  This patch
implements this idea.

3 years agoFix PR gdb/17917 Lookup build-id in remote binaries
Daniel Black [Mon, 18 Oct 2021 06:06:47 +0000 (17:06 +1100)] 
Fix PR gdb/17917 Lookup build-id in remote binaries

GDB doesn't support loading debug files using build-id from remote
target filesystems.

This is the case when gdbserver attached to a process and a gdb target
remote occurs over tcp.

With this change we make build-id lookups possible:

    (gdb) show debug-file-directory
    The directory where separate debug symbols are searched for is "/usr/local/lib/debug".
    (gdb) set debug-file-directory /usr/lib/debug
    (gdb) show sysroot
    The current system root is "target:".
    (gdb) target extended-remote :46615
    Remote debugging using :46615
    warning: Can not parse XML target description; XML support was disabled at compile time
    Reading /usr/sbin/mariadbd from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
    Reading /usr/sbin/mariadbd from remote target...
    Reading symbols from target:/usr/sbin/mariadbd...
    Reading /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading symbols from target:/usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug...
    Reading /lib/x86_64-linux-gnu/libpcre2-8.so.0 from remote target...
    ...

Before this change, the lookups would have been (GNU gdb (GDB) Fedora 10.2-3.fc34):

    (gdb) target extended-remote :46615
    Remote debugging using :46615
    Reading /usr/sbin/mariadbd from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
    Reading /usr/sbin/mariadbd from remote target...
    Reading symbols from target:/usr/sbin/mariadbd...
    Reading /usr/sbin/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading /usr/sbin/.debug/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading /usr/lib/debug//usr/sbin/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading /usr/lib/debug/usr/sbin//0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Reading target:/usr/lib/debug/usr/sbin//0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target...
    Missing separate debuginfo for target:/usr/sbin/mariadbd
    Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug
    (No debugging symbols found in target:/usr/sbin/mariadbd)

Observe it didn't look for
/usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug
on the remote target (where it is) and expected them to be installed
locally.

As a minor optimization, this also changes the build-id lookup such that
if sysroot is empty, no second lookup of the same location is performed.

Change-Id: I5181696d271c325a25a0805a8defb8ab7f9b3f55
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17917

3 years agoFix a potential illegal memory access when testing for a special LTO symbol name.
Nick Clifton [Tue, 19 Oct 2021 15:02:49 +0000 (16:02 +0100)] 
Fix a potential illegal memory access when testing for a special LTO symbol name.

bfd * linker.c (_bfd_generic_link_add_one_symbol): Test for a NULL
name before checking to see if the symbol is __gnu_lto_slim.
* archive.c (_bfd_compute_and_write_armap): Likewise.
binutils
* nm.c (filter_symbols): Test for a NULL name before checking to
see if the symbol is __gnu_lto_slim.
* objcopy.c (filter_symbols): Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Oct 2021 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoCTF: incorrect underlying type setting for enumeration types
Weimin Pan [Mon, 18 Oct 2021 18:15:21 +0000 (14:15 -0400)] 
CTF: incorrect underlying type setting for enumeration types

A bug was filed against the incorrect underlying type setting for
an enumeration type, which was caused by a copy and paste error.
This patch fixes the problem by setting it by calling objfile_int_type,
which was originally dwarf2_per_objfile::int_type, with ctf_type_size bits.
Also add error checking on ctf_func_type_info call.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Oct 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoPR28459, readelf issues bogus warning
Alan Modra [Sun, 17 Oct 2021 07:04:46 +0000 (17:34 +1030)] 
PR28459, readelf issues bogus warning

I'd missed the fact that the .debug_rnglists dump doesn't exactly
display the contents of the section.  Instead readelf rummages through
.debug_info looking for DW_AT_ranges entries, then displays the
entries in .debug_rnglists pointed at, sorted.  A simpler dump of the
actual section contents might be more useful and robust, but it was
likely done that way to detect overlap and holes.

Anyway, the headers in .debug_rnglists besides the first are ignored,
and limiting to the unit length of the first header fails if there is
more than one unit.

PR 28459
* dwarf.c (display_debug_ranges): Don't constrain data to length
in header.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Oct 2021 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agold: Adjust pr28158.rd for glibc 2.34
H.J. Lu [Sat, 16 Oct 2021 15:12:25 +0000 (08:12 -0700)] 
ld: Adjust pr28158.rd for glibc 2.34

Adjust pr28158.rd for glibc 2.34:

$ readelf -W --dyn-syms tmpdir/pr28158

Symbol table '.dynsym' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.34 (2)
     2: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     3: 000000000040401c     4 OBJECT  GLOBAL DEFAULT   23 foo@VERS_2.0 (3)
$

vs older glibc:

$ readelf -W --dyn-syms tmpdir/pr28158

Symbol table '.dynsym' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (3)
     2: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     3: 000000000040401c     4 OBJECT  GLOBAL DEFAULT   23 foo@VERS_2.0 (2)

$

* testsuite/ld-elf/pr28158.rd: Adjusted for glibc 2.34.

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Oct 2021 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 Oct 2021 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoPowerpc: Add support for openat and fstatat syscalls
Carl Love [Wed, 13 Oct 2021 20:28:48 +0000 (20:28 +0000)] 
Powerpc: Add support for openat and fstatat syscalls

[gdb] update ppc-linux-tdep.c

Add argument to ppc_canonicalize_syscall for the wordsize.
Add syscall entries for the openat and fstatat system calls.

3 years ago[gdb/testsuite] Add .debug_loc support in dwarf assembler
Tom de Vries [Thu, 14 Oct 2021 14:58:21 +0000 (16:58 +0200)] 
[gdb/testsuite] Add .debug_loc support in dwarf assembler

Add .debug_loc support in the dwarf assembler, and use it in new test-case
gdb.dwarf2/loc-sec-offset.exp (which is based on
gdb.dwarf2/loclists-sec-offset.exp).

Tested on x86_64-linux.

3 years ago[GOLD] Re: PowerPC64: Don't pretend to support multi-toc
Alan Modra [Thu, 14 Oct 2021 06:31:06 +0000 (17:01 +1030)] 
[GOLD] Re: PowerPC64: Don't pretend to support multi-toc

We can't get at section->address() until everything is laid out, so
trying to generalise the offset calculation rather than using a value
of 0x8000 (the old object->toc_base_offset()) was bound to fail.
got->g_o_t() is a little better than a hard-coded 0x8000.

* powerpc.cc (Target_powerpc::Scan::local, global): Don't use
toc_pointer() here.

3 years ago[GOLD] Two GOT sections for PowerPC64
Alan Modra [Fri, 8 Oct 2021 23:33:21 +0000 (10:03 +1030)] 
[GOLD] Two GOT sections for PowerPC64

Split .got into two piece, one with the header and entries for small
model got entries, the other with entries for medium/large model got
entries.  The idea is to better support mixed pcrel/non-pcrel code
where non-pcrel small-model .toc entries need to be within 32k of the
toc pointer.

* target.h (Target::tls_offset_for_local): Add got param.
(Target::tls_offset_for_global): Likewise.
(Target::do_tls_offset_for_local, do_tls_offset_for_global): Likewise.
* output.h (Output_data_got::Got_entry::write): Add got param.
* output.cc (Output_data_got::Got_entry::write): Likewise, pass to
tls_offset_for_local/global calls.
(Output_data_got::do_write): Adjust to suit.
* s390.cc (Target_s390::do_tls_offset_for_local): Likewise.
(Target_s390::do_tls_offset_for_global): Likewise.
* powerpc.cc (enum Got_type): Extend with small types, move from
class Target_powerpc.
(Target_powerpc::biggot_): New.
(Traget_powerpc::do_tls_offset_for_local, do_tls_offset_for_global,
got_size, got_section, got_base_offset): Handle biggot_.
(Target_powerpc::do_define_standard_symbols): Adjust.
(Target_powerpc::make_plt_section, do_finalize_sections): Likewise.
(Output_data_got_powerpc::Output_data_got_powerpc): Only make
64-bit header for small got section.
(Output_data_got_powerpc::g_o_t): Only return a result for small
got section.
(Output_data_got_powerpc::write): Only write small got section
header.
(Target_powerpc::Scan::local, global): Select small/big Got_type
and section to suit reloc.
(Target_powerpc::Relocate::relocate): Similarly.
(Sort_toc_sections): Rewrite.

3 years ago[GOLD] PowerPC64: Don't pretend to support multi-toc
Alan Modra [Tue, 12 Oct 2021 09:15:13 +0000 (19:45 +1030)] 
[GOLD] PowerPC64: Don't pretend to support multi-toc

Code in powerpc.cc is pretending to support a per-object toc pointer
value, but powerpc gold has no real support for multi-toc.  This patch
removes the pretense, tidying quite a lot in preparation for a
followup patch.  If multi-toc is ever to be supported, don't revert
this patch but start by adding object parameter to toc_pointer() and
an object to Branch_stub_key.

* powerpc.cc (Powerpc_relobj::toc_base_offset): Delete.
(Target_powerpc::toc_pointer): New function.  Use throughout.
(Target_powerpc::got_base_offset): New function.  Use throughout..
(Output_data_got_powerpc::got_base_offset): ..in place of
this.  Delete.
(Output_data_got_powerpc::Output_data_got_powerpc): Init
header_index_ to -1u for 64-bit, and make header here.
(Output_data_got_powerpc::set_final_data_size, reserve_ent): Don't
make 64-bit header here.
(Output_data_got_powerpc::g_o_t): Return toc pointer offset in
section for 64-bit.  Use throughout.
(Stub_table): Remove toc_base_off_ from Branch_stub_key, and
object param on add_long_branch_entry and find_long_branch_entry.
Adjust all uses.

3 years agoRe: s12z/disassembler: call memory_error_func when appropriate
Alan Modra [Thu, 14 Oct 2021 02:36:16 +0000 (13:06 +1030)] 
Re: s12z/disassembler: call memory_error_func when appropriate

Adjust for commit ba7c18a48457.

* testsuite/gas/s12z/truncated.d: Update expected output.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 Oct 2021 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years ago[gdb/exp] Improve <error reading variable> message
Tom de Vries [Wed, 13 Oct 2021 19:35:49 +0000 (21:35 +0200)] 
[gdb/exp] Improve <error reading variable> message

When printing a variable x in a subroutine foo:
...
subroutine foo (x)
  integer(4) :: x (*)
  x(3) = 1
end subroutine foo
...
where x is an array with unknown bounds, we get:
...
$ gdb -q -batch outputs/gdb.fortran/array-no-bounds/array-no-bounds \
  -ex "break foo" \
  -ex run \
  -ex "print x"
Breakpoint 1 at 0x4005cf: file array-no-bounds.f90, line 18.

Breakpoint 1, foo (x=...) at array-no-bounds.f90:18
18        x(3) = 1
$1 = <error reading variable>
...

Improve the error message by printing the details of the error, such that we
have instead:
...
$1 = <error reading variable: failed to get range bounds>
...

This is a change in gdb/valprint.c, and grepping through the sources reveals
that this is a common pattern.

Tested on x86_64-linux.

3 years agoPPC fix for stfiwx instruction (and additional stores with primary opcode of 31)
Carl Love [Fri, 8 Oct 2021 22:54:05 +0000 (22:54 +0000)] 
PPC fix for stfiwx instruction (and additional stores with primary opcode of 31)

[gdb] Fix address being recorded in rs6000-tdep.c, ppc_process_record_op31.

The GDB record function was recording the variable addr that was passed in
rather than the calculated effective address (ea) by the
ppc_process_record_op31 function.