AnsweredAssumed Answered

HCS08 linker INIT function disregards assembly relocatable sections

Question asked by SCOTT MILLER on Jul 20, 2016
Latest reply on Jul 29, 2016 by ZhangJennie


I just ran into a weird problem that caused me some serious bootloader headaches.  I recently ported an HCS08 project from CW6.2 to CW10.6 and did quite a bit of cleanup, partly to make use of PE functions.

 

The problem I discovered is that if I use the INIT command in the linker configuration file to designate my bootloader_main assembly function as the program entry point, the linker apparently disregards the SECTION specifier in the .asm file.  The start of the bootloader looks like this:

BOOTSTRAP_ROM:SECTION
XDEFbootloader_main

bootloader_main:

; code here

 

The LCF places BOOTSTRAP_ROM into section BROM at 0xFE00.  The reset vector points to bootloader_main and all is well - unless I set INIT bootloader_main.

 

The only reason I did this was for the sake of having the debugger start there while I was doing some troubleshooting.  As far as I can tell from the documentation, it shouldn't have any effect on placement.

 

Without the INIT command, everything is fine, bootloader_main gets placed at 0xFE00 and calls PE's _EntryPoint when it's done.  With INIT set, it gets placed at the start of DEFAULT_ROM, along with its constants that were also declared in BOOTSTRAP_ROM.

 

If I use ORG $FE00 to place bootloader_main in an absolute section, the linker honors it.  It's only the relocatable section that's ignored.

 

I got it working again by removing the INIT command, but I'd like to know why this happens.  Does INIT have some other significance that's not covered in the manual?  Why would it ignore the defined sections?  Particularly for the constants, which have their own BOOTSTRAP_ROM: SECTION placement and aren't directly named by INIT.

 

Thanks,

 

Scott

Outcomes