diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 15c77bece9..a2b0771db2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2020-05-01 Alan Modra + + PR 25900 + * elfnn-riscv.c (_bfd_riscv_relax_section): Check root.type before + accessing root.u.def of symbols. Also check root.u.def.section + is non-NULL. Reverse tests so as to make the logic positive. + 2020-05-01 Alan Modra PR 25882 diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 8fcb1067fd..473bf50f2d 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -4161,15 +4161,16 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, symval = 0; sym_sec = bfd_und_section_ptr; } - else if (h->root.u.def.section->output_section == NULL - || (h->root.type != bfd_link_hash_defined - && h->root.type != bfd_link_hash_defweak)) - continue; - else + else if ((h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && h->root.u.def.section != NULL + && h->root.u.def.section->output_section != NULL) { symval = h->root.u.def.value; sym_sec = h->root.u.def.section; } + else + continue; if (h->type != STT_FUNC) reserve_size =