DSP

CCS build error: relocation overflow

2019-07-13 19:01发布

注:此文为转载,原文地址:http://dpinglee.blog.163.com/blog/static/14409775320108482431820/ DSP程序编译进行build时,出现如下错误提示:
cgtoolsincl6x" -@"Debug.lkf" >> error: relocation overflow occured at address 0x00000074 in section '.text' of input file 'e: imyprojectss_testDebug est.obj'. The 21-bit relocated address 0x11238f is too large to encode in the 15-bit field. You may need to add a mask to the assembly instruction or use other target specific assembly features if you really only need the lowest 15 bits of this symbol. Please see the section on Relocation in the Assembly User's Guide. 原因分析: 一般是程序变量定义所在位置超出所在的段所能寻址的最大地址范围。 解决方法: 在CCS下设置Project->Build Options->Compiler->Advanced->Memory Models为
'far calls and data'或者更远选项,默认设置为,'near calls and data' 一般情况下可以解决这种问题。
具体原因,可以参考《TMS320C6x Optimizing C Compiler User’s Guide.pdf》 8.1.5 小节:Large and Small Memory Models:
-----------------------------------------------
The compiler supports two memory models that affect how the .bss section is allocated into memory. Neither model restricts the size of the .text or .cinit sections.
〉〉 The small memory model, which is the default, requires that the entire .bss section fit within 32K bytes (32,768 bytes) of memory. This means that the total space for all static and global data in the program must be less than 32K bytes. The compiler sets the data-page pointer register (DP,which is B14) during runtime initialization to point to the beginning of the .bss section. Then the compiler can access all objects in .bss (global and static variables and constant tables) with direct addressing without modifying the DP.
〉〉The large memory model does not restrict the size of the .bss section;
unlimited space is available for static and global data. However, when the compiler accesses any global or static object that is stored in .bss, it must first load the object’s address into a register before a global data item is accessed. 
----------------------------------------------------
而在上述提到的error中提到:The21-bit relocated address 0x11238f is too large to encode in the 15-bit field. 15-bit应该就是对section限制为32Kbyte,但实际程序中申请的空间已远远大于这个数值,因此应该选泽The large memory model 才行。