[Mono-dev] AMD64 AOT code and bad IMT

Gavin Dodd gavin at wholesalealgorithms.com
Tue May 28 19:26:09 UTC 2013


I finally got this sorted out.

The issue was struct alignment between the two compilers. 

A lot of structs use bitfields (MonoVTable was the first I found) which is platform specific implementation according to the C standard.
VC (used for compiler) was aligning the first bitfield to a 2 byte boundary and CLang (used for runtime) was not.

I fixed it with pad bytes to align the structs, but this only fixes my case.


This was in a version based on 2.8, but the latest release still uses bitfields.


Gavin



________________________________
 From: Gavin Dodd <gavin at wholesalealgorithms.com>
To: "mono-devel-list at lists.ximian.com" <mono-devel-list at lists.ximian.com> 
Sent: Monday, May 20, 2013 4:37 PM
Subject: [Mono-dev] AMD64 AOT code and bad IMT
 


Hi,

I'm new to Mono so I'm not sure if this is the right list. Please point me in the right direction if this isn't the place to ask these questions.

I'm trying to get AOT compiled code to run on an embedded AMD 64 system. 


It is crashing the first time it hits a method call requiring an IMT because the pointer is incorrect

To make things more interesting I'm working with a branch of mono 2.8 (I think) and I don't have any symbols for the AOT compiled code at run time,

The problem shows up in


common_call_trampoline(mgreg_t* regs, guint8* code, gpointer arg, guint8* tramp, MonoVTable* vt, gpointer* vtable_slot, gboolean need_rgctx_tramp) Line 320    C++

    if (m == MONO_FAKE_IMT_METHOD) {
        MonoMethod *impl_method;
        MonoObject *this_arg;

   
     /* we get the interface method because mono_convert_imt_slot_to_vtable_slot ()
         * needs the signature to be able to find the this argument
         */
        m = mono_arch_find_imt_method (regs, code);

...


At this point m points to bad data. The address is the address returned by mono_get_lmf_addr() 


From the map file I think the function calling the trampoline is System_IO_StreamReader_Initialize_System_IO_Stream_System_Text_Encoding_bool_int
from System_IO_StreamReader__cctor

I'm not sure what function it is trying to call (the vt parameter is for System.IO.NullStream)



My questions are:

Is the lmf address the correct value for the return of mono_arch_find_imt_method? If not what should it be?
What generates the IMT for AOT compiled code? 

What sets the IMT address table at run time and where is it stored? I haven't seen any breakpoints on IMT functions get hit at runtime.

Thanks

Gavin




_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130528/8eec276d/attachment.html>


More information about the Mono-devel-list mailing list