mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-11 09:14:38 +03:00
elf: Do not assume relocatable unless DT_RELA present. Fixes #170
This commit is contained in:
parent
650c1443e0
commit
c22492976a
@ -127,8 +127,20 @@ static bool elf64_is_relocatable(uint8_t *elf, struct elf64_hdr *hdr) {
|
||||
memcpy(&phdr, elf + (hdr->phoff + i * hdr->phdr_size),
|
||||
sizeof(struct elf64_phdr));
|
||||
|
||||
if (phdr.p_type == PT_DYNAMIC)
|
||||
return true;
|
||||
if (phdr.p_type != PT_DYNAMIC) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint16_t j = 0; j < phdr.p_filesz / sizeof(struct elf64_dyn); j++) {
|
||||
struct elf64_dyn dyn;
|
||||
memcpy(&dyn, elf + (phdr.p_offset + j * sizeof(struct elf64_dyn)),
|
||||
sizeof(struct elf64_dyn));
|
||||
|
||||
switch (dyn.d_tag) {
|
||||
case DT_RELA:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user