Cleaner error handling with ELFU_WARN and ELFU_WARNELF
[centaur.git] / src / elfops / phdr-contains-section.c
1 #include <libelf/libelf.h>
2 #include <libelf/gelf.h>
3
4 #include <libelfu/libelfu.h>
5
6
7 int elfu_ePhdrContainsScn(GElf_Phdr *phdr, GElf_Shdr *shdr)
8 {
9   size_t secStart = shdr->sh_offset;
10   size_t secEnd   = shdr->sh_offset + shdr->sh_size;
11   size_t segStart = phdr->p_offset;
12   size_t segEnd   = phdr->p_offset + phdr->p_memsz;
13
14   if (secStart < segStart || secEnd > segEnd) {
15     return 0;
16   }
17
18   return 1;
19 }