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.

使用ccs4.1.2编译器时,堆栈内存分配出错



以下一段程序是.cmd的一部分:

SECTIONS
{
   /* Setup for "boot to SARAM" mode:
      The codestart section (found in DSP28_CodeStartBranch.asm)
      re-directs execution to the start of user code.  */
     
 110   .stack           : > RAMM1,     PAGE = 1
       .ebss            : > DRAML0,    PAGE = 1
    .econst          : > DRAML0,    PAGE = 1     
    .esysmem         : > RAMM1,     PAGE = 1

     
     
     
    codestart        : > BEGIN,     PAGE = 0
    ramfuncs         : > RAMM0      PAGE = 0 
    .text            : > PRAML0,    PAGE = 0
    .cinit           : > RAMM0,     PAGE = 0
    .pinit           : > RAMM0,     PAGE = 0
    .switch          : > RAMM0,     PAGE = 0
    .reset           : > RESET,     PAGE = 0, TYPE = DSECT /* not used, */

 

编译出错提示:


<Linking>
warning: creating ".stack" section with default size of 0x400; use the -stack
   option to change the default size
"../2801_RAM_lnk.cmd", line 110: error: run placement fails for object
   ".stack", size 0x400 (page 1).  Available ranges:
   RAMM1        size: 0x50         unused: 0x50         max hole: 0x50     
error: errors encountered during linking; "T.out" not built

我不知道堆栈为什么不能分配内存,您能帮我吗?

  • JiaQing,

    这里出错的原因是 工程里设置了 0x400的空间来做堆栈,且这个空间分配在RAMM1中,但是RAMM1因为被工程其他数据或代码占用了许多,仅剩下0x50的空间,所以放不下,编译出错。

    解决的方法是:

    1. 把堆栈改小到 0x50,这样就可以了 ----- 右键工程属性 》 linker > stack size。

    2. 堆栈该小,0x400太大了,一般0x200就足够了,然后看能否把CMD中映射到RAMM1的段分配给RAMM0,这样RAMM1就有足够的空间了。

    Eric