Menu

#2837 SDCC z80 places things in the wrong segment

open
None
Z80
5
2023-01-31
2018-11-17
Alan Cox
No

The attached code shows the two cases I have found where const data ends up in the wrong segment. The second one is quite weird. If you have no function referencing the const data then it ends up in the right segment. If it is followed by a routine that uses it then it ends up in code.

I don't understand why the no reference case emits it at all. It's static, and unreferenced so ought to just vanish.

Causes some really weird Fuzix breakages

sdcc -mz80 --constseg _CONST /tmp/1.c

1 Attachments
1.c

Discussion

  • Philipp Klaus Krause

    • Category: other --> Z80
     
  • Philipp Klaus Krause

    I can reproduce the problem for z80 in current SDCC 3.8.3 [r10680]. For stm8, on the other hand, this seems to work ok.

    Philipp

     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    Fixed in [r11146]. Thanks for the patch.

    Philipp

     
  • Alan Cox

    Alan Cox - 2019-03-29

    I only fixex fixed the one case... the static one is still busted when I tested it ?

     
  • Philipp Klaus Krause

    • status: closed-fixed --> open
     
  • Philipp Klaus Krause

    Reopened for the second case.

     
  • Philipp Klaus Krause

    As of current [r13845], I see the string in the correct segment, but the static struct array still in the wrong one. For both stm8 and z80.

     

    Related

    Commit: [r13845]

  • Philipp Klaus Krause

    I don't really know how to fix this in general. I'm a code generation person, and have some ideas about optimizations.
    But all that segment and linker-related stuff is unfamiliar ground me. In [r13846], I fixed the second issue for z80 and related, but I have no idea about how to fix it in general. Non-z80-related ports still put some stuff that should be in the const segment into the code segment instead.

     

    Related

    Commit: [r13846]


Log in to post a comment.

Monday.com Logo