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

Pierre Free Pascal pierre at freepascal.org
Mon Jun 17 15:54:04 CEST 2013


  Maybe the section keyword that was introduced for embedded systems for variables
(see compiler/pdecvar.pas unit, look for _SECTION and try_consume_sectiondirective)
should be extended to function/procedure header parsing.


procedure reset; assembler; nostackframe; public name'_reset'; section '.reset,"ax", at progbits';
would then do all you want.

Pierre Muller

> -----Message d'origine-----
> De : fpc-devel-bounces at lists.freepascal.org [mailto:fpc-devel-
> bounces at lists.freepascal.org] De la part de Jeppe Græsdal Johansen
> Envoyé : lundi 17 juin 2013 08:54
> À : FPC developers' list
> Objet : Re: [fpc-devel] How can I distribute code in two different memory
> areas? (.section)
> 
> 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
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list