Hi,
SDCC uses very simple scheme for storing initialization data. It generates
two copies of variables, one copy is initialization data which is stored
after code section, and copied to variables area on startup. I think, it is
caused by very simple linkers supported. More complex linkers can do this
job instead of compiler, so result binary can be customized to generate
data section initialized, or separate initialization data. For example, GNU
LD may change LMA (load memory address, address after loading, before
startup) of data segment, so result will be same as produced by SDCC. But
you may exclude LMA changing, so VMA (virtual memory address, address where
program expects objects to be, "CPU memory") and LMA will be same - it is
what you want.

I have upgraded GNU Binutils to support SDCC. So you may generate assembler
for your code, then compile it by GNU AS and link by GNU LD (I suggest use
z80-unknown-elf toolchain). You may try to create your own liker script,
which stores INITIALIZER section to .data output section, and creates
INITIALIZED as separate section with same VMA as INITIALIZER but with
different LMA (I suggest put it out of address space). You need binutils
2.34+. I suggest master branch of their GIT repo (there are some useful
fixes and upgrades). Build using --target=z80-unknown-elf as configure
option. Also, you may vote for:
https://sourceforge.net/p/sdcc/feature-requests/666/

...
.text 0x8000 :
{
  __text_start = .;
  *(_HOME)
  *(_CABS)
  *(_CODE)
  *(_RODATA)
  *(.text *.text.* .gnu.linkonce.t.*) /* it is required for  proper section
attributes */
  __text_end = .;
}
.data :
{
  __data_start = .;
  *(_INITIALIZER)
  *(.data *.data.* .gnu.linkonce.d.*) /* it is required for  proper section
attributes */
  __data_end = .;
}
.bss :
{
  __bss_start = .;
  *(_DABS)
  *(_DATA)
  *(.bss *.bss.* .gnu.linkonce.b.*) /* it is required for  proper section
attributes */
  __bss_end = .;
}
.data_init ADDR(__data_start) : AT(0x10000) /* LMA is out of address space
*/
{
  *(_INITIALIZED)
}
...

Sergey

ср, 1 апр. 2020 г. в 11:01, Brad Robinson <brobin...@toptensoftware.com>:

> Hey All,
>
> I've got a Z80 project where the generated image will be loaded
> directly into RAM and therefore the initialization data doesn't need
> to be copied from the image to a specified RAM area.
>
> How can I configure SDCC to generate an image like this?  A working
> example would be great.
>
> Brad
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to