diff options
author | Alan Modra <amodra@gmail.com> | 2020-05-01 15:32:00 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-05-01 15:32:36 +0930 |
commit | a2714d6cca1f1c7695f8dc84b49a4a51d1db86c8 (patch) | |
tree | 5f20f779745c44575c90b238e06395a601963a96 /bfd | |
parent | 60832332244aae2835851aba83f4b705cf29f8a3 (diff) | |
download | gdb-a2714d6cca1f1c7695f8dc84b49a4a51d1db86c8.zip gdb-a2714d6cca1f1c7695f8dc84b49a4a51d1db86c8.tar.gz gdb-a2714d6cca1f1c7695f8dc84b49a4a51d1db86c8.tar.bz2 |
PR25900, RISC-V: null pointer dereference
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elfnn-riscv.c | 11 |
2 files changed, 13 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 15c77be..a2b0771 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2020-05-01 Alan Modra <amodra@gmail.com> + 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 <amodra@gmail.com> + PR 25882 * elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output. diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 8fcb106..473bf50 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 = |