Skip to content

Commit a9f5a55

Browse files
author
Jim Wilson
committed
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.
1 parent 4e53911 commit a9f5a55

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

bfd/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-03-21 Jim Wilson <jimw@sifive.com>
2+
3+
PR 24365
4+
* elfnn-riscv.c (riscv_elf_relocate_section): For STT_SECTION check,
5+
verify sym non-NULL before using. Add identical check using h.
6+
17
2019-03-21 Sudakshina Das <sudi.das@arm.com>
28

39
* elf-bfd.h (struct elf_backend_data): Add argument to

bfd/elfnn-riscv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,9 @@ riscv_elf_relocate_section (bfd *output_bfd,
20592059
all relocs to update these addends. This is also ambiguous, as
20602060
we do allow offsets to be added to the target address, which are
20612061
not to be used to find the auipc address. */
2062-
if ((ELF_ST_TYPE (sym->st_info) == STT_SECTION) && rel->r_addend)
2062+
if (((sym != NULL && (ELF_ST_TYPE (sym->st_info) == STT_SECTION))
2063+
|| (h != NULL && h->type == STT_SECTION))
2064+
&& rel->r_addend)
20632065
{
20642066
r = bfd_reloc_dangerous;
20652067
break;

0 commit comments

Comments
 (0)