/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Bizzare linker error

Username:     
Password:     
             

Forum

# 1   2008-07-10 10:47:34 Bizzare linker error

lmm
New member
Registered: 2008-06-24
Posts: 5

Bizzare linker error

(I'm trying to build a very modified version of the toggle_with_circleOS sample. After making some changes I started getting the following error; reverting them makes it go away, I'm investigating more closely to see exactly which change has started it)
Running : LD
\"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "C:\Program Files\Raisonance\Ride\Examples\ARM\Primer\STM32\toggle_with_CircleOS\objrelease\toggle_with_CircleOS.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Program Files\Raisonance\Ride\Examples\ARM\Primer\STM32\toggle_with_CircleOS\objrelease\toggle_with_CircleOS.map"   
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.1/../../../../arm-none-eabi/bin/ld.exe: DISCARD has both ordered [`.ARM.exidx' in c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.1/thumb2\libgcc.a(_divdi3.o)] and unordered [`.ARM.extab' in c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.1/thumb2\libgcc.a(_divdi3.o)] sections 
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.1/../../../../arm-none-eabi/bin/ld.exe: final link failed: Bad value 
collect2: ld returned 1 exit status 

Anyone ever seen an error like this, or have any idea what it means?

Many thanks

Offline

 

# 2   2008-07-10 10:54:27 Bizzare linker error

lmm
New member
Registered: 2008-06-24
Posts: 5

Re: Bizzare linker error

Having tested, I seem to be getting the error if I'm doing a division involving a number of type "long long", but not otherwise.

Offline

 

# 3   2008-07-11 13:23:39 Bizzare linker error

matloub
Member
Registered: 2008-02-21
Posts: 98

Re: Bizzare linker error

Hi

Can you send me a small project that does not link to support@raisonance.com
I would like to see if I get the same error.

Best regards,
Matloub

Offline

 

# 4   2008-07-11 14:19:44 Bizzare linker error

lmm
New member
Registered: 2008-06-24
Posts: 5

Re: Bizzare linker error

It's literally just a question of adding the following to a default project:
   long long x,y,z;
   z=x/y;
(I'd guess you might have to be a bit cleverer if compiling with optimizations, so that gcc doesn't eliminate it entirely).
If you want the full project I'm working on I'll send a copy on or before Monday, but it's really as simple as that.

Thanks for looking into it,
Michael

Offline

 

# 5   2008-07-23 18:09:24 Bizzare linker error

matloub
Member
Registered: 2008-02-21
Posts: 98

Re: Bizzare linker error

Hi Michael

I am really sorry for the delay in answering. For unknown reason I found your email in the garbage when I was verifying it.

I tried as you suggested on your post to add the "l long long x,y,z; z=x/y;" to the example toggle_with_CircleOs but the build did not fail.
Are you sure that adding these simple lines to a project resulted to a build failed?

I think there is something else in your project because I get the same error as you when I use your project.
This error should come from the point that CircleOS is compiled with library that might do not support the use of float that you attempt to do.

We are look that point.

Best regards,
Matloub

Offline

 

# 6   2008-07-23 18:52:50 Bizzare linker error

lmm
New member
Registered: 2008-06-24
Posts: 5

Re: Bizzare linker error

Yes, I tried adding literally just those lines, at the top of the Application_Handler function, and got the error. Furthermore in the project I sent you, if one changes all the long longs which are used for division into longs, but leaves the others as long longs, it builds and links ok. So I really think it's likely to be the division of long longs.
If it's something linked to floating point, perhaps it's an attempt to cast a long long to a double? (I can't remember whether I ever did that, and don't have the code to hand as I'm posting).

Thanks again for any help,
Michael

Offline

 

# 7   2009-04-06 18:11:56 Bizzare linker error

robbee
New member
Registered: 2009-03-30
Posts: 4

Re: Bizzare linker error

I'm having the same error when I tried to add a sprintf to my code. This is very frustrating and I'm starting to doubt CirceOS apps can get bigger than 32K in total without upgrade to PRO version. I don't need any debug capability at the moment just a way to compile the app and flash it to my primer2.

Code became bigger than starter kit's limitation so I had to manually edit Circle_App.LD. Before that I had FLASH FULL alert!

There ale only 3 new lines I added to the regular primer2 circleOS project's template

#include <stdio.h>

and 2 lines at the top of Application_Ini()

char buf[50];
sprintf(buf,"test %d",123);

Changed MEMORY block of my LD file looks like follows:

MEMORY
{
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
  FLASHB1 (r) : ORIGIN = 0x8000000, LENGTH = 0x6000
  FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 512K-0x6000
  EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
}

and the error I'm getting is telling about failure of DISCARD clause, see below:

Building C:\Program Files\Raisonance\Ride\examples\mytest.rapp
Running: LD
\"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\mytest.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\mytest.map"   
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/bin/ld.exe: DISCARD has both ordered [`.ARM.exidx' in c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/thumb2\libgcc.a(_divdi3.o)] and unordered [`.ARM.extab' in c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/thumb2\libgcc.a(_divdi3.o)] sections 
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/bin/ld.exe: final link failed: Bad value 
collect2: ld returned 1 exit status 
 
Build failed

If anyone had this problem and found a solution please share. Any ideas are welcomed :-)

Best Regards!

Offline

 

# 8   2009-04-07 08:22:41 Bizzare linker error

VincentC
Administrator
Registered: 2007-11-08
Posts: 149

Re: Bizzare linker error

Hi,

First, you can be sure that this problem is NOT related to PRO/STD RLink/Primer: It is a link error and at this point Ride has not communicated with the RLink yet. In fact it does not even know which kind of RLink you have. (you can even unplug the RLink, you will still get the same error!)

Now, the error message that you get usually comes from linking objects and/or libraries that have been compiled with different versions of the compiler or with very different code generation options. (it's not the only possible explanation, but it is the most likely) This explains why it appears when you start using some library functions. (sprintf, long long division, etc.)

I can reproduce your error here (although I have a Primer PRO wink ) but I will need more time to enquire on it. However, I already see two things that you should change:

1. The FLASH region cannot have a LENGTH of "512K-0x6000", as the CircleOS uses the end of the Flash for storing constants, initial values for data and non-debuggable code. See the ld of the OS itself (not the applications) for knowing the size that must be reserved there. (might depend on the version of the OS you are using) And of course always make sure that you change the "_eflash" symbol accordingly whenever you change this region's length.

2. The error you report only comes when you use the sprintf from gcc, which is a bad idea because this sprintf is designed for working in unix-like environment, and therefore it performs a lot of things that are useless in a Primer with CircleOS. So it takes up much more flash than it should. For sure it should work, and we will now try to understand why it doesn't, but still I recommend you use our small printf library instead. (with or without floats depending on your needs) Using this library requires that you also use the Uart0 putchar library because of a small problem (that we will correct later) in the way the small printf is written. So you must either also include the UART0_putchar, which is quite small so it should be OK, or you can take the sources of the small printf library from Ride and include them directly in your project, but then you'll have to modify them a little for not calling IO_putchar.
I just tested to add your code in toggle_with_circle_OS, change the ld a little to increase the FLASH region's size to 25K (and "_eflash" accordingly), change the link options to include the small printf and UART0_putchar libraries. Then the project links and I could test by debugging with a Primer PRO that the sprintf fills 'buf' as expected.

Best Regards,

Vincent

Offline

 

# 9   2009-04-07 12:29:29 Bizzare linker error

VincentC
Administrator
Registered: 2007-11-08
Posts: 149

Re: Bizzare linker error

Hi,

The problem is due to a typo in the linker script that we found several months ago, but it was fixed only in the standard linker script and we forgot to do it in the CircleOS scripts.

You need to replace the "DISCARD" standard section name by the "/DISCARD/" special section name:

Code:

   /DISCARD/ :
   {
      libc.a (*)
      libm.a (*)
      libgcc.a (*)
   }

You can also refer to "<Ride>\lib\ARM\sections_FLASH.ld" and copy-paste from it.

Then you also need to either use the UART0_putchar, or add the <Ride>\lib\ARM\e_stdio\src\syscalls.c file to your project, as the sprintf needs some functions that are defined in this file. (_sbrk, ...)

But once again I recommend using the sprintf from the small printf library instead. (see my previous message)

I hope it helps.

Best Regards,

Vincent

Offline

 

# 10   2009-04-07 17:26:51 Bizzare linker error

robbee
New member
Registered: 2009-03-30
Posts: 4

Re: Bizzare linker error

Vincent,

once I changed to /DISCARD/ and added UART0 Putchar in LD config it's linking !
I'll use light versions of sprintf as you suggested in my future projects. Thanks for rapid investigation and response. It's nice to know someone really watches this forum and is willing and able to help.

Best Regards!

Robert.

Offline

 

# 11   2009-06-03 11:27:49 Bizzare linker error

Mysterio
Member
From: Germany/NRW
Registered: 2009-05-22
Posts: 23

Re: Bizzare linker error

I had the same problem
but I made the steps, that are discribed here.
The old error disappeared, but now I have a new error:

Running: LD
\"C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "C:\Programme\Raisonance\Ride\examples\objdebug\Application1.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Programme\Raisonance\Ride\examples\objdebug\Application1.map"   
c:/programme/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r': 
signalr.c:(.text+0x2): undefined reference to `_getpid' 
collect2: ld returned 1 exit status 

I don't know, what I made wrong

I Need help...


The only definitly knowledge we have, is that we don't know anything. -Sokrates-

Offline

 

Board footer