elf: elf64_load_section(): Return false early if sh_num == 0
diff --git a/common/lib/elf.c b/common/lib/elf.c
index 1522c2b9..73c19979 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -297,6 +297,10 @@ bool elf64_load_section(uint8_t *elf, void *buffer, const char *name, size_t lim
#error Unknown architecture
#endif
+ if (hdr->sh_num == 0) {
+ return false;
+ }
+
if (hdr->shdr_size < sizeof(struct elf64_shdr)) {
panic(true, "elf: shdr_size < sizeof(struct elf64_shdr)");
}
