[fpc-devel] How can I distribute code in two different memory areas? (.section)

Michael Ring mail at michael-ring.org
Sun Jun 2 23:15:30 CEST 2013

Unfortunately that does not seem to work (or I use it wrong):

This procedure:

procedure _general_exception_handler; assembler; nostackframe; public 
   .section "reset"
   sdbbp 0;
    b .Lloopb

translates to:

.section .text.n_pic32mx1xxfxxxc_$$__general_exception_handler
         .balign 4
         .type PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER, at function
         .type   _GENERAL_EXCEPTION_HANDLER, at function

.section reset
         sdbbp   0
         b       .Lj11
         jr      $ra
         .set    macro
         .set    reorder

which creates an assembler error:

Error: operation combines symbols in different segments

the error is from the .size line.

Am 02.06.13 22:51, schrieb Jeppe Græsdal Johansen:
> Den 02-06-2013 22:41, Michael Ring skrev:
>> Hi, perhaps I am overseeing a simple solution for my problem:
>> On the pic32 there are two flash areas, one at 0x9d000000 for the 
>> main program and another at 0xbfc00000 that is called Boot Flash. On 
>> reset the program starts in the boot flash at the first address.
>> I have written the startup code for the chips now but I need to 
>> distribute some procedures between the two memory areas, for obvious 
>> reasons I must have some code at address 0xbfc00000 or the chip will 
>> not boot correctly ;-).
>> My thought was now to tweak the linker script in the same way the 
>> original linker scripts of pic32 work:
>> {
>>   kseg0_program_mem    (rx)  : ORIGIN = 0x9D000000, LENGTH = 0x80000
>>   kseg1_boot_mem             : ORIGIN = 0xBFC00000, LENGTH = 0x490
>> }
>> {
>>   .reset _RESET_ADDR :
>>   {
>>     KEEP(*(.reset))
>>     KEEP(*(.reset.startup))
>>   } > kseg1_boot_mem
>> }
>> In assembler I can then simply write:
>>  .section .reset,code and
>>  .section .reset.startup,code
>> and then the code, this will automagically end up in the 
>> kseg1_boot_mem, but this does not work with the inline assembler. Any 
>> ideas on how to do this the correct way? Is there something more 
>> intelligent than to write a plain assembler file?
>> TnX,
>> Michael
> You should be able to use
> .section ".reset"
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130602/1aa23efb/attachment.html>

More information about the fpc-devel mailing list