This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _sbrk: undefined reference to `end' problem


Hi Roberto,

In my .ld file there isn't an `end' declaration. But if I put the following code at the end of .ld file, the compilation terminate correctly, but the application does not function correctly:

PROVIDE (end = .);

I don't know the `end' address to insert in the declaration. Can anybody help me?

As you guessed the "end" symbol is a special one that need to be provided by the linker script. But what you didn't know is that the symbol needs to be placed at the lowest allocatable memory address not occupied by the program or its data. (Try running "ld --verose" to see how this is done with the linker's built-in default script). The _sbrk() function in libgloss/arm/syscalls.c uses this "end" symbol as the starting point for memory allocation.


Note: putting the "PROVIDE (end = .);" at the end of your linker script is incorrect because presumably you have also provided the location of the start of the stack, which is at the top of allocatable memory. "end" needs to be that the bottom of allocatable memory.

Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]