diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index 4903aec134730..441f5bbce7d1b 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -229,6 +229,8 @@ private void PublishCode() _compilation.NodeFactory.Target.MinimumFunctionAlignment : _compilation.NodeFactory.Target.OptimumFunctionAlignment; + alignment = Math.Max(alignment, _codeAlignment); + var objectData = new ObjectNode.ObjectData(_code, relocs, alignment, @@ -2516,6 +2518,7 @@ private void MethodCompileComplete(CORINFO_METHOD_STRUCT_* methHnd) private byte[] _code; private byte[] _coldCode; + private int _codeAlignment; private byte[] _roData; @@ -2535,11 +2538,25 @@ private void allocMem(uint hotCodeSize, uint coldCodeSize, uint roDataSize, uint if (coldCodeSize != 0) coldCodeBlock = (void*)GetPin(_coldCode = new byte[coldCodeSize]); + _codeAlignment = -1; + if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) + { + _codeAlignment = 32; + } + else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) + { + _codeAlignment = 16; + } + if (roDataSize != 0) { int alignment = 8; - if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) + if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) + { + alignment = 32; + } + else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) { alignment = 16; }