cancel
Showing results for 
Search instead for 
Did you mean: 

Section Boundary Crossing linker error

Guillermo Corrales
Associate II
Posted on March 06, 2018 at 17:23

Hi all,

I'm developing an application (PROJECT) for a STM8S208RB (128k flash) t

hat was using around 100kB of flash. Now 

I have added a new library (LIBRARY) that has increased memory usage to 120kB

of flash

.

Now, when I delete some code in my application I get the following error:

&sharperror clnk

PROJECT

_release\

PROJECT

.lkf:152

PROJECT

_release\library_api.o: section boundary crossing (.text:095c) f_LIBRARY_SetListCallback

The command: 'clnk -l'C:\Program Files (x86)\COSMIC\FSE_Compilers\Lib' -o PROJECT_release\project.sm8 -m

PROJECT

_release\

PROJECT

.map

PROJECT

_release\

PROJECT

.lkf' has failed, the returned value is: 1

exit code=1.

(I get this error after commenting an if-else related with the library)

(

LIBRARY_SetListCallback is a function related with the library, but it doesn't have any relation with the if-else

)

I'm using the following compiler options:

  • Long Stack (

    +modsl)

  • Minimize code size (+compact)

  • Enforce Prototyping Functions (-pp)

  • Allow Pointer Narrowing (-pnp)

  • Compiler options (-gnc) and (-nocross) was not used.

I'm using 

the following linker options:

  • Interrupt vector on 0x8000

  • Code/Constants from 0x8080 to 0x27FFF

  • Zero page from 0x0000 to 0x00FF

  • RAM from 0x0100 to 0x13FF

This is my memory sections map:

--------

Segments

--------

start 00008080 end 0000ba6c length 14828 segment .const

start 0000bd17 end 000258f4 length 105437 segment .text

start 00004000 end 00004000 length 0 segment .eeprom

start 00000000 end 00000000 length 0 segment .bsct

start 00000000 end 0000000a length 10 segment .ubsct

start 0000000a end 0000000a length 0 segment .bit

start 0000000a end 0000000a length 0 segment .share

start 00000100 end 000003a3 length 675 segment .data, initialized

start 0000ba74 end 0000bd17 length 675 segment .data, from

start 000003a3 end 00001380 length 4061 segment .bss

start 00000000 end 000079be length 31166 segment .info.

start 00008000 end 00008080 length 128 segment .const

start 0000ba6c end 0000ba74 length 8 segment .init

I looked for this error code in the STM8 forum but I couldn't find a answer that would help me.

Has anybody any idea of how to solve this linker error?

Thanks all of you in advance,

Guillermo,

#linker #section-boundary-crossing #stm8-microcontrollers
1 ACCEPTED SOLUTION

Accepted Solutions
luca239955_stm1_st
Senior II
Posted on March 07, 2018 at 18:11

Hello,

there are some sections of code that cannot be linked across the 0xFFFF limit, because they contain 16 bit internal jumps that would work either below 0xFFFF or above it, but not across. Usually these small sections of code are inside the libraries that we (Cosmic) provide with the compiler, but in your case it looks like they are inside some libraires provided by someone else: the solution is to link these libraries at another address, by either changig the linking order (that was basically what was happening when your overall code was bigger) or by forcing a segment beginning at 0x10000 just before the object file where you get the problem.

I hope this is clear, but if you have difficulties don't hesitate to contact us directly on the support email.

Regards,

Luca (Cosmic)

View solution in original post

2 REPLIES 2
luca239955_stm1_st
Senior II
Posted on March 07, 2018 at 18:11

Hello,

there are some sections of code that cannot be linked across the 0xFFFF limit, because they contain 16 bit internal jumps that would work either below 0xFFFF or above it, but not across. Usually these small sections of code are inside the libraries that we (Cosmic) provide with the compiler, but in your case it looks like they are inside some libraires provided by someone else: the solution is to link these libraries at another address, by either changig the linking order (that was basically what was happening when your overall code was bigger) or by forcing a segment beginning at 0x10000 just before the object file where you get the problem.

I hope this is clear, but if you have difficulties don't hesitate to contact us directly on the support email.

Regards,

Luca (Cosmic)

Posted on March 08, 2018 at 14:32

Hi Luca,

Thank you so much for your fast response, now I think I understand the source of my problem. 

Most of the new library is at the end of the .text segment (IE: The 

LIBRARY_SetListCallback

mentioned in the error is located around 0x25000, really far away from 0xFFFF) BUT I added also some new code  that was located at the begining of .text (IE: the mentioned if-else that triggered the error). So because of this new code I think I have moved some other code across 0xFFFF, generating the

section boundary crossing

error. Is this reasoning correct?

Following your instructions, I have changed the linking order manually in the 'PROJECT.lkf' file, so now from 0x8080 to 0

x12000 I have some libraries that I will never modify, so there is no risk of  'move code across 0xFFFF' again. At this point I have some doubts:
  1. ¿There is a way to change the linking order from STVD?
  2. When you mention that around 0xFFFF COSMIC libraries are usually located, It is because as COSMIC libraries are always linked the last ones, in a <64Kb memory model they would be adressed at around 0xFFFF?
  3. Is this solution correct? I mean, If with the new code between 0x8080 and 0x12000 the project compiles and that code will never be modified. section boundary crossing error could appears again?

Thanks all you in advance and best regards.

Guillermo,