* PR25900, RISC-V: null pointer dereference
@ 2020-05-01 6:01 Alan Modra
2020-05-05 23:27 ` Palmer Dabbelt
0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2020-05-01 6:01 UTC (permalink / raw)
To: binutils
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.
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 =
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PR25900, RISC-V: null pointer dereference
2020-05-01 6:01 PR25900, RISC-V: null pointer dereference Alan Modra
@ 2020-05-05 23:27 ` Palmer Dabbelt
0 siblings, 0 replies; 2+ messages in thread
From: Palmer Dabbelt @ 2020-05-05 23:27 UTC (permalink / raw)
To: binutils; +Cc: binutils
On Thu, 30 Apr 2020 23:01:28 PDT (-0700), binutils@sourceware.org wrote:
> 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.
>
> 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 =
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-05 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 6:01 PR25900, RISC-V: null pointer dereference Alan Modra
2020-05-05 23:27 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).