:: commit ffe25e380894157d3b646cebf4c35fb689248ae9

mintsuki <mintsuki@protonmail.com> — 2024-06-05 09:30

parents: dc4c3f2b9d

lib/elf: Stop parsing PT_DYNAMIC once DT_NULL reached

diff --git a/common/lib/elf.c b/common/lib/elf.c
index de589baf..194216bb 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -315,11 +315,14 @@ static bool elf64_apply_relocations(uint8_t *elf, struct elf64_hdr *hdr, void *b
                     break;
                 case DT_NEEDED:
                     panic(true, "elf: ELF file attempts to load a dynamically linked library");
+                case DT_NULL:
+                    goto end_of_pt_segment;
             }
         }
 
         break;
     }
+end_of_pt_segment:
 
     if (rela_offset != 0) {
         if (rela_ent < sizeof(struct elf64_rela)) {
tab: 248 wrap: offon