cancel
Showing results for 
Search instead for 
Did you mean: 

Cosmic linker error - Section Boundary crossing

nsayag
Associate II
Posted on September 14, 2011 at 15:24

Hi all,

I am busy modifying my code so that I can utilize a custom bootloader. My application code is running and compiling with no problems on its own.

The problem begins when I try to shift the start address of the code and interrupt vector to 0x9090 and 0x9000 respectively. The symptom is a list of linker errors of the following format -

&sharperror clnk Release\sr.lkf:78 Release\request.o: section boundary crossing (.text:0014)

I have followed the instructions in AN2659 which only requires to change the addresses of the code and interrupt vector in the project's settings (settings->Linker Input)

I have checked the MAP file of the compiled version before the shift and there is no code space issue (the code is around 36K and I am using a 64K processor).

Any explanation/assistance would be much appreciated.

Thanks, Noam.

#cosmic-link-linking-stvd #bootloader #cosmic
6 REPLIES 6
luca239955_stm1_st
Senior II
Posted on September 15, 2011 at 09:47

Hi,

it looks like your code is now crossing the address 0xFFFF, which requires to use a new memory model (callf instead of call and all the such).

Regards,

Luca (Cosmic)

nsayag
Associate II
Posted on September 15, 2011 at 09:57

Thanks for your response Luca,

Can you elaborate how do I change the memory model?

By the way, looking at the s19 file of the compiled code before the shift, I can see that data is written to addresses greater than 0x10000....

Thanks, Noam.

nsayag
Associate II
Posted on September 15, 2011 at 11:07

Hi again,

Very weird/interesting thing -

I have changed the C compiler optimization from ''Minimize code size (+compact)'' to ''Speed Optimization (+fast)'' and the code is now compiling and linking fine at 0x9000 start address.... (I left the other optimizations unchanged -  +split and -oc).

Does it make sense to anyone?

Thanks, Noam.  

luca239955_stm1_st
Senior II
Posted on September 16, 2011 at 10:13

Hi,

as I said, the problem comes from the fact that your code is going over the address 0xFFFF and you are using a memory model (== compiler options) that will work only below this limit.

More in detail, your code might still work by chance (as you saw), but, depending on which function happens to be located across the critical address 0xFFFF, you might see linker errors such as the one you reported: this explains why, changing random parameters (-> the code size change -> the functions are not allocated at the same addresses), you sometimes see errors and sometimes not.

When you cross the address 0xFFFF you *must* use special compiler options / libraries: look for ''memory models'' in the user manual and especially the chapter “Memory Models for

code larger than 64K�?. It is important to understand that ''bigger than 64k'' for the stm8 actually means ''crossing the address 0xFFFF'', as the code starts in 0x8000

Regards,

Luca

nsayag
Associate II
Posted on September 16, 2011 at 16:05

Hi again Luca and thanks for the elaborated response!

I have been using Stack Long (modsl) memory model all along... I have searched throughout the code for any @near calls and there aren't any...

Does that means that I have to go and physically add @far before any function definition/call? From what I have read in the manual, when defining Stack Long, the calls are defaulted to @far...

You have mentioned different libraries, I haven't seen any mentioning on that...

Hope to get further assistance from you!

Cheers, Noam.

jdf25252
Associate II
Posted on September 16, 2011 at 16:33

Noam

I saw that error when my code first went over into the next section.  If you look in ''Project Settings'' The ''C Compiler'' tab & category ''Output'' if either ''Functions do not cross section (-gnc)'' or ''Functions do Not Cross Boundarie (+nocross)'' are checked you can get this error. My current project will get this error if checked but runs fine otherwise.  As long as you are compiling with ''+modsl'' you should be OK as there are no memory management registers that would need to change when crossing a page boundary

jdf.