Skip to content

Commit 83a0ac6

Browse files
authored
Merge pull request #536 from CreateAndInject/CheckOverlaps
Check overlaps
2 parents 8f7edaf + a45d40c commit 83a0ac6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/DotNet/Writer/NativeModuleWriter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ void ReuseIfPossible(PESection section, IReuseChunk chunk, RVA origRva, uint ori
354354
if (((uint)origRva & (requiredAlignment - 1)) != 0)
355355
return;
356356

357+
var origEnd = origRva + origSize;
358+
foreach (var reusedChunk in reusedChunks) {
359+
if (origRva < reusedChunk.RVA + reusedChunk.Chunk.GetVirtualSize() && origEnd > reusedChunk.RVA)
360+
return;
361+
}
362+
357363
if (section.Remove(chunk) is null)
358364
throw new InvalidOperationException();
359365
reusedChunks.Add(new ReusedChunkInfo(chunk, origRva));

0 commit comments

Comments
 (0)