Bug 29823

Summary: ld riscv: undefined elf_backend_obj_attrs_handle_unknown causes segfault when merging .riscv.attributes
Product: binutils Reporter: Fangrui Song <i>
Component: ldAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: kito.cheng, nelson.chu
Priority: P2    
Version: 2.40   
Target Milestone: ---   
Host: Target: riscv64-*-*
Build: Last reconfirmed:

Description Fangrui Song 2022-11-23 17:42:13 UTC
% cat a.s
.attribute 9, "0"
% riscv64-linux-gnu-gcc -c a.s
% ~/Dev/binutils-gdb/out/riscv64/ld/ld-new a.o a.o
[1]    3982286 segmentation fault  ~/Dev/binutils-gdb/out/riscv64/ld/ld-new a.o a.o

lang_check=>_bfd_riscv_elf_merge_private_bfd_data=>riscv_merge_attributes => `result &= _bfd_elf_merge_unknown_attribute_low (ibfd, obfd, i);` => `get_elf_backend_data (err_bfd)->obj_attrs_handle_unknown (err_bfd, tag);` => null pointer dereference