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