| ... | @@ -96,8 +96,7 @@ const BinaryElfOutput = struct { | ... | @@ -96,8 +96,7 @@ const BinaryElfOutput = struct { |
| 96 | | 96 | |
| 97 | sort.sort(*BinaryElfSegment, self.segments.items, {}, segmentSortCompare); | 97 | sort.sort(*BinaryElfSegment, self.segments.items, {}, segmentSortCompare); |
| 98 | | 98 | |
| 99 | if (self.segments.items.len > 0) { | 99 | for (self.segments.items) |firstSegment, i| { |
| 100 | const firstSegment = self.segments.items[0]; | | |
| 101 | if (firstSegment.firstSection) |firstSection| { | 100 | if (firstSegment.firstSection) |firstSection| { |
| 102 | const diff = firstSection.elfOffset - firstSegment.elfOffset; | 101 | const diff = firstSection.elfOffset - firstSegment.elfOffset; |
| 103 | | 102 | |
| ... | @@ -107,9 +106,10 @@ const BinaryElfOutput = struct { | ... | @@ -107,9 +106,10 @@ const BinaryElfOutput = struct { |
| 107 | | 106 | |
| 108 | const basePhysicalAddress = firstSegment.physicalAddress; | 107 | const basePhysicalAddress = firstSegment.physicalAddress; |
| 109 | | 108 | |
| 110 | for (self.segments.items) |segment| { | 109 | for (self.segments.items[i + 1 ..]) |segment| { |
| 111 | segment.binaryOffset = segment.physicalAddress - basePhysicalAddress; | 110 | segment.binaryOffset = segment.physicalAddress - basePhysicalAddress; |
| 112 | } | 111 | } |
| | 112 | break; |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | | 115 | |