Menu

Ordering areas, and area symbols missing (custom crt0)

Help
Lex
2024-03-20
2024-05-09
  • Lex

    Lex - 2024-03-20

    I'm trying to write a custom crt0.s for the ZX Spectrum 48k. I want to avoid doing a copy for the initialised data (since the whole binary is loaded into RAM anyway) and have the whole binary be located at 0x8000 onwards.

    For now I have made minimal changes to the default Z80 crt0.s file, I have removed the vector table (already set up by the system before my program is loaded) and set the start address to 0x8000.

    When I look at the generated listing file, I see that the _HEADER area is at 0x8000, but then the _CODE area starts at 0. How am I supposed to make the _CODE section appear after the _HEADER section? I also don't see the s_<area> and l_<area> symbols being generated for all of the areas. For example, the _GSINIT area symbols are not listed in the sym file, while the s__DATA and l__DATA symbols are.

     
    • Philipp Klaus Krause

      Normally, for z80 and related, you choose the order in your crt0.s/crt0.o, and when linking, list that crt0.o first. The linker will pick up the order from the first file it sees, and when all areas are in that crt0.o, that will be the order for all of them.
      AFAIK, this can also be overridden using linker scripts, if necessary.

       

      Last edit: Philipp Klaus Krause 2024-03-21
      • Lex

        Lex - 2024-03-21

        I have done that, the order is specified in there with a bunch of .area commands, but some of the areas don't appear in the order I'd expect.

        A custom linker script would be ideal really. Where is the docuemtnation for how to write linker scripts?

         
        • Janko Stamenović

          Until somebody answers, maybe the workaround is to add this in the command line while compiling? --code-loc 0x8100 (depends on the length of the header, that's if it's 0x100 long)

           

          Last edit: Janko Stamenović 2024-03-25
  • Maarten Brock

    Maarten Brock - 2024-05-09

    The documentation for the linker is in asmlnk.txt
    SDCC creates a .lk file as the linker script when linking.

     

Log in to post a comment.