summaryrefslogtreecommitdiff
path: root/src/elfops/section-in-segment.c
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-06-17 23:34:30 +0100
committernorly <ny-git@enpas.org>2013-06-17 23:39:12 +0100
commitf88e1ad7d9db8a41abecc795200f21138af65c74 (patch)
treedc17e6153ae6ee4678b39f365f8c9d9b28bdde43 /src/elfops/section-in-segment.c
parent150d0c42d423fe49304d648e2c19ff08f6c2e0ad (diff)
C90 compliance, except variadic macros and TODOs
Also removed a lot of dead code from the early days.
Diffstat (limited to 'src/elfops/section-in-segment.c')
-rw-r--r--src/elfops/section-in-segment.c80
1 files changed, 0 insertions, 80 deletions
diff --git a/src/elfops/section-in-segment.c b/src/elfops/section-in-segment.c
deleted file mode 100644
index 7e6206b..0000000
--- a/src/elfops/section-in-segment.c
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <stdlib.h>
-#include <libelfu/libelfu.h>
-
-
-/*
- * Returns the section that starts at the same point in the file as
- * the segment AND is wholly contained in the memory image.
- *
- * If no section fits, NULL is returned.
- */
-Elf_Scn* elfu_eScnFirstInSegment(Elf *e, GElf_Phdr *phdr)
-{
- Elf_Scn *scn;
-
- scn = elf_getscn(e, 1);
- while (scn) {
- GElf_Shdr shdr;
-
- if (gelf_getshdr(scn, &shdr) != &shdr) {
- return NULL;
- }
-
- if (shdr.sh_offset == phdr->p_offset
- && PHDR_CONTAINS_SCN_IN_MEMORY(phdr, &shdr)) {
- return scn;
- }
-
- scn = elf_nextscn(e, scn);
- }
-
- return NULL;
-}
-
-
-
-/*
- * Returns the first section that is contained in the segment and
- * ends as close to its memory image of as possible (the "last"
- * section in the segment).
- *
- * If no section fits, NULL is returned.
- */
-Elf_Scn* elfu_eScnLastInSegment(Elf *e, GElf_Phdr *phdr)
-{
- Elf_Scn *last = NULL;
- Elf_Scn *scn;
-
-
- scn = elf_getscn(e, 1);
- while (scn) {
- GElf_Shdr shdr;
-
- if (gelf_getshdr(scn, &shdr) != &shdr) {
- ELFU_WARNELF("gelf_getshdr");
- continue;
- }
-
- if (PHDR_CONTAINS_SCN_IN_MEMORY(phdr, &shdr)) {
- if (!last) {
- last = scn;
- } else {
- GElf_Shdr shdrOld;
-
- if (gelf_getshdr(last, &shdrOld) != &shdrOld) {
- continue;
- }
-
- if (shdr.sh_offset + shdr.sh_size
- > shdrOld.sh_offset + shdrOld.sh_size) {
- // TODO: Check (leftover space in memory image) < (p_align)
- last = scn;
- }
- }
- }
-
- scn = elf_nextscn(e, scn);
- }
-
- return last;
-}