Commit Graph

17194 Commits

Author SHA1 Message Date
jiawei
3d1cafa0c6 RISC-V: Scalar crypto instructions and operand set.
Add instructions in k-ext, some instruction in zbkb, zbkc is reuse from
zbb,zbc, we just change the class attribute to make them both support.
The 'aes64ks1i' and 'aes64ks2' instructions are present in both the Zknd
and Zkne extensions on rv64.  Add new operand letter 'y' to present 'bs'
symbol and 'Y' to present 'rnum' symbolc  for zkn instructions.  Also add
a new Entropy Source CSR define 'seed' located at address 0x015.

bfd/
	* elfxx-riscv.c (riscv_multi_subset_supports): Added support for
	crypto extension.
gas/
	*config/tc-riscv.c (enum riscv_csr_class): Added CSR_CLASS_ZKR.
	(riscv_csr_address): Checked for CSR_CLASS_ZKR.
	(validate_riscv_insn): Added y and Y for bs and rnum operands.
	(riscv_ip): Handle y and Y operands.
include/
	* opcode/riscv-opc.h: Added encodings of crypto instructions.
	Also defined new csr seed, which address is 0x15.
	* opcode/riscv.h: Defined OP_* and INSN_CLASS_* for crypto.
opcodes/
	* riscv-dis.c (print_insn_args): Recognized new y and Y operands.
	* riscv-opc.c (riscv_opcodes): Added crypto instructions.
2021-11-16 11:47:55 +08:00
jiawei
dfdba09776 RISC-V: Minimal support of scalar crypto extension.
Minimal support of scalar crypto extension, add "k" in the
riscv_supported_std_ext, to make the order check right with
"zk" behind "zb".

bfd/
	* elfxx-riscv.c (riscv_implicit_subsets): Added implicit
	rules for zk* extensions.
	(riscv_supported_std_ext): Added entry for k.
	(riscv_supported_std_z_ext): Added entries for zk*.
2021-11-16 11:47:50 +08:00
GDB Administrator
00855fe7cd Automatic date update in version.in 2021-11-16 00:00:06 +00:00
Clément Chigot
eae06bb301 COFF: avoid modifications over C_FILE filename aux entries.
Commit e86fc4a5bc ("PR 28447: implement multiple parameters for .file
on XCOFF") introduces C_FILE entries which can store additional
information.
However, some modifications are needed by them but not by the original
C_FILE entries, usually representing the filename.
This patch ensures that filename entries are kept as is, in order to
protect targets not supporting the additional entries.

	* coffgen.c (coff_write_symbol): Protect filename entries
	(coff_write_symbols): Likewise.
	(coff_print_symbol): Likewise.
2021-11-15 23:07:11 +10:30
Alan Modra
7aba54da42 PowerPC64 @notoc in non-power10 code
R_PPC64_REL24_P9NOTOC is a variant of R_PPC64_REL24_NOTOC for use on
@notoc cals from non-power10 code in the rare case that using such a
construct is useful.  R_PPC64_REL24_P9NOTOC will be emitted by gas
rather than R_PPC64_REL24_NOTOC when @notoc is used in a branch
instruction if power10 instructions are not enabled at that point.
The new relocation tells the linker to not use power10 instructions on
any stub emitted for that branch, unless overridden by
--power10-stubs=yes.

The current linker heuristic of only generating power10 instructions
for stubs if power10-only relocations are detected, continues to be
used.

include/
	* elf/ppc64.h (R_PPC64_REL24_P9NOTOC): Define.
bfd/
	* reloc.c (BFD_RELOC_PPC64_REL24_P9NOTOC): Define.
	* elf64-ppc.c (ppc64_elf_howto_raw): Add entry for new reloc.
	(ppc64_elf_reloc_type_lookup): Handle it.
	(enum ppc_stub_type): Delete.
	(enum ppc_stub_main_type, ppc_stub_sub_type): New.
	(struct ppc_stub_type): New.
	(struct ppc_stub_hash_entry): Use the above new type.
	(struct ppc_link_hash_table): Update stub_count.
	(is_branch_reloc, ppc64_elf_check_relocs),
	(toc_adjusting_stub_needed): Handle new reloc.
	(stub_hash_newfunc, select_alt_stub, ppc_merge_stub),
	(ppc_type_of_stub, plt_stub_size, build_plt_stub),
	(build_tls_get_addr_head, build_tls_get_addr_tail),
	(ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_size_stubs),
	(ppc64_elf_build_stubs, ppc64_elf_relocate_section): Handle new
	reloc.  Modify stub handling to suit new scheme.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): When power10 is not enabled
	return BFD_RELOC_PPC64_REL24_P9NOTOC for @notoc.
	(fixup_size, ppc_force_relocation, ppc_fix_adjustable): Handle
	BFD_RELOC_PPC64_REL24_P9NOTOC.
ld/
	* testsuite/ld-powerpc/callstub-2.s: Add .machine power10.
2021-11-15 12:20:13 +10:30
GDB Administrator
cb2e519a5e Automatic date update in version.in 2021-11-15 00:00:22 +00:00
GDB Administrator
9d6a1a6496 Automatic date update in version.in 2021-11-14 00:00:13 +00:00
GDB Administrator
b9252d079a Automatic date update in version.in 2021-11-13 00:00:24 +00:00
GDB Administrator
d31028e8cc Automatic date update in version.in 2021-11-12 00:00:17 +00:00
Nelson Chu
f786c359c1 RISC-V: Dump objects according to the elf architecture attribute.
For now we should always generate the elf architecture attribute both for
elf and linux toolchains, so that we could dump the objects correctly
according to the generated architecture string.  This patch resolves the
problem that we probably dump an object with c.nop instructions, but
in fact the c extension isn't allowed.  Consider the following case,

nelson@LAPTOP-QFSGI1F2:~/test$ cat temp.s
.option norvc
.option norelax
.text
add     a0, a0, a0
.byte   0x1
.balign 16
nelson@LAPTOP-QFSGI1F2:~/test$ ~/binutils-dev/build-elf32-upstream/build-install/bin/riscv32-unknown-elf-as temp.s -o temp.o
nelson@LAPTOP-QFSGI1F2:~/test$ ~/binutils-dev/build-elf32-upstream/build-install/bin/riscv32-unknown-elf-objdump -d temp.o

temp.o:     file format elf32-littleriscv

Disassembly of section .text:

00000000 <.text>:
   0:   00a50533                add     a0,a0,a0
   4:   01                      .byte   0x01
   5:   00                      .byte   0x00
   6:   0001                    nop
   8:   00000013                nop
   c:   00000013                nop
nelson@LAPTOP-QFSGI1F2:~/test$ ~/binutils-dev/build-elf32-upstream/build-install/bin/riscv32-unknown-elf-readelf -A temp.o
Attribute Section: riscv
File Attributes
  Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0"

The c.nop at address 0x6 is generated for alignment, but since the rvc isn't
allowed for this object, dump it as a c.nop instruction looks wrong.  After
applying this patch, I get the following result,

nelson@LAPTOP-QFSGI1F2:~/test$ ~/binutils-dev/build-elf32-upstream/build-install/bin/riscv32-unknown-elf-objdump -d temp.o

temp.o:     file format elf32-littleriscv

Disassembly of section .text:

00000000 <.text>:
   0:   00a50533                add     a0,a0,a0
   4:   01                      .byte   0x01
   5:   00                      .byte   0x00
   6:   0001                    .2byte  0x1
   8:   00000013                nop
   c:   00000013                nop

For the current objdump, we dump data to .byte/.short/.word/.dword, and
dump the unknown or unsupported instructions to .2byte/.4byte/.8byte, which
respectively are 2, 4 and 8 bytes instructions.  Therefore, we shouldn't
dump the 0x0001 as a c.nop instruction in the above case, we should dump
it to .2byte 0x1 as a unknown instruction, since the rvc is disabled.

However, consider that some people may use the new objdump to dump the old
objects, which don't have any elf attributes.  We usually set the default
architecture string to rv64g by bfd/elfxx-riscv.c:riscv_set_default_arch.
But this will cause rvc instructions to be unrecognized.  Therefore, we
set the default architecture string to rv64gc for disassembler, to keep
the previous behavior.

This patch pass the riscv-gnu-toolchain gcc/binutils regressions for
rv32emc-elf, rv32gc-linux, rv32i-elf, rv64gc-elf and rv64gc-linux
toolchains.  Also, tested by --enable-targets=all and can build
riscv-gdb successfully.

bfd/
	* elfnn-riscv.c (riscv_merge_arch_attr_info): Tidy the
	codes for riscv_parse_subset_t setting.
	* elfxx-riscv.c (riscv_get_default_ext_version): Updated.
	(riscv_subset_supports): Moved from gas/config/tc-riscv.c.
	(riscv_multi_subset_supports): Likewise.
	* elfxx-riscv.h: Added extern for riscv_subset_supports and
	riscv_multi_subset_supports.
gas/
	* config/tc-riscv.c (riscv_subset_supports): Moved to
	bfd/elfxx-riscv.c.
	(riscv_multi_subset_supports): Likewise.
	(riscv_rps_as): Defined for architectrue parser.
	(riscv_set_arch): Updated.
	(riscv_set_abi_by_arch): Likewise.
	(riscv_csr_address): Likewise.
	(reg_lookup_internal): Likewise.
	(riscv_ip): Likewise.
	(s_riscv_option): Updated.
	* testsuite/gas/riscv/mapping-04b.d: Updated.
	* testsuite/gas/riscv/mapping-norelax-03b.d: Likewise.
	* testsuite/gas/riscv/mapping-norelax-04b.d: Likewise.
opcodes/
	* riscv-dis.c: Include elfxx-riscv.h since we need the
	architecture parser.  Also removed the cpu-riscv.h, it
	is already included in elfxx-riscv.h.
	(default_isa_spec): Defined since the parser need this
	to set the default architecture string.
	(xlen): Moved out from riscv_disassemble_insn as a global
	variable, it is more convenient to initialize riscv_rps_dis.
	(riscv_subsets): Defined to recoed the supported
	extensions.
	(riscv_rps_dis): Defined for architectrue parser.
	(riscv_disassemble_insn): Call riscv_multi_subset_supports
	to make sure if the instructions are valid or not.
	(print_insn_riscv): Initialize the riscv_subsets by parsing
	the elf architectrue attribute.  Otherwise, set the default
	architectrue string to rv64gc.
2021-11-11 16:59:13 +08:00
GDB Administrator
2ec453b566 Automatic date update in version.in 2021-11-11 00:00:35 +00:00
Przemyslaw Wirkus
14f458590a arm: enable Cortex-A710 CPU
This patch is adding support for Cortex-A710 CPU in Arm.

bfd/

	* cpu-arm.c (processors): Add cortex-a710.

gas/

	* NEWS: Update docs.
	* config/tc-arm.c (arm_cpus): Add cortex-a710 to -mcpu.
	* doc/c-arm.texi: Update docs.
	* testsuite/gas/arm/cpu-cortex-a710.d: New test.
2021-11-10 14:09:05 +00:00
Clément Chigot
e86fc4a5bc PR 28447: implement multiple parameters for .file on XCOFF
On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
additional information to AIX linker, or its debugger. These are
stored in auxiliary entries of the C_FILE symbol.

bfd/
	PR 28447
	* coffcode.h (combined_entry_type): Add extrap field.
	(coff_bigobj_swap_aux_in): Adjust names of x_file fields.
	(coff_bigobj_swap_aux_out): Likewise.
	* coffgen.c (coff_write_auxent_fname): New function.
	(coff_fix_symbol_name): Write x_file using
	 coff_write_auxent_fname.
	(coff_write_symbol): Likewise.
	(coff_write_symbols): Add C_FILE auxiliary entries to
	string table if needed.
	(coff_get_normalized_symtab): Adjust names of x_file fields.
	Normalize C_FILE auxiliary entries.
	(coff_print_symbol): Print C_FILE auxiliary entries.
	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust names of
	x_file fields.
	(_bfd_xcoff_swap_aux_out): Likewise.
	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
	(_bfd_xcoff64_swap_aux_out): Likewise.
	* cofflink.c (_bfd_coff_final_link): Likewise.
	(_bfd_coff_link_input_bfd): Likewise.
	* coffswap.h (coff_swap_aux_in): Likewise.
	* peXXigen.c (_bfd_XXi_swap_aux_in): Likewise.
	(_bfd_XXi_swap_aux_out): Likewise.
	* xcofflink.c (xcoff_link_input_bfd): Likewise.
	* libcoff.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_file): New function.
	* config/tc-ppc.h (OBJ_COFF_MAX_AUXENTRIES): Change to 4.
	* testsuite/gas/ppc/aix.exp: Add tests.
	* testsuite/gas/ppc/xcoff-file-32.d: New test.
	* testsuite/gas/ppc/xcoff-file-64.d: New test.
	* testsuite/gas/ppc/xcoff-file.s: New test.
include/
	* coff/internal.h (union internal_auxent): Change x_file to be a
	  struct instead of a union. Add x_ftype field.
	* coff/rs6000.h (union external_auxent): Add x_resv field.
	* coff/xcoff.h (XFT_FN): New define.
	(XFT_CT): Likewise.
	(XFT_CV): Likewise.
	(XFT_CD): Likewise.
2021-11-10 14:43:24 +10:30
GDB Administrator
b790c47da3 Automatic date update in version.in 2021-11-10 00:00:22 +00:00
GDB Administrator
d98c63919a Automatic date update in version.in 2021-11-09 00:00:18 +00:00
GDB Administrator
603955c8de Automatic date update in version.in 2021-11-08 00:00:10 +00:00
GDB Administrator
eea68ebb33 Automatic date update in version.in 2021-11-07 00:00:10 +00:00
Alan Modra
e8f81980ce ubsan: undefined shift in mach-o.c
This one was logically wrong too.  If file_ptr was 64 bits, then -1U
is extended to 0x00000000ffffffff, probably not what was intended
here.

	* mach-o.c (FILE_ALIGN): Correct expression.
2021-11-06 21:15:49 +10:30
Fangrui Song
dd207c1302 readelf: Support RELR in -S and -d and output
readelf -r dumping support is not added in this patch.

include/
	* elf/common.h: Add SHT_RELR, DT_RELR{,SZ,ENT}
bfd/
	* elf.c (_bfd_elf_print_private_bfd_data): Add DT_RELR{,SZ,ENT}.
binutils/
	* readelf.c (get_dynamic_type): Add DT_RELR{,SZ,ENT}.
	(get_section_type_name): Add SHT_RELR.
2021-11-06 17:11:08 +10:30
GDB Administrator
cf0992fe6f Automatic date update in version.in 2021-11-06 00:00:19 +00:00
Alan Modra
c5967f38de PR28530, Hang in objdump on machine with 196GB RAM
Investigating the PR28530 testcase, which has a fuzzed compression
header with an enormous size, I noticed that decompress_contents is
broken when the size doesn't fit in strm.avail_out.  It wouldn't be
too hard to support larger sizes (patches welcome!) but for now just
stop decompress_contents from returning rubbish.

	PR 28530
	* compress.c (decompress_contents): Fail when uncompressed_size
	is too big.
	(bfd_init_section_decompress_status): Likewise.
2021-11-05 14:15:18 +10:30
Alan Modra
a3c0896d80 asan: alpha-vms: objdump buffer overflows
* vms-alpha.c (evax_bfd_print_desc): Sanity check buffer access.
	(evax_bfd_print_valspec, evax_bfd_print_typspec): Likewise.
	(evax_bfd_print_dst): Likewise.
2021-11-05 14:15:18 +10:30
GDB Administrator
831105b6d9 Automatic date update in version.in 2021-11-05 00:00:30 +00:00
H.J. Lu
33d3e18ed7 Revert "bfd: Always check sections with the corrupt size"
This reverts commit e0f7ea9143.
2021-11-04 08:07:09 -07:00
H.J. Lu
e0f7ea9143 bfd: Always check sections with the corrupt size
Always check sections with the corrupt size for non-MMO files.  Skip MMO
files for compress_status == COMPRESS_SECTION_NONE since MMO has special
handling for COMPRESS_SECTION_NONE.

	PR binutils/28530
	* compress.c (bfd_get_full_section_contents): Always check
	sections with the corrupt size.
2021-11-04 06:57:32 -07:00
Nelson Chu
edc77c591a RISC-V: Clarify the behavior of .option rvc or norvc.
Add/Remove the rvc extension to/from the riscv_subsets once the
.option rvc/norvc is set.  So that we don't need to always check
the riscv_opts.rvc in the riscv_subset_supports, just call the
riscv_lookup_subset to search the subset list is enough.

Besides, we will need to dump the instructions according to the
elf architecture attributes.  That means the dis-assembler needs
to parse the architecture string from the elf attribute before
dumping any instructions, and also needs to recognized the
INSN_CLASS* classes from riscv_opcodes.  Therefore, I suppose
some functions will need to be moved from gas/config/tc-riscv.c
to bfd/elfxx-riscv.c, including riscv_multi_subset_supports and
riscv_subset_supports.  This is one of the reasons why we need
this patch.

This patch passes the gcc/binutils regressions of rv32emc-elf,
rv32i-elf, rv64gc-elf and rv64gc-linux toolchains.

bfd/
	* elfxx-riscv.c (riscv_remove_subset): Remove the extension
	from the subset list.
	(riscv_update_subset): Add/Remove an extension to/from the
	subset list.  This is used for the .option rvc or norvc.
	* elfxx-riscv.h: Added the extern bool riscv_update_subset.
gas/
	* config/tc-riscv.c (riscv_set_options): Removed the unused
	rve flag.
	(riscv_opts): Likewise.
	(riscv_set_rve): Removed.
	(riscv_subset_supports): Removed the riscv_opts.rvc check.
	(riscv_set_arch): Don't need to call riscv_set_rve.
	(reg_lookup_internal): Call riscv_subset_supports to check
	whether the rve is supported.
	(s_riscv_option): Add/Remove the rvc extension to/from the
	subset list once the .option rvc/norvc is set.
2021-11-04 17:46:09 +08:00
GDB Administrator
8f01568908 Automatic date update in version.in 2021-11-04 00:00:14 +00:00
Alan Modra
a442059f66 PR28523, ld.bfd created undefined symbols on ppc64
This patch removes any fake (linker created) function descriptor
symbol if its code entry symbol isn't dynamic, to ensure bogus dynamic
symbols are not created.  The change to func_desc_adjust requires that
it be run only once, which means ppc64_elf_tls_setup can't call it for
just a few selected symbols.

	PR 28523
	* elf64-ppc.c (func_desc_adjust): If a function entry sym is
	not dynamic and has no plt entry, hide any associated fake
	function descriptor symbol.
	(ppc64_elf_edit): Move func_desc_adjust iteration over syms to..
	(ppc64_elf_tls_setup): ..here.
2021-11-03 10:46:29 +10:30
GDB Administrator
b480ee76e4 Automatic date update in version.in 2021-11-03 00:00:18 +00:00
GDB Administrator
317db249c7 Automatic date update in version.in 2021-11-02 00:00:17 +00:00
Alan Modra
c908dea26f macho-o archive sanity checks
Anti-fuzzing checks.

	* mach-o.c (bfd_mach_o_fat_archive_p): Sanity check entry offset
	and size against file size.
2021-11-01 22:30:33 +10:30
Przemyslaw Wirkus
3197e593d8 arm: add armv9-a architecture to -march
Update also include:
	+ New value of Tag_CPU_arch EABI attribute (22) is added.
	+ Updated missing Tag_CPU_arch EABI attributes.
	+ Updated how we combine archs 'v4t_plus_v6_m' as this mechanism
	  have to handle new Armv9 as well.

Regression tested on `arm-none-eabi` cross Binutils and no issues.

bfd/

	* archures.c: Define bfd_mach_arm_9.
	* bfd-in2.h (bfd_mach_arm_9): Define bfd_mach_arm_9.
	* cpu-arm.c: Add 'armv9-a' option to -march.
	* elf32-arm.c (using_thumb2_bl): Update assert check.
	(arch_has_arm_nop): Add TAG_CPU_ARCH_V9.
	(bfd_arm_get_mach_from_attributes): Add case for TAG_CPU_ARCH_V9.
	Update assert.
	(tag_cpu_arch_combine): Updated table.
	(v9): New table..

binutils/

	* readelf.c (arm_attr_tag_CPU_arch): Update with

elfcpp/

	* arm.h: Update TAG_CPU_ARCH_ enums with correct values.

gas/

	* NEWS: Update docs.
	* config/tc-arm.c (get_aeabi_cpu_arch_from_fset): Return Armv9-a
	for -amarch=all.
	(aeabi_set_public_attributes): Update assert.
	* doc/c-arm.texi: Update docs.
	* testsuite/gas/arm/armv9-a_arch.d: New test.
	* testsuite/gas/arm/attr-march-all.d: Update test with v9.

include/

	* elf/arm.h Update TAG_CPU_ARCH_ defines with correct values.
	* opcode/arm.h (ARM_EXT3_V9A): New macro.
	(ARM_ARCH_NONE): Updated with arm_feature_set.core size.
	(FPU_NONE): Updated.
	(ARM_ANY): Updated.
	(ARM_ARCH_UNKNOWN): New macro.
	(ARM_FEATURE_LOW): Updated.
	(ARM_FEATURE_CORE): Updated.
	(ARM_FEATURE_CORE_LOW): Updated.
	(ARM_FEATURE_CORE_HIGH): Updated.
	(ARM_FEATURE_COPROC): Updated.
	(ARM_FEATURE): Updated.
	(ARM_FEATURE_ALL): New macro.

opcodes/

	* arm-dis.c (select_arm_features): Support bfd_mach_arm_9.
	Also Update bfd_mach_arm_unknown to use new macro ARM_ARCH_UNKNOWN.
2021-11-01 10:51:03 +00:00
GDB Administrator
e7360783ae Automatic date update in version.in 2021-11-01 00:00:19 +00:00
Alan Modra
590abc168f Don't include coff/pe.h in coff-x86_64.c
This (and other) code from coffcode.h is broken for x86_64_coff_vec,
and has been ever since support was added in 2006 commit 99ad839030
Here, bfd_coff_aoutsz must match coff_swap_aouthdr_out otherwise we
end up writing garbage.

      /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
	 include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)).  */
      char * buff;
      bfd_size_type amount = bfd_coff_aoutsz (abfd);

      buff = (char *) bfd_malloc (amount);
      if (buff == NULL)
	return false;

      coff_swap_aouthdr_out (abfd, & internal_a, buff);
      amount = bfd_bwrite (buff, amount, abfd);

We have removed support for --target=x86_64-coff, likely because it
never worked properly, but still produce coff-x86_64.o with
--enable-targets=all.  This means objcopy can recognize x86_64 COFF
files but will write garbage to the output file, a fact found by
fuzzers.  I suspect x86_64 COFF is still broken after this fix, and
mention of coff-x86_64.* should be removed from bfd/Makefile.am.

	* coff-x86_64.c: Don't include coff/pe.h.
	(COFF_WITH_pex64): Don't define here.
	* pe-x86_64.c: Include coff/pe.h and other headers.
	(PEI_HEADERS): Define.
2021-10-31 11:42:52 +10:30
Alan Modra
1c5e9d8d8c Re: PR28420, ecoff fuzzing failures
sym_ptr_ptr NULL results in segfaults.

	PR 28420
	* ecoff.c (ecoff_slurp_reloc_table): Don't leave sym_ptr_ptr NULL.
2021-10-31 11:42:08 +10:30
Alan Modra
9216910ed8 ubsan: alpha-vms: undefined shift
* vms-alpha.c (evax_bfd_print_image): Shift left 1u.
2021-10-31 11:41:39 +10:30
Alan Modra
3c8ed65a5d PR28518: signed integer overflow & free on unmalloced address
PR 28518
	* vms-alpha.c (build_module_list): Don't lose malloc buffer address.
	Use unsigned variables.
2021-10-31 10:57:52 +10:30
GDB Administrator
fb9f44d410 Automatic date update in version.in 2021-10-31 00:00:09 +00:00
GDB Administrator
4a3a56c5f3 Automatic date update in version.in 2021-10-30 00:00:26 +00:00
Alan Modra
c45c3dba8c ELF core file size checks
Catch fuzzed segments where p_offset + p_filesz wraps, and limit error
output.

	* elfcore.h (elf_core_file_p): Rewrite segment checks using
	bfd_get_file_size.  Set read_only on file size errors.
	* elfcode.h (elf_swap_shdr_in): Don't repeat error message.
2021-10-29 17:22:32 +10:30
Alan Modra
c82ebeb7e6 obcopy vs. files with silly section alignment
We already ignore stupid segment alignment when rewriting headers,
ignore section alignment too.

	* elf.c (rewrite_elf_program_header): Ignore section alignment
	power greater than 62.
2021-10-29 15:48:22 +10:30
GDB Administrator
208eb58158 Automatic date update in version.in 2021-10-29 00:00:18 +00:00
Alan Modra
0a0ff9d931 asan: mmo: NULL dereferenc in mmo_xore_32
mmo_get_loc can return NULL.  It's commented even, and that the caller
then must handle a split field.  mmo_xore_* don't handle split fields,
instead just segfault.  Stop that happening, and refuse to recognise
fuzzed mmo files that trigger this problem.

	* mmo.c (mmo_get_loc): Don't declare inline.
	(mmo_xore_64, mmo_xore_32, mmo_xore_16): Remove forward decls.
	Return pointer, don't dereference NULL.
	(mmo_scan): Return error on mmo_get_loc returning NULL.
2021-10-28 13:25:57 +10:30
Alan Modra
42eec46f23 bfd: remove use of INLINE
No need to use anything fancy, plain inline works just as well.

	* bfd-in.h (INLINE): Don't define.
	* bfd-in2.h: Regenerate.
	* aoutx.h: Replace use of INLINE with inline.
	* elf-eh-frame.c: Likewise.
	* elf32-score7.c: Likewise.
	* elfxx-mips.c: Likewise.
	* ihex.c: Likewise.
	* mach-o.c: Likewise.
	* mmo.c: Likewise.
2021-10-28 13:24:37 +10:30
GDB Administrator
9fc9dbc28b Automatic date update in version.in 2021-10-28 00:00:16 +00:00
Alan Modra
94852430d6 asan: alpha-vms: buffer overflows
Yet more anti-fuzzer sanity checking

	* vms-alpha.c (evax_bfd_print_egsd): Sanity check record and
	name lengths before access.
	(evax_bfd_print_etir_stc_ir, evax_bfd_print_etir): Likewise.
2021-10-28 07:40:49 +10:30
GDB Administrator
28c26ce5fd Automatic date update in version.in 2021-10-27 00:00:18 +00:00
GDB Administrator
3976e96a02 Automatic date update in version.in 2021-10-26 00:00:12 +00:00
Alan Modra
1e5a28be0f ubsan: _bfd_xcoff64_swap_aux_in left shift of negative value
* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Use bfd_vma for h.
2021-10-25 11:41:52 +10:30
Alan Modra
b920bc3722 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.
2021-10-25 10:33:26 +10:30