Link Errors Questions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Link Errors Questions

1,741 Views
geoffW
Contributor III

Hi

 

This is probably a fairly easy question, but I just cannot find any documentation or code examples to help me solve the problem.  Can anyone point me at a document that explains the syntax of the *.lcf  command files, as I just can't seem to find it ?

 

I am using Code Warrior 7.1 and building for the  54455 V4 CPU, with MQX V3.5

 

I have ported some existing code over and fixed a bunch of compile errors. I am now stuck on some linker errors. I realise because the code uses malloc() and free() I need to define a heap.

 

 

Error   : Undefined : "__HEAP_START"
Referenced from "__break" in

Error   : Undefined : "__mem_limit"
alloc.c line 176   Referenced from "brk" in

Error   : Undefined : "__stack_safety"
alloc.c line 176   Referenced from "brk" in

Link failed.

 

  

I can fix the " __HEAP_START link error by guessing what the definition should be for this variable in the lcf file

 

but I have no idea how to fix the problem with  "__mem_limit"  and "__stack_safety" variables

 

The odd thing is I can search my entire Freescale folder for ""__stack_safety" and get no hits and if I look in alloc.c line 176 is in the middle of some comments. Very confusing

 

I would appreciate any help on this problem, thanks.

 

Regards Geoff

Labels (1)
0 Kudos
5 Replies

531 Views
CrasyCat
Specialist III

Hello

 

These are not CodeWarrior generated symbols.

I guess they come either from your MQX package of from some library you are using.

 

Did you check if there is anything related to these symbols in your MQX related folders?

 

CrasyCat

0 Kudos

531 Views
geoffW
Contributor III

Hi  Crasycat

 

Thanks for the help, I am still mystified by this one.

 

I have searched thro 6 Gigs of folders, my freescale folder has the codewarrior folder, the MQX source and my app folders below it. I get no text hits at all on "stack_safety"

 

I have now removed all my app code and get the same link error.

 

I have tested a standard example piece of code from MQX 3.5 (the mfs_usb  demo example)

 

Just adding the lines

 

#include <stdlib.h>

 

char *ptr;

ptr = malloc(1000)

 

triggers the link errors, Take out the malloc line, and link error goes away

 

I know it disagrees with your post, but the evidence seems to point at Codewarrior as the culprit

 

Very odd

 

Geoff

 

 

 

 

 

 

0 Kudos

531 Views
CrasyCat
Specialist III

Hello

 

Did you try creating a project in CodeWarrior using the wizard and adding a malloc.

You may have to increase heap size in the .lcf file.

 

Are you able to link then?

 

CrasyCat

0 Kudos

531 Views
geoffW
Contributor III

Hi

 

Thanks for the suggestion to try

 

I have  just tried that now, built a template project (No MQX).

 

For the simple wizard template project I can add a malloc() line and still get a clean compile and link.

 

So it must be related to having MQX in the build that is somehow triggering the link errors

 

Geoff 

0 Kudos

531 Views
CrasyCat
Specialist III

Hello

 

That is what I was suspecting.

 

May be MQX has a remapping from malloc function to some OS related memory allocation function.

It might be a good idea to check how dynamic memory allocation is performed when OS is used/activated.

 

CrasyCat

0 Kudos