Skip sections which are not PROGBITS
authorSofian Brabez <sbz@FreeBSD.org>
Mon, 1 Jun 2020 14:56:05 +0000 (16:56 +0200)
committerSofian Brabez <sbz@FreeBSD.org>
Mon, 1 Jun 2020 14:57:56 +0000 (16:57 +0200)
ELF debug sections type are all SHT_PROGBITS so avoid looping on all other
types for nothing

elf.c

diff --git a/elf.c b/elf.c
index e73e9c49d03c020b54ccbbaa645463177b81bcf0..ce9eafead50c278ce08823f0a67c10f8e979e517 100644 (file)
--- a/elf.c
+++ b/elf.c
@@ -124,6 +124,9 @@ elf_debug_print(Elf_Obj *e)
     printf("%d ELF debug sections:\n", elf_debug(e));
 
     for (i=0; i < e->shdr_size; i++) {
+        if (e->shdr[i].sh_type != SHT_PROGBITS)
+            continue;
+
         section_name = elf_str_get(e, i);
         if (strnstr(section_name, debug_prefix, strlen(debug_prefix))) {
             printf("%s\n", section_name);