diff --git a/Source/CDSection.m b/Source/CDSection.m index 4630b63d..c3df909e 100644 --- a/Source/CDSection.m +++ b/Source/CDSection.m @@ -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];