#147976 - bpoint - Mon Dec 31, 2007 12:04 pm
Happy New Year everyone! (well, almost ;) )
I'm having a bit of a problem getting ARM/Thumb interworking working properly with devkitARM r21.
I can currently compile and execute both ARM and Thumb code (my interrupt handler is compiled as ARM and is located in iwram). I can also call Thumb code from ARM, and return back properly to ARM, but I *cannot* call ARM code from Thumb. The interworking glue being generated is using an invalid address.
To show what's going on, here's a small dissassembly of the actual code (compiled in debug mode, no optimizations enabled):
And so the CPU jumps into OAM memory, and everything goes downhill from there. The area of code where the interwork glue is located seems to be correct, as there are other functions where the offsets are perfectly valid.
Looking at the map file, the actual address of the update function which should be called is half-way correct:
Why 0x0700 is being used instead of 0x0300 is what I don't understand.
Just to make sure I've done everything right:
1) ARM code is compiled with -marm -mthumb-interworking
2) Thumb code is compiled with -mthumb -mthumb-interworking
3) The update() function has __attribute__(section (".iwram"), long_call) specified, and is being compiled as ARM
4) The function calling the update() function is just normal Thumb code
Is there something I've missed?
I'm having a bit of a problem getting ARM/Thumb interworking working properly with devkitARM r21.
I can currently compile and execute both ARM and Thumb code (my interrupt handler is compiled as ARM and is located in iwram). I can also call Thumb code from ARM, and return back properly to ARM, but I *cannot* call ARM code from Thumb. The interworking glue being generated is using an invalid address.
To show what's going on, here's a small dissassembly of the actual code (compiled in debug mode, no optimizations enabled):
Code: |
080345F0: F012 bl
080345F2: FF72 bl ___ZN7CFSound13DeviceGBABase6updateEv_from_thumb 080474D8: 4778 bx pc 080474DA: 46C0 mov r8, r8 080474DC: EABEE6C7 b 0x07001000 |
And so the CPU jumps into OAM memory, and everything goes downhill from there. The area of code where the interwork glue is located seems to be correct, as there are other functions where the offsets are perfectly valid.
Looking at the map file, the actual address of the update function which should be called is half-way correct:
Code: |
.iwram 0x03001000 0x194 c:/CF/lib/gba\libDebug-CFSound.a(gbaBase.arm.o)
0x03001000 CFSound::DeviceGBABase::update() |
Why 0x0700 is being used instead of 0x0300 is what I don't understand.
Just to make sure I've done everything right:
1) ARM code is compiled with -marm -mthumb-interworking
2) Thumb code is compiled with -mthumb -mthumb-interworking
3) The update() function has __attribute__(section (".iwram"), long_call) specified, and is being compiled as ARM
4) The function calling the update() function is just normal Thumb code
Is there something I've missed?