diff options
author | Jim Wilson <jimw@sifive.com> | 2019-03-21 15:08:48 -0700 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2019-03-21 15:16:19 -0700 |
commit | a9f5a5517fb7df640f0fcd4cb0f9961818b6505b (patch) | |
tree | a72de21479b1e52dcf700b652378fd5d04430509 /bfd | |
parent | 4e5391148d51c58785aad637f1a92d47b91b3ae6 (diff) | |
download | gdb-a9f5a5517fb7df640f0fcd4cb0f9961818b6505b.zip gdb-a9f5a5517fb7df640f0fcd4cb0f9961818b6505b.tar.gz gdb-a9f5a5517fb7df640f0fcd4cb0f9961818b6505b.tar.bz2 |
RISC-V: Fix linker crash in section symbol check.
sym is only set for local symbols. h is only set for global symbols. Gas
won't let me create a global section symbol, but bfd appears to have some
support for that, and I can't rule out that other assemblers might do this.
So we need to support both, and verify sym and h are non-NULL before using.
bfd/
PR 24365
* elfnn-riscv.c (riscv_elf_relocate_section): For STT_SECTION check,
verify sym non-NULL before using. Add identical check using h.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elfnn-riscv.c | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 31ffadf..1225e3c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2019-03-21 Jim Wilson <jimw@sifive.com> + + PR 24365 + * elfnn-riscv.c (riscv_elf_relocate_section): For STT_SECTION check, + verify sym non-NULL before using. Add identical check using h. + 2019-03-21 Sudakshina Das <sudi.das@arm.com> * elf-bfd.h (struct elf_backend_data): Add argument to diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 0a0ceb7..bb114e5 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -2059,7 +2059,9 @@ riscv_elf_relocate_section (bfd *output_bfd, all relocs to update these addends. This is also ambiguous, as we do allow offsets to be added to the target address, which are not to be used to find the auipc address. */ - if ((ELF_ST_TYPE (sym->st_info) == STT_SECTION) && rel->r_addend) + if (((sym != NULL && (ELF_ST_TYPE (sym->st_info) == STT_SECTION)) + || (h != NULL && h->type == STT_SECTION)) + && rel->r_addend) { r = bfd_reloc_dangerous; break; |