From c4d9a1aaf7c25e45adcaaebc970429f2c61bf6e9 Mon Sep 17 00:00:00 2001 From: norly Date: Sat, 23 Feb 2013 15:47:53 +0000 Subject: [PATCH] Merge {first,last}-section-in-segment.c --- src/elfops/first-section-in-segment.c | 36 ------------------- ...tion-in-segment.c => section-in-segment.c} | 31 ++++++++++++++++ 2 files changed, 31 insertions(+), 36 deletions(-) delete mode 100644 src/elfops/first-section-in-segment.c rename src/elfops/{last-section-in-segment.c => section-in-segment.c} (66%) diff --git a/src/elfops/first-section-in-segment.c b/src/elfops/first-section-in-segment.c deleted file mode 100644 index 58065a5..0000000 --- a/src/elfops/first-section-in-segment.c +++ /dev/null @@ -1,36 +0,0 @@ -#include - -#include -#include - -#include - - -/* - * 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_firstSectionInSegment(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 - && elfu_segmentContainsSection(phdr, &shdr)) { - return scn; - } - - scn = elf_nextscn(e, scn); - } - - return NULL; -} diff --git a/src/elfops/last-section-in-segment.c b/src/elfops/section-in-segment.c similarity index 66% rename from src/elfops/last-section-in-segment.c rename to src/elfops/section-in-segment.c index 53323f6..e12720f 100644 --- a/src/elfops/last-section-in-segment.c +++ b/src/elfops/section-in-segment.c @@ -7,6 +7,37 @@ #include +/* + * 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_firstSectionInSegment(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 + && elfu_segmentContainsSection(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" -- 2.30.2