#19884 - shadow_gg - Tue Apr 27, 2004 1:55 pm
Hi everybody, does anyone can told me why my rom work in arm but not in thumb?
when I compile in THUMB my game freeze , and I saw some illegal writes.
My program is in C++,and it seems it happens when he tried to call methods in some classes.
the instructions in ASM who use to make the illegal write always look like this:
800285e: 6002 str r2, [r0, #0] //ILLEGAL WRITE!
8002860: 6808 ldr r0, [r1, #0]
8002862: 2103 mov r1, #3
8002864: fa9af008 bl 800ad9c <_ZN7Sprite211SetPriorityEt>
normally there shouldn't be any differences in my C code ?
The same C code should either work in ARM or THUMB ,no ?
I hope somebody will be able to help me,bcs I'm damn blocked
THX ALL!
#19893 - f(DarkAngel) - Tue Apr 27, 2004 8:00 pm
It seems to be a pointer routine. It might be that you're writing to an illegal address (like null pointer), or maybe the pointer value wraps because it overflowed 2^16 in thumb mode and pointing to an illegal address... I'm not sure.
_________________
death scream...
#19898 - sajiimori - Tue Apr 27, 2004 9:05 pm
Quote: |
maybe the pointer value wraps because it overflowed 2^16 in thumb mode and pointing to an illegal address
|
Thumb instructions are just abbreviations of ARM instructions. They have the same addressable space.
#19905 - col - Tue Apr 27, 2004 9:45 pm
shadow_gg,
show us some compilable source code that exhibits the problem.
also, what compiler/version are you using?
And which command line switches are set?
Col
#19994 - poslundc - Thu Apr 29, 2004 3:20 pm
shadow_gg wrote: |
bcs I'm damn blocked |
You know you've been writing too much ASM code when you read that as brach-carry-set...
Dan.
#20000 - shadow_gg - Thu Apr 29, 2004 5:16 pm
lol dan ^^
I used devkitadv g++ 3.0.2
it seems I had fixed the illegal writes issues by removing one function.
All my files where compiled in ARM mode and all was working well.
Actually for my game working I must compile my main.cpp and sprite.cpp in arm.
All others sources files are compiled in thumb.
Now I want to compile main.cpp and sprite.cpp in thumb mode,
but I got some stranges visuals effects occurings.
What can I do in my code who works in ARM and not in THUMB?
sizeof( types ) are the same between ARM and THUMB ,no?
how the same C++ code can differ when compiled ?
my rules for getting .o files
%.o:%.cpp
$(GCC_PATH) -I. -I$(DEVKIT_PATH)/lib/gcc-lib/arm-agb-elf/3.0.2/include -I$(DEVKIT_PATH)/arm-agb-elf/include -I$(Nintendo_include) -I./lucidcore/ -I./gbacoreapi/ -g -O2 -frename-registers -Wall -fverbose-asm -mthumb -mthumb-interwork -c -o $@ $<
oh I just discovered something strange in the makefile:
@ $(LD_PATH) --no-warn-mismatch -o GBA.elf ./gbacoreapi/crt0.o ./gbacoreapi/crtbegin.o ./gbacoreapi/crtend.o $(OBJS) $(SOUND_FILES) -L$(DEVKIT_PATH)/lib/gcc-lib/arm-agb-elf/3.0.2/interwork -L$(DEVKIT_PATH)/arm-agb-elf/lib/interwork -L$(Nintendo_lib) -T Linkscript -lagbsyscall -lstdc++ -lgcc -lc -Map GBA.map
when I removed --no-warn-mismatch it doesn't compile anymore,
bcs my object files generated by objcopy don't support interworking.
Maybe my errors come from this point,huh?
How can I add interworking support in this line :
%.o:%.bin
$(OBJCOPY_PATH) -B arm -I binary -O elf32-little --rename-section .data=.rodata $< $@
?
THX ALL FOR UR REPLIES ,AND EXCUSE ME FOR MY POOR ENGLISH ;)
#20043 - col - Fri Apr 30, 2004 1:05 pm
shadow_gg wrote: |
lol dan ^^
I used devkitadv g++ 3.0.2
it seems I had fixed the illegal writes issues by removing one function.
All my files where compiled in ARM mode and all was working well.
Actually for my game working I must compile my main.cpp and sprite.cpp in arm.
All others sources files are compiled in thumb.
Now I want to compile main.cpp and sprite.cpp in thumb mode,
but I got some stranges visuals effects occurings.
What can I do in my code who works in ARM and not in THUMB?
sizeof( types ) are the same between ARM and THUMB ,no?
how the same C++ code can differ when compiled ?
|
without some source code its difficult to help much.
I do remember that the version of gcc you are using was unable to dereference pointers to member functions correctly from thumb code.
I am using 3.2.2 (devkitadv 5), and that issue has beed resolved.
Quote: |
oh I just discovered something strange in the makefile:
@ $(LD_PATH) --no-warn-mismatch -o GBA.elf ./gbacoreapi/crt0.o ./gbacoreapi/crtbegin.o ./gbacoreapi/crtend.o $(OBJS) $(SOUND_FILES) -L$(DEVKIT_PATH)/lib/gcc-lib/arm-agb-elf/3.0.2/interwork -L$(DEVKIT_PATH)/arm-agb-elf/lib/interwork -L$(Nintendo_lib) -T Linkscript -lagbsyscall -lstdc++ -lgcc -lc -Map GBA.map
when I removed --no-warn-mismatch it doesn't compile anymore,
bcs my object files generated by objcopy don't support interworking.
Maybe my errors come from this point,huh?
How can I add interworking support in this line :
%.o:%.bin
$(OBJCOPY_PATH) -B arm -I binary -O elf32-little --rename-section .data=.rodata $< $@
?
|
If your code and the libs you use are all compiled with interworking enabled, then its just raw data thats the problem - sound, graphics... in that case you can use a tool called interflip (?) to fix the data object files.
If on the other hand the problem is in code object files, then they must be recompiled with interworking on. Any libs you link to should also support interworking.
cheers,
Col