From: Anton Lapounov Date: Thu, 24 Jun 2021 19:09:36 +0000 (-0700) Subject: Ensure relocation blocks are 4-byte aligned (#54668) X-Git-Tag: submit/tizen/20210909.063632~595 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7cb47629a859e24e04431010dcd95d68fa49a035;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Ensure relocation blocks are 4-byte aligned (#54668) --- diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/SectionBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/SectionBuilder.cs index 608ba52..1e02a78 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/SectionBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/SectionBuilder.cs @@ -703,6 +703,13 @@ namespace ILCompiler.PEWriter /// 16-bit entries encoding offset relative to the base RVA (low 12 bits) and relocation type (top 4 bite) private static void FlushRelocationBlock(BlobBuilder builder, int baseRVA, List offsetsAndTypes) { + // Ensure blocks are 4-byte aligned. This is required by kernel memory manager + // on Windows 8.1 and earlier. + if ((offsetsAndTypes.Count & 1) == 1) + { + offsetsAndTypes.Add(0); + } + // First, emit the block header: 4 bytes starting RVA, builder.WriteInt32(baseRVA); // followed by the total block size comprising this header