[binutils-gdb] null dereference in csky opcodes support
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=efc26507d9998eef6dc0b17480e0d921f40958c1 commit efc26507d9998eef6dc0b17480e0d921f40958c1 Author: Alan Modra <[email protected]> Date: Sun Mar 22 13:11:39 2026 +1030 null dereference in csky opcodes support section->relocation will remain NULL on an error reading the relocs. * csky-dis.c (is_extern_symbol): Delete section flag check. Instead check that section->relocation is non-NULL. Make addr param a bfd_vma. Diff: --- opcodes/csky-dis.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c index aaf6ffd1b85..6c905833cce 100644 --- a/opcodes/csky-dis.c +++ b/opcodes/csky-dis.c @@ -201,19 +201,15 @@ csky_find_inst_info (struct csky_opcode_info const **pinfo, } static bool -is_extern_symbol (struct disassemble_info *info, int addr) +is_extern_symbol (struct disassemble_info *info, bfd_vma addr) { - unsigned int rel_count = 0; - - if (info->section == NULL) - return 0; - if ((info->section->flags & SEC_RELOC) != 0) /* Fit .o file. */ + if (info->section != NULL && info->section->relocation != NULL) { + unsigned int rel_count = 0; struct reloc_cache_entry *pt = info->section->relocation; for (; rel_count < info->section->reloc_count; rel_count++, pt++) - if ((long unsigned int)addr == pt->address) + if (addr == pt->address) return true; - return false; } return false; }