summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-02-23 15:59:12 +0000
committernorly <ny-git@enpas.org>2013-02-23 15:59:12 +0000
commit6e4cbafe0876ff14ff03a14ab80951167ef67e06 (patch)
tree6e8ef066e67b841ef5c18ece44d7543958db4e02
parentc4d9a1aaf7c25e45adcaaebc970429f2c61bf6e9 (diff)
Clean up ELF-related files and functions
-rw-r--r--include/libelfu/elfops.h13
-rw-r--r--include/libelfu/generic.h9
-rw-r--r--include/libelfu/libelfu.h1
-rw-r--r--src/elfops/phdr-contains-section.c (renamed from src/elfops/segment-contains-section.c)2
-rw-r--r--src/elfops/phdr-fixup-selfref.c (renamed from src/elfops/phdr.c)2
-rw-r--r--src/elfops/section-by-name.c2
-rw-r--r--src/elfops/section-in-segment.c8
-rw-r--r--src/elfops/section-name.c2
-rw-r--r--src/generic/scnSize.c (renamed from src/elfops/scnSize.c)2
-rw-r--r--src/model/check.c4
-rw-r--r--src/printing/sections.c4
-rw-r--r--src/printing/segments.c4
12 files changed, 31 insertions, 22 deletions
diff --git a/include/libelfu/elfops.h b/include/libelfu/elfops.h
index a57069d..25575a1 100644
--- a/include/libelfu/elfops.h
+++ b/include/libelfu/elfops.h
@@ -6,15 +6,14 @@
#include <libelfu/types.h>
-size_t elfu_scnSizeFile(const GElf_Shdr *shdr);
-char* elfu_sectionName(Elf *e, Elf_Scn *scn);
-Elf_Scn* elfu_sectionByName(Elf *e, char *name);
+ char* elfu_eScnName(Elf *e, Elf_Scn *scn);
+Elf_Scn* elfu_eScnByName(Elf *e, char *name);
-int elfu_segmentContainsSection(GElf_Phdr *phdr, GElf_Shdr *shdr);
-Elf_Scn* elfu_firstSectionInSegment(Elf *e, GElf_Phdr *phdr);
-Elf_Scn* elfu_lastSectionInSegment(Elf *e, GElf_Phdr *phdr);
+ int elfu_ePhdrContainsScn(GElf_Phdr *phdr, GElf_Shdr *shdr);
+Elf_Scn* elfu_eScnFirstInSegment(Elf *e, GElf_Phdr *phdr);
+Elf_Scn* elfu_eScnLastInSegment(Elf *e, GElf_Phdr *phdr);
-void elfu_fixupPhdrSelfRef(Elf *e);
+void elfu_ePhdrFixupSelfRef(Elf *e);
#endif
diff --git a/include/libelfu/generic.h b/include/libelfu/generic.h
new file mode 100644
index 0000000..9d9aefb
--- /dev/null
+++ b/include/libelfu/generic.h
@@ -0,0 +1,9 @@
+#ifndef __LIBELFU_GENERIC_H__
+#define __LIBELFU_GENERIC_H__
+
+#include <gelf.h>
+
+
+size_t elfu_gScnSizeFile(const GElf_Shdr *shdr);
+
+#endif
diff --git a/include/libelfu/libelfu.h b/include/libelfu/libelfu.h
index 961235f..3c62aad 100644
--- a/include/libelfu/libelfu.h
+++ b/include/libelfu/libelfu.h
@@ -4,6 +4,7 @@
#include <libelfu/types.h>
+#include <libelfu/generic.h>
#include <libelfu/elfops.h>
#include <libelfu/model.h>
diff --git a/src/elfops/segment-contains-section.c b/src/elfops/phdr-contains-section.c
index 298cf72..6b57019 100644
--- a/src/elfops/segment-contains-section.c
+++ b/src/elfops/phdr-contains-section.c
@@ -4,7 +4,7 @@
#include <libelfu/libelfu.h>
-int elfu_segmentContainsSection(GElf_Phdr *phdr, GElf_Shdr *shdr)
+int elfu_ePhdrContainsScn(GElf_Phdr *phdr, GElf_Shdr *shdr)
{
size_t secStart = shdr->sh_offset;
size_t secEnd = shdr->sh_offset + shdr->sh_size;
diff --git a/src/elfops/phdr.c b/src/elfops/phdr-fixup-selfref.c
index ccdc021..e79f584 100644
--- a/src/elfops/phdr.c
+++ b/src/elfops/phdr-fixup-selfref.c
@@ -3,7 +3,7 @@
#include <libelf.h>
#include <gelf.h>
-void elfu_fixupPhdrSelfRef(Elf *e)
+void elfu_ePhdrFixupSelfRef(Elf *e)
{
GElf_Ehdr ehdr;
size_t i, n;
diff --git a/src/elfops/section-by-name.c b/src/elfops/section-by-name.c
index 1697140..3352b14 100644
--- a/src/elfops/section-by-name.c
+++ b/src/elfops/section-by-name.c
@@ -6,7 +6,7 @@
#include <libelfu/libelfu.h>
-Elf_Scn* elfu_sectionByName(Elf *e, char *name)
+Elf_Scn* elfu_eScnByName(Elf *e, char *name)
{
size_t shstrndx;
Elf_Scn *scn;
diff --git a/src/elfops/section-in-segment.c b/src/elfops/section-in-segment.c
index e12720f..cb62514 100644
--- a/src/elfops/section-in-segment.c
+++ b/src/elfops/section-in-segment.c
@@ -13,7 +13,7 @@
*
* If no section fits, NULL is returned.
*/
-Elf_Scn* elfu_firstSectionInSegment(Elf *e, GElf_Phdr *phdr)
+Elf_Scn* elfu_eScnFirstInSegment(Elf *e, GElf_Phdr *phdr)
{
Elf_Scn *scn;
@@ -26,7 +26,7 @@ Elf_Scn* elfu_firstSectionInSegment(Elf *e, GElf_Phdr *phdr)
}
if (shdr.sh_offset == phdr->p_offset
- && elfu_segmentContainsSection(phdr, &shdr)) {
+ && elfu_ePhdrContainsScn(phdr, &shdr)) {
return scn;
}
@@ -45,7 +45,7 @@ Elf_Scn* elfu_firstSectionInSegment(Elf *e, GElf_Phdr *phdr)
*
* If no section fits, NULL is returned.
*/
-Elf_Scn* elfu_lastSectionInSegment(Elf *e, GElf_Phdr *phdr)
+Elf_Scn* elfu_eScnLastInSegment(Elf *e, GElf_Phdr *phdr)
{
Elf_Scn *last = NULL;
Elf_Scn *scn;
@@ -60,7 +60,7 @@ Elf_Scn* elfu_lastSectionInSegment(Elf *e, GElf_Phdr *phdr)
continue;
}
- if (elfu_segmentContainsSection(phdr, &shdr)) {
+ if (elfu_ePhdrContainsScn(phdr, &shdr)) {
if (!last) {
last = scn;
} else {
diff --git a/src/elfops/section-name.c b/src/elfops/section-name.c
index 1365eb6..e77efee 100644
--- a/src/elfops/section-name.c
+++ b/src/elfops/section-name.c
@@ -6,7 +6,7 @@
#include <libelfu/libelfu.h>
-char* elfu_sectionName(Elf *e, Elf_Scn *scn)
+char* elfu_eScnName(Elf *e, Elf_Scn *scn)
{
size_t shstrndx;
GElf_Shdr shdr;
diff --git a/src/elfops/scnSize.c b/src/generic/scnSize.c
index 2c65ca1..e4cf1c1 100644
--- a/src/elfops/scnSize.c
+++ b/src/generic/scnSize.c
@@ -5,7 +5,7 @@
-size_t elfu_scnSizeFile(const GElf_Shdr *shdr)
+size_t elfu_gScnSizeFile(const GElf_Shdr *shdr)
{
assert(shdr);
diff --git a/src/model/check.c b/src/model/check.c
index cd45f2d..dd5e8eb 100644
--- a/src/model/check.c
+++ b/src/model/check.c
@@ -69,7 +69,7 @@ int elfu_modelCheck(ElfuElf *me)
/* Check for overlapping sections */
for (i = 0; i < numSecs - 1; i++) {
- if (sortedSecs[i]->shdr.sh_offset + elfu_scnSizeFile(&sortedSecs[i]->shdr)
+ if (sortedSecs[i]->shdr.sh_offset + elfu_gScnSizeFile(&sortedSecs[i]->shdr)
> sortedSecs[i+1]->shdr.sh_offset) {
fprintf(stderr, "elfu_check: Found overlapping sections: %s and %s.\n",
elfu_modelScnName(me, sortedSecs[i]),
@@ -90,7 +90,7 @@ int elfu_modelCheck(ElfuElf *me)
/* Check for sections overlapping with PHDRs */
for (i = 0; i < numSecs; i++) {
if (isOverlapping(sortedSecs[i]->shdr.sh_offset,
- elfu_scnSizeFile(&sortedSecs[i]->shdr),
+ elfu_gScnSizeFile(&sortedSecs[i]->shdr),
me->ehdr.e_phoff,
me->ehdr.e_phentsize * me->ehdr.e_phnum)) {
fprintf(stderr, "elfu_check: Found section overlapping with PHDRs: %s.\n",
diff --git a/src/printing/sections.c b/src/printing/sections.c
index be7a907..e06f3b7 100644
--- a/src/printing/sections.c
+++ b/src/printing/sections.c
@@ -31,7 +31,7 @@ void printSegmentsWithSection(Elf *e, Elf_Scn *scn)
continue;
}
- if (elfu_segmentContainsSection(&phdr, &shdr)) {
+ if (elfu_ePhdrContainsScn(&phdr, &shdr)) {
printf(" %d %s\n", i, segmentTypeStr(phdr.p_type));
}
}
@@ -42,7 +42,7 @@ void printSection(Elf *e, Elf_Scn *scn)
{
printf(" %jd: %s\n",
(uintmax_t) elf_ndxscn(scn),
- elfu_sectionName(e, scn));
+ elfu_eScnName(e, scn));
}
diff --git a/src/printing/segments.c b/src/printing/segments.c
index 1f431d6..74eeb83 100644
--- a/src/printing/segments.c
+++ b/src/printing/segments.c
@@ -33,8 +33,8 @@ void printSectionsInSegment(Elf *e, GElf_Phdr *phdr)
continue;
}
- if (elfu_segmentContainsSection(phdr, &shdr)) {
- printf(" %10u %s\n", elf_ndxscn(scn), elfu_sectionName(e, scn));
+ if (elfu_ePhdrContainsScn(phdr, &shdr)) {
+ printf(" %10u %s\n", elf_ndxscn(scn), elfu_eScnName(e, scn));
}
scn = elf_nextscn(e, scn);