6 #include <libelfu/libelfu.h>
10 * Returns the first section that is contained in the segment and
11 * ends as close to its memory image of as possible (the "last"
12 * section in the segment).
14 * If no section fits, NULL is returned.
16 Elf_Scn* elfu_lastSectionInSegment(Elf *e, GElf_Phdr *phdr)
22 scn = elf_getscn(e, 1);
24 if (elfu_segmentContainsSection(phdr, scn) == ELFU_TRUE) {
31 if (gelf_getshdr(last, &shdrOld) != &shdrOld) {
35 if (gelf_getshdr(scn, &shdrNew) != &shdrNew) {
39 if (shdrNew.sh_offset + shdrNew.sh_size
40 > shdrOld.sh_offset + shdrOld.sh_size) {
41 // TODO: Check (leftover space in memory image) < (p_align)
47 scn = elf_nextscn(e, scn);