/* Meta-functions */
-int elfu_mScnForall(ElfuElf *me, SectionHandlerFunc f, void *aux1, void *aux2)
+void* elfu_mScnForall(ElfuElf *me, SectionHandlerFunc f, void *aux1, void *aux2)
{
ElfuPhdr *mp;
ElfuScn *ms;
}
CIRCLEQ_FOREACH(ms, &mp->childScnList, elemChildScn) {
- int rv = f(me, ms, aux1, aux2);
+ void *rv = f(me, ms, aux1, aux2);
if (rv) {
return rv;
}
CIRCLEQ_FOREACH(ms, &me->orphanScnList, elemChildScn) {
- int rv = f(me, ms, aux1, aux2);
+ void *rv = f(me, ms, aux1, aux2);
if (rv) {
return rv;
}
}
- return 0;
+ return NULL;
}
/* Counting */
-static int subCounter(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
+static void* subCounter(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
size_t *i = (size_t*)aux1;
ElfuScn *otherScn = (ElfuScn*)aux2;
if (ms == otherScn) {
- return 1;
+ return ms;
}
*i += 1;
- return 0;
+ /* Continue */
+ return NULL;
}
}
-/* Returns the section index equivalent to the model flattened to ELF */
+/* Returns the index a section would have in the flattened ELF */
size_t elfu_mScnIndex(ElfuElf *me, ElfuScn *ms)
{
/* NULL section *is* counted */
}
+static void* subOldscn(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
+{
+ ElfuScn *otherScn = (ElfuScn*)aux1;
+ (void)aux2;
+
+ if (ms->oldptr == otherScn) {
+ return ms;
+ }
+
+ /* Continue */
+ return NULL;
+}
+
+/* Returns the section with oldscn == oldscn */
+ElfuScn* elfu_mScnByOldscn(ElfuElf *me, ElfuScn *oldscn)
+{
+ assert(me);
+ assert(oldscn);
+
+ return elfu_mScnForall(me, subOldscn, oldscn, NULL);
+}
+
+
/* Convenience */
}
-static int subScnsToArray(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
+static void* subScnsToArray(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
ElfuScn **arr = (ElfuScn**)aux1;
size_t *i = (size_t*)aux2;
arr[(*i)] = ms;
*i += 1;
- return 0;
+ /* Continue */
+ return NULL;
}
static int cmpScnOffs(const void *ms1, const void *ms2)