Skip to content

Commit 8445687

Browse files
committed
Fixed not fixing up the parsed functions for 32 bit Mach-O files
1 parent 523f0a7 commit 8445687

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/parser/file/macho/machoFile.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ static inline bool machoFile_handleFunctionStarts(struct machoFile* self, struct
266266
return true;
267267
}
268268

269+
static inline void machoFile_fixupFunctions(struct machoFile* self) {
270+
vector_iterate(pair_funcFile_t, &self->functions, {
271+
if (element->first.length != 0) continue;
272+
273+
uint64_t* address = vector_uint64_search(&self->functionStarts, &element->first.startAddress, &machoFile_uint64Compare);
274+
if (address != NULL && (size_t) (address - self->functionStarts.content) < self->functionStarts.count - 2) {
275+
element->first.length = *++address - element->first.startAddress;
276+
}
277+
})
278+
}
279+
269280
/**
270281
* Parses a Mach-O file into the given Mach-O file abstraction object.
271282
*
@@ -308,6 +319,9 @@ static inline bool machoFile_parseFileImpl(struct machoFile * self,
308319
}
309320
lc = (void *) lc + macho_maybeSwap(32, bitsReversed, lc->cmdsize);
310321
}
322+
323+
machoFile_fixupFunctions(self);
324+
311325
return true;
312326
}
313327

@@ -354,14 +368,7 @@ static inline bool machoFile_parseFileImpl64(struct machoFile * self,
354368
lc = (void *) lc + macho_maybeSwap(32, bitsReversed, lc->cmdsize);
355369
}
356370

357-
vector_iterate(pair_funcFile_t, &self->functions, {
358-
if (element->first.length != 0) continue;
359-
360-
uint64_t* address = vector_uint64_search(&self->functionStarts, &element->first.startAddress, &machoFile_uint64Compare);
361-
if (address != NULL && (size_t) (address - self->functionStarts.content) < self->functionStarts.count - 2) {
362-
element->first.length = *++address - element->first.startAddress;
363-
}
364-
})
371+
machoFile_fixupFunctions(self);
365372

366373
return true;
367374
}

0 commit comments

Comments
 (0)