Turn elfu_gScnSizeFile into a macro
[centaur.git] / include / libelfu / generic.h
1 #ifndef __LIBELFU_GENERIC_H__
2 #define __LIBELFU_GENERIC_H__
3
4 #include <libelf/gelf.h>
5
6 #define OFFS_END(off, sz) ((off) + (sz))
7
8 #define OVERLAPPING(off1, sz1, off2, sz2) \
9   (!((off1) == (off2) && ((sz1 == 0) || (sz2 == 0))) \
10    && (((off1) <= (off2) && (off2) < OFFS_END((off1), (sz1))) \
11        || ((off2) <= (off1) && (off1) < OFFS_END((off2), (sz2)))) \
12   )
13
14 #define FULLY_OVERLAPPING(off1, sz1, off2, sz2) \
15   (((off1) <= (off2) && OFFS_END((off2), (sz2)) <= OFFS_END((off1), (sz1))) \
16    || ((off2) <= (off1) && OFFS_END((off1), (sz1)) <= OFFS_END((off2), (sz2))))
17
18
19
20 #define SCNFILESIZE(shdr) ((shdr)->sh_type == SHT_NOBITS ? 0 : (shdr)->sh_size)
21
22
23 int elfu_gPhdrContainsScn(GElf_Phdr *phdr, GElf_Shdr *shdr);
24
25
26 #endif