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

Jeppe Græsdal Johansen jeppe at j-software.dk
Mon Jun 17 08:53:30 CEST 2013

Den 17-06-2013 08:20, Sergei Gorelkin skrev:
> 16.06.2013 23:39, Michael Ring пишет:
>> I had some time this weekend (while beeing grilled by the sun on my 
>> balcony) to work on another
>> thing that did not work correct and that I did not understand (Now I 
>> do, I least I hope ;-)
>> As said before in this thread, I wanted to distribute Code in two 
>> different memory areas because
>> this needs to be done so that pic32 startup code works correctly.
>> But when I linked my binary the elf-file had always a startup address 
>> somewhere in the wrong memory
>> area.
>> This is what I tried:
>> procedure reset; assembler; nostackframe; public name'_reset';
>> asm
>>    .section ".reset,\"ax\", at progbits"
>>    la      $k0, _startup
>>    jr      $k0                      //Jump to startup code
>>    nop
>>    .text
>> end;
> In general, the custom section support in compiler needs a lot of 
> improvement...
> Try the following, maybe it could work:
> procedure anyname; assembler; nostackframe;
> asm
>    .section ".reset,\"ax\", at progbits"
> .globl _reset
> _reset:                                   // <-- correct name here
>    la  $k0, _startup
>    jr  $k0
>    nop
> .text
> end;
> Regards,
> Sergei
I agree that it needs some work. Having a way to specify the section 
with a procedure directive would largely be preferable I think. Such a 
directive could also be interesting for variables and typed constants

Also, I think
    .section ".reset"
should work just fine in most cases

More information about the fpc-devel mailing list