hazel/kernel/elf.c

17 lines
508 B
C
Raw Normal View History

2024-07-06 03:51:46 -04:00
#include <kernel/elf.h>
#include <strcmp.h>
section_t *elf_find_section(elf_t *elf, const char *name) {
section_t *str = (section_t *)((uint32_t)elf + elf->e_shoff + elf->e_shstrndx*elf->e_shentsize);
section_t *found = 0;
for (int i = 0; i < elf->e_shnum; i++) {
section_t *sec = (section_t *)((uint32_t)elf + elf->e_shoff + i*elf->e_shentsize);
const char *n = (char *)((uint32_t)elf + str->sh_offset + sec->sh_name);
if (!strcmp(n, name)) {
found = sec;
}
}
return found;
}