Skip to content

Commit

Permalink
Merge pull request nygard#42 from 0xced/fix-section-offset
Browse files Browse the repository at this point in the history
Fix invalid section offsets
  • Loading branch information
nygard committed Mar 28, 2014
2 parents 3ef4b07 + 055f8b8 commit 71b7518
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/CDSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ - (id)initWithDataCursor:(CDMachOFileDataCursor *)cursor segment:(CDLCSegment *)
_section.addr = [cursor readPtr];
_section.size = [cursor readPtr];
_section.offset = [cursor readInt32];
uint32_t dyldOffset = (uint32_t)(_section.addr - segment.vmaddr + segment.fileoff);
if (_section.offset > 0 && _section.offset != dyldOffset) {
fprintf(stderr, "Warning: Invalid section offset 0x%08x replaced with 0x%08x in %s,%s\n", _section.offset, dyldOffset, [_segmentName UTF8String], [_sectionName UTF8String]);
_section.offset = dyldOffset;
}
_section.align = [cursor readInt32];
_section.reloff = [cursor readInt32];
_section.nreloc = [cursor readInt32];
Expand Down

0 comments on commit 71b7518

Please sign in to comment.