[#5104] user/blkfin-test/crash_test/traps_test.c lies...

Document created by Aaronwu Employee on Sep 3, 2013
Version 1Show Document
  • View in full screen mode

[#5104] user/blkfin-test/crash_test/traps_test.c lies...

Submitted By: Robin Getz

Open Date

2009-04-30 16:56:04     Close Date

2009-05-05 16:53:51

Priority:

Medium     Assignee:

Robin Getz

Status:

Closed     Fixed In Release:

N/A

Found In Release:

2010R1     Release:

Category:

N/A     Board:

N/A

Processor:

ALL     Silicon Revision:

Is this bug repeatable?:

Yes     Resolution:

Fixed

Uboot version or rev.:

    Toolchain version or rev.:

any

App binary format:

N/A     

Summary: user/blkfin-test/crash_test/traps_test.c lies...

Details:

 

In an effort to make things compile with no errors, the errors don't actually do what was indented anymore...

 

void instruction_fetch_miss(void)

{

        int (*foo)(void);

        int i;

        i=0x87654320;

        foo = (void *)i;

        (*foo)();

}

 

compiles to:

 

000010f8 <_instruction_fetch_miss>:

    10f8:       4b e1 65 87     P3.H = 0x8765;          /*    P3=0x87650000 */

    10fc:       00 e8 00 00     LINK 0x0;               /* (0) */

    1100:       0b e1 20 43     P3.L = 0x4320;          /*   P3=0x87654320 */

    1104:       59 91           P1 = [P3];

    1106:       5b ac           P3 = [P3 + 0x4];

    1108:       01 e8 00 00     UNLINK;

    110c:       51 00           JUMP (P1);

 

Which dereferences P3, not jumps to it.

 

 

 

Can someone break these properly?

 

Follow-ups

 

--- Mike Frysinger                                           2009-04-30 17:02:42

i think the code is correct.  you're looking at the output of FDPIC which has to

handle function descriptors.

 

the FLAT output looks like what you'd expect:

        P2.H = 34661;

        P2.L = 17184;

        jump (P2);

 

Jie/Bernd would have to comment further

 

otherwise the only way to get what you want is with asm()

 

--- Robin Getz                                               2009-04-30 19:05:05

Ah - gottcha.

 

Hmmm...

 

I'll wait for Bernd/Jie to comment, and then maybe use some more #ifdef

__FDPIC__ in the source...

 

For now, I guess I'll just compile as flat, and assign to me.

 

-Robin

 

 

--- Bernd Schmidt                                            2009-05-04 17:39:37

What Mike said.

 

--- Jie Zhang                                                2009-05-04 23:06:22

Both __FDPIC__ and asm can work. I have no preference on either one. The

__FDPIC__ version might look like:

 

void instruction_fetch_miss(void)

{

        int (*foo)(void);

#ifdef __FDPIC__

        int i[2] = {0x87654320, 0};

#else

        int i = 0x87654320;

#endif

        foo = (void *)i;

        (*foo)();

}

 

--- Mike Frysinger                                           2009-05-04 23:20:41

this seems to work:

 

#ifdef __FDPIC__

# define _get_func_ptr(addr) ({ unsigned long __addr[2] = { addr, 0 }; __addr;

})

#else

# define _get_func_ptr(addr) (addr)

#endif

#define get_func_ptr(addr) (void *)(_get_func_ptr(addr))

 

...

 

  foo = get_func_ptr(0x87654320);

 

--- Robin Getz                                               2009-05-05 16:53:51

Works for me.

 

Thanks for the tip.

 

Fixed.

 

-Robin

 

 

 

    Files

    Changes

    Commits

    Dependencies

    Duplicates

    Associations

    Tags

 

File Name     File Type     File Size     Posted By

No Files Were Found

 

http://test.com

Attachments

    Outcomes