aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-05-01 15:32:00 +0930
committerAndreas K. Hüttel <dilfridge@gentoo.org>2020-07-25 13:22:05 +0300
commitf3a5cb841cd6a790fe16442df4ec97dc4357f3be (patch)
treef66d97468f4988a4bfc5746d7b434a5f4d829aea
parentbinutils: drop redundant 'program_name' definition (-fno-common) (diff)
downloadbinutils-gdb-f3a5cb841cd6a790fe16442df4ec97dc4357f3be.tar.gz
binutils-gdb-f3a5cb841cd6a790fe16442df4ec97dc4357f3be.tar.bz2
binutils-gdb-f3a5cb841cd6a790fe16442df4ec97dc4357f3be.zip
PR25900, RISC-V: null pointer dereferencegentoo/binutils-2.34-5
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. (cherry picked from commit a2714d6cca1f1c7695f8dc84b49a4a51d1db86c8)
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elfnn-riscv.c11
2 files changed, 13 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ca87f744a3..502c02cc64 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+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-04-21 Tamar Christina <tamar.christina@arm.com>
Backport from mainline.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 46f0100ace..fd62931f88 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -4141,15 +4141,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 =