#112 _stack_end definition missing for pic16


This problem appears specific to mpic16. Using other
processors (such as z80) appears to work OK.

sdcc -mpic16 a.c

message: using default linker script
error: missing definition for symbol "_stack_end",
required by

cat a.c

int test;
void main() {
test = 0;

2.5.4 #1191 (Jan 13 2006) (UNIX)


  • Raphael Neider

    Raphael Neider - 2006-01-17
    • milestone: --> 100455
    • labels: --> 608414
    • status: open --> open-invalid
  • Raphael Neider

    Raphael Neider - 2006-01-17

    Logged In: YES

    This is no bug, its a feature:
    The pic16 port allows you to specify the location of your
    call-stack via pragmas. Use a line like
    #pragma stack 0x300 0xff
    to place your stack at [0x300..0x3ff], initial stack pointer
    will be 0x3ff, our stack grows downwards.
    This specification is required exactly once per project.

    And, yes: I should go and implement some default behaviour
    to suppress this error... as soon as I get an idea, i do it.
    BTW: This is documented behaviour, ever seen the SDCC Manual?


  • Richard Deeley

    Richard Deeley - 2006-01-17

    Logged In: YES

    Yes, I did see the manual. Spent some time looking for this
    specific information as well as a web search for these
    keywords. Without success, needless to say. Well, like the
    HHGG, I guess I should have found it.

    Thanks for the info.

  • Vangelis Rokas

    Vangelis Rokas - 2006-03-06
    • assigned_to: nobody --> vrokas
    • status: open-invalid --> open-accepted
  • Vangelis Rokas

    Vangelis Rokas - 2006-04-08

    Logged In: YES

    The idea is to have a small object that will allocate
    enough space for stack. This file will be placed in
    libsdcc.lib which is always used when SDCC links objects.
    The result will be the following, if the user has supplied
    a stack directive in the main() file then the linker will
    see _stack_end symbol and use that, otherwise it will have
    to load the symbol from the library.

    This approach eliminates the missing symbol error, but
    certainly will prevent users from understanding what's
    happening with stack and stack size.

    Would anyone disagree with this?

  • Maarten Brock

    Maarten Brock - 2006-04-08
    • milestone: 100455 -->
    • labels: 608414 -->
  • Maarten Brock

    Maarten Brock - 2006-04-08

    Logged In: YES


    This looks like a perfect solution. The understanding by
    the users will have to come from good documentation.

    I may seem pedantic about this, but I do not consider this
    a bug. It is documented behaviour as it is right now and
    your proposal is a very nice new feature. Therefor I move
    this to feature requests.


  • Philipp Klaus Krause

    • labels: --> pic16 target
    • status: open-accepted --> open

Log in to post a comment.