From 42cc87bfc8bcd5534ac23bcbaaec138ea73dbff5 Mon Sep 17 00:00:00 2001 From: rdbo Date: Thu, 11 Apr 2024 08:43:28 -0300 Subject: [PATCH] skip symbols with undefined section index --- internal/elfutils/elfutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/elfutils/elfutils.c b/internal/elfutils/elfutils.c index 179f0342..e21f4cf0 100644 --- a/internal/elfutils/elfutils.c +++ b/internal/elfutils/elfutils.c @@ -93,7 +93,7 @@ enum_elf##elf_type##_symbols(FILE *elf, uint64_t base_address, int (*callback)(c if (fread(&sym, sizeof(sym), 1, elf) == 0) \ goto STRTAB_EXIT; \ \ - if (sym.st_name == 0 || ELFW_ST_TYPE(sym) == STT_FILE) \ + if (sym.st_name == 0 || ELFW_ST_TYPE(sym) == STT_FILE || sym.st_shndx == 0) \ continue; \ \ symbol_name = &strtab[sym.st_name]; \ @@ -125,7 +125,7 @@ enum_elf##elf_type##_symbols(FILE *elf, uint64_t base_address, int (*callback)(c if (fread(&sym, sizeof(sym), 1, elf) == 0) \ goto DYNSTR_EXIT; \ \ - if (sym.st_name == 0 || ELFW_ST_TYPE(sym) == STT_FILE) \ + if (sym.st_name == 0 || ELFW_ST_TYPE(sym) == STT_FILE || sym.st_shndx == 0) \ continue; \ \ symbol_name = &dynstr[sym.st_name]; \