application resets phone, GCC buil/link issue ? | developer.brewmp.com application resets phone, GCC buil/link issue ? | developer.brewmp.com

Developer

application resets phone, GCC buil/link issue ?

Forums:

Hi everybody

Is anybody using the elf2mod utility as found here :

https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/elf2mod

I thought that was the latest version. It is the only one I see that comes with a linker script.

I tried compiling the whiteboard app from the sdk examples and it just resets my phone.

Can anybody using GCC and this elf2mod utility let me know what they use as compile and link options ? there are so many versions of elf2mod around, and different advice on using gcc and brew that I don't know if what I am doing is the right, most up to date way.

While I am at it: anybody has success debugging with gdb ? any gotchas to be aware of ?

Thanks !

Bruno

I'm using BREWElf2Mod with an MD5Sum of
29e72b19a1256fc23736d85dc86c4d9b
This is one from GCCSupportForBREW.zip from https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/compilersgnu
i.e. not the one you're using.
Compile flags are -fno-rtti -mcpu=arm7tdmi -mapcs-frame -fno-builtin -ffunction-sections -fshort-wchar -fno-exceptions -fno-unwind-tables -mlittle-endian -O2-O2 -DDYNAMIC_APP
Link flags are --script armelf.brew -L$(WINARMHOME)/lib/gcc/arm-elf/4.1.1 --emit-relocs -( -lgcc -l -)
Linker script is this one
http://brew.wardco.com/armelf.brew
but I changed "AEEModGen.o"(.text.AEEMod_Load) to be *(.text.AEEMod_Load) for my convenience.

I'm using BREWElf2Mod with an MD5Sum of
29e72b19a1256fc23736d85dc86c4d9b
This is one from GCCSupportForBREW.zip from https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/compilersgnu
i.e. not the one you're using.
Compile flags are -fno-rtti -mcpu=arm7tdmi -mapcs-frame -fno-builtin -ffunction-sections -fshort-wchar -fno-exceptions -fno-unwind-tables -mlittle-endian -O2-O2 -DDYNAMIC_APP
Link flags are --script armelf.brew -L$(WINARMHOME)/lib/gcc/arm-elf/4.1.1 --emit-relocs -( -lgcc -l -)
Linker script is this one
http://brew.wardco.com/armelf.brew
but I changed "AEEModGen.o"(.text.AEEMod_Load) to be *(.text.AEEMod_Load) for my convenience.

If you're compiling unmodified code and it compiles fine, then the most likely issue is that you have not got AEEMod_Load at the entry point, which should be at 0x8000. Have a link at the link map to see what's going on.

If you're compiling unmodified code and it compiles fine, then the most likely issue is that you have not got AEEMod_Load at the entry point, which should be at 0x8000. Have a link at the link map to see what's going on.

I got it to work using the elf2mod I already have but if I use any optimization flag (i.e. anything but -O0) it resets the phone.
I'll try yet another linkerscript and elf2mod...

I got it to work using the elf2mod I already have but if I use any optimization flag (i.e. anything but -O0) it resets the phone.
I'll try yet another linkerscript and elf2mod...

BenBlaukopf wrote:If you're compiling unmodified code and it compiles fine, then the most likely issue is that you have not got AEEMod_Load at the entry point, which should be at 0x8000. Have a link at the link map to see what's going on.
you meant at 0x00000000, right ?
I see when using -O0, AEEMod_Load is at 0 but not when using -O2. I guess that is the issue...
I kind of assumed that link script Qualcomm provided would work in any config. I'll see how to fix it.
bruno

BenBlaukopf wrote:If you're compiling unmodified code and it compiles fine, then the most likely issue is that you have not got AEEMod_Load at the entry point, which should be at 0x8000. Have a link at the link map to see what's going on.
you meant at 0x00000000, right ?
I see when using -O0, AEEMod_Load is at 0 but not when using -O2. I guess that is the issue...
I kind of assumed that link script Qualcomm provided would work in any config. I'll see how to fix it.
bruno

ok that was it. I just changed the linker script (elf2mod.x) provided in this package
https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/elf2mod
by changing this
.text :
{
*(.text .stub .text.* .gnu.linkonce.t* .glue_7t .glue_7)
} :ER_RO =0
to this
.text 0 : AT( 0 )
{
*(.text.AEEMod_Load)
*(.text .stub .text.* .gnu.linkonce.t* .glue_7t .glue_7)
} :ER_RO =0
now -O2 works fine too !
Thanks for the help

ok that was it. I just changed the linker script (elf2mod.x) provided in this package
https://brewx.qualcomm.com/brew/sdk/authdownload.jsp?page=dx/elf2mod
by changing this
.text :
{
*(.text .stub .text.* .gnu.linkonce.t* .glue_7t .glue_7)
} :ER_RO =0
to this
.text 0 : AT( 0 )
{
*(.text.AEEMod_Load)
*(.text .stub .text.* .gnu.linkonce.t* .glue_7t .glue_7)
} :ER_RO =0
now -O2 works fine too !
Thanks for the help

brunobruno wrote:you meant at 0x00000000, right ?
I see when using -O0, AEEMod_Load is at 0 but not when using -O2. I guess that is the issue...
Well, yes and no.
I did mean that AEEMod_Load, and therefore the entry point, should be right at the start of the linked elf file. And therefore at 0x0000. However, the ARM toolchain link scripts have traditionally put the entry point at 0x8000 - so AEEMod_Load is still the start of the elf file - but is set to load at 0x8000. I'm not sure that this can make a blind bit of difference to the elf2mod utility, but I will continue to do it, because it works :) And if someone would like to educate me some more about elf files, I'd be most grateful!
brunobruno wrote:
I kind of assumed that link script Qualcomm provided would work in any config. I'll see how to fix it.
bruno
Ummm, no comment :)

brunobruno wrote:you meant at 0x00000000, right ?
I see when using -O0, AEEMod_Load is at 0 but not when using -O2. I guess that is the issue...
Well, yes and no.
I did mean that AEEMod_Load, and therefore the entry point, should be right at the start of the linked elf file. And therefore at 0x0000. However, the ARM toolchain link scripts have traditionally put the entry point at 0x8000 - so AEEMod_Load is still the start of the elf file - but is set to load at 0x8000. I'm not sure that this can make a blind bit of difference to the elf2mod utility, but I will continue to do it, because it works :) And if someone would like to educate me some more about elf files, I'd be most grateful!
brunobruno wrote:
I kind of assumed that link script Qualcomm provided would work in any config. I'll see how to fix it.
bruno
Ummm, no comment :)