This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using __text__ directive with CCS?

Other compilers I've used support directives that allow C programs to get the length of my text segment at run time, but I can't find anything in the CCS version 5.1.6 documentation.

I know that the linker outputs a .map file that includes the necessary symbols (e.g., .text, etext) but how can I access these from the C program?  I need to know the starting and ending address of the text segment and its length.

Thanks -- Mike

 

  • While you can rely on symbols predefined by the linker like .text and etext, it is pretty easy to just create your own in the linker command file.  Here is one way to create your own symbols named TEXT_START and TEXT_SIZE.

        .text > RAM, RUN_START(TEXT_START), RUN_SIZE(TEXT_SIZE)

    Referring to these symbols in C is straightforward, but a bit non-intuitive.  This post describes it in detail.

    Thanks and regards,

    -George