×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    4

    Unhappy How use ARM dynamic thunk ON SYMBIAN

    Could anybody give me some advice?

    I want to test dynamic ARM instruction generating on Nokia E71 mobile phone, but the result is very frustrating. The S60 application died without any error tip or pannic.

    Sample codes is as following:


    <PRE>
    <CODE>
    // Compiler: RCVT2.2
    // cmd: abld build armv5 urel


    #pragma arm // the following is compiled as ARM mode instead of thumb


    // used as ARM thunk bytes source
    // function dummy_thunk's ARMv5 ARM assembly is:
    // dummy_thunk
    // 0x00000088: e12fff1e ../. BX r14

    void dummy_thunk(void)
    {
    }

    typedef unsigned int uint32_t;

    int CallThunk(void)
    {
    char* p0;
    uint32_t* p1;

    typedef void (*_THUNK_FUNCPTR)(void);
    _THUNK_FUNCPTR fn = (_THUNK_FUNCPTR)dummy_thunk;
    log_info("function dummy_thunk=0x%X", fn);
    // printed: 0x79768678

    if(1)
    {
    uint32_t dfn0 = *((uint32_t*)fn);
    uint32_t dfn1 = *((uint32_t*)fn + 1);
    log_info("function dummy_thunk data dfn0=0x%08X, dfn1=0x%08X", dfn0, dfn1);
    // e12fff1e and entry of CallThunk is printed.
    }

    p0 = (char*)malloc(100); // use heap memory to save thunk
    p1 = (uint32_t*)(p0 + (8 - (uint32_t)p0 % 8)); // aligned thunk by 8
    *p1 = *((uint32_t*)fn);
    *(p1+1) = *((uint32_t*)fn + 1);

    // now let fn point to user thunk p1
    fn = (_THUNK_FUNCPTR)p1;

    if(1)
    {
    uint32_t dfn0 = *((uint32_t*)fn);
    uint32_t dfn1 = *((uint32_t*)fn + 1);
    log_info("user thunk data dfn0=0x%08X, dfn1=0x%08X, p1 = 0x%X", dfn0, dfn1, p1);
    // e12fff1e and entry of CallThunk is printed. Totally same as values before copied.
    }

    // call into user thunk using fn() will cause S60 application crashed without any error or pannic!!!
    // Assemly:
    // 0x000000f4: e12fff33 3./. BLX r3

    fn(); // CRASHED here

    free(p0);
    return 0;
    }


    #pragma thumb // has nothing below this line!


    </CODE>
    </PRE>

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,699

    Re: How use ARM dynamic thunk ON SYMBIAN

    Quote Originally Posted by KevinHua View Post
    Could anybody give me some advice?

    I want to test dynamic ARM instruction generating on Nokia E71 mobile phone, but the result is very frustrating. The S60 application died without any error tip or pannic.
    Have you actually enabled them? (http://wiki.forum.nokia.com/index.ph...ded_panic_code)

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    4

    Re: How use ARM dynamic thunk ON SYMBIAN

    Thanks for tip of Errrd location. Now, it raise a Kern-Exec 3 panic. I cannot understand what makes this panic yet since the thunk is position independent, and the 4-byte instruction should could be moved to any address that is aligned by 4.
    The one thing that may cause panic is the memory access protection. The address before calling thunk is 0x7XXXYYYY, however, the heap memory to store the thunk is at 0x7XXYYY. The offset is more than 32M for BLX lable, but should be available for BLX r3.
    Any idea about it?

Similar Threads

  1. Problems with SymbianOSUnit on Symbian OS 9.1
    By dr_rost in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2007-12-10, 18:38
  2. Replies: 1
    Last Post: 2005-02-25, 15:36
  3. Be careful in programming with Symbian Dynamic Buffer classes
    By manjul.bizoara in forum Mobile Java General
    Replies: 0
    Last Post: 2005-02-25, 09:27
  4. Replies: 2
    Last Post: 2003-08-19, 16:39
  5. setting of Series 60 MIDP SDK for Symbian OS version 1.2 for networking
    By servigo in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2003-07-31, 07:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×