This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with GNU compiler(2013q4) with SDK 6.1

Hi ,

I have a code like below.

__attribute__((used, long_call, section(".data"))) void function_1()
{
   unsigned int a;
   unsigned int b[10];
   int c;


   c= a-((a/ 10)* 10);
   b[i] = c;
   a= a/10;
}

when I tried to build I got the error as follows

1. relocation truncated to fit: R_ARM_THM_CALL against symbol `__aeabi_uidivmod' defined in .text section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/lib/gcc/arm-none-eabi/4.8.3/armv6-m\libgcc.a(_udivsi3.o)
2. relocation truncated to fit: R_ARM_THM_CALL against symbol `__aeabi_uidiv' defined in .text section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/lib/gcc/arm-none-eabi/4.8.3/armv6-m\libgcc.a(_udivsi3.o)

Can anyone suggest me and help me how I can resolve this issue.

Regards, Anand

EDIT: format

Parents
  • When you post code can you please use the post-code button so it looks like code instead of a jumbled mess of text, it's hard to read.

    You used long_call in your function_1 definition to ensure anyone calling it uses a full 32-bit call, because you're putting it in the data segment. However you are then trying to call back to a normal system routine to do divide, which is in your code/text segment and is too far away for a normal

    bl <immediate>

    instruction on ARM, so it fails at link time.

    If you compile the one .c file containing your RAM-based function with the -mlong_calls option that will make the udiv calls full 32-bit.

    Why are you doing this anyway by the way? What's the need to run the code out of RAM?

  • I didn't say change long_calls to mlong_calls I said compile that .c file with the -mlong_calls (or possibly -mlong-calls) compile option which should make it use long calls for all calls OUT of that piece of c code. I believe the pragma just makes it use long calls for calls INTO that piece of c, which you had already with your attribute, which also put it in the data segment. So put that back, take the pragma out and add the compilation flag to that one .c module so that when it compiles you get something like

    gcc -o out.o -mlong_calls out.c 
    

    That's where you need it to be. If you check the assembler instead of BLX calls you should get an LDR to load the register and then a BL Rx.

    By the way you're not necessarily helping yourself very much as the division library you are calling will still end up in Flash, so you'll be back to Flash to execute that anyway.

Reply
  • I didn't say change long_calls to mlong_calls I said compile that .c file with the -mlong_calls (or possibly -mlong-calls) compile option which should make it use long calls for all calls OUT of that piece of c code. I believe the pragma just makes it use long calls for calls INTO that piece of c, which you had already with your attribute, which also put it in the data segment. So put that back, take the pragma out and add the compilation flag to that one .c module so that when it compiles you get something like

    gcc -o out.o -mlong_calls out.c 
    

    That's where you need it to be. If you check the assembler instead of BLX calls you should get an LDR to load the register and then a BL Rx.

    By the way you're not necessarily helping yourself very much as the division library you are calling will still end up in Flash, so you'll be back to Flash to execute that anyway.

Children
No Data
Related