Menu

#2312 Entry labels for global functions are not marked as global labels

closed-fixed
Ben Shi
Z80
5
2015-04-04
2014-11-11
Kio
No

compiling .c file:

void main(){}

results in .s file:

...
_main_start::
_main:
ret
_main_end::
...

The entry label for main() is followed by ':' but should be followed by '::' to indicate a global label.

With sdas this does not harm, but an alternate assembler (e.g. my zasm) could just ignore the .globl pseudo opcode (which tells the linker that it's global) and rely on the ':' or '::' respectively for label resolution, if they were correct. Currently i added some not-so-sane code to handle this in zasm. :/

Discussion

  • Ben Shi

    Ben Shi - 2015-03-17

    What about keeping the .globl pseudo opcode, while emitting "::" for global functions and ":" for static ones?

    Something like changing line 4391@z80/gen.c

    from

    emit2 ("!functionlabeldef", sym->rname);

    to

    if (!IS_STATIC (sym->etype))
    emit2 ("!functionlabeldef_global", sym->rname);
    else
    emit2 ("!functionlabeldef", sym->rname);

     
  • Maarten Brock

    Maarten Brock - 2015-03-17

    I guess this depends on the other assembler supporting :: for global labels. Is this a common concept?

     
  • Ben Shi

    Ben Shi - 2015-03-17

    If not common, I vote for rejecting this ticket.

     
  • Ben Shi

    Ben Shi - 2015-04-02
    • status: open --> closed-fixed
    • assigned_to: Ben Shi
     
  • Ben Shi

    Ben Shi - 2015-04-02

    Fixed in reversion #9205 by adding a "globalfunctionlabeldef". I thought,

    1. This change does no harm to sdcc itself.
    2. At least can benefit zasm, and potentially other z80 assemblers.
     
  • Kio

    Kio - 2015-04-04

    thats nice and thanks for that. :)
    i'll test the new version when i'm back on zasm.

     

Log in to post a comment.