elf-attrs.c memory allocation fail
authorAlan Modra <amodra@gmail.com>
Tue, 19 Sep 2023 00:09:31 +0000 (09:39 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 19 Sep 2023 22:53:47 +0000 (08:23 +0930)
commita1d1634d0012ddeecc59bb0e6012d4455edae6e8
treeba213a2d27da84a2ec41bc2a1e7fc6ac23730131
parenta56e5dce69bfad45ee6977a916ccea283e087e8b
elf-attrs.c memory allocation fail

Report errors rather than segfaulting.

bfd/
* elf-attrs.c (elf_new_obj_attr): Return NULL on bfd_alloc fail.
(bfd_elf_add_obj_attr_int): Handle NULL return from the above,
and propagate return to callers.
(elf_add_obj_attr_string, elf_add_obj_attr_int_string): Likewise.
(bfd_elf_add_obj_attr_string): Similarly.
(_bfd_elf_copy_obj_attributes): Report error on alloc fails.
(_bfd_elf_parse_attributes): Likewise.
* elf-bfd.h (bfd_elf_add_obj_attr_int): Update prototype.
(bfd_elf_add_obj_attr_string): Likewise.
(bfd_elf_add_obj_attr_int_string): Likewise.
gas/
* config/obj-elf.c (obj_elf_vendor_attribute): Report fatal
error on out of memory from bfd attribute functions.
* config/tc-arc.c (arc_set_attribute_int): Likewise.
(arc_set_attribute_string, arc_set_public_attributes): Likewise.
* config/tc-arm.c (aeabi_set_attribute_int): Likewise.
(aeabi_set_attribute_string): Likewise.
* config/tc-mips.c (mips_md_finish): Likewise.
* config/tc-msp430.c (msp430_md_finish): Likewise.
* config/tc-riscv.c (riscv_write_out_attrs): Likewise.
* config/tc-sparc.c (sparc_md_finish): Likewise.
* config/tc-tic6x.c (tic6x_set_attribute_int): Likewise.
* config/tc-csky.c (md_begin): Likewise.
(set_csky_attribute): Return ok status.
bfd/elf-attrs.c
bfd/elf-bfd.h
gas/config/obj-elf.c
gas/config/tc-arc.c
gas/config/tc-arm.c
gas/config/tc-csky.c
gas/config/tc-mips.c
gas/config/tc-msp430.c
gas/config/tc-riscv.c
gas/config/tc-sparc.c
gas/config/tc-tic6x.c