Open BredPet opened 7 years ago
@Dmitri-Botcharnikov @sergign60 @alpencolt @jkotas please take a look
For non-GC statics: It should be handled here already: https://github.com/dotnet/corert/blob/1105f175e74e0fee755d5e0884eb41e7fd32e453/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NonGCStaticsNode.cs#L125 . This should be the case you are hitting. Either the RequireInitialAlignment
does not work; or the alignment is computed incorrectly somehow. I do not see any obvious bug.
For GC statics (statics that contain GC references): The space for these statics is allocated at startup of the program here: https://github.com/dotnet/corert/blob/ad69441dcad98c1189cac37927f46bbec4f03a18/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/StartupCode/StartupCodeHelpers.GlobalTables.cs#L61. The dummy type used to allocate them is created here at compile time: https://github.com/dotnet/corert/blob/764c8674d5463d3a4c744562941aef00b7210afb/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs#L630 . There is a bug that the dummy type used to allocate these does not have the RequiresAlign8Flag flag set when the statics blob needs 8-byte alignment.
@jkotas thanks, I'll check this.
I run some HelloWorld sample on Tizen ARM and get the following bt:
disas:
0x0002eb7c <+48>: ldrexd r10, r11, [r0]
"bus error" occurs because the r0 contains an unaligned pointer(0xb4c6f42c) to Int64. Where is the logic for aligning such pointers? I tried several potential places, but the address of the pointer didn't change. Maybe this alignment is somewhere in CoreCLR...