Using Not used variables

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Using Not used variables

2,139 次查看
BAN
Contributor II
Hi!
 
I'm using a lot of constant variables in a table and the code is written in a way that the linker cannot see that they are used and hence they will not be linked into the application. To avoid this I'm forced to do a dummy read for each variable.
 
Is there a way to tell the linker that the variables inside this segment must be linked even if they seem to be unused??
 
//Bengt
标签 (1)
0 项奖励
回复
2 回复数

722 次查看
stanish
NXP Employee
NXP Employee
Hi BAN,

This depends on CodeWarrior you are using. Could you specify which CodeWarrior you mean?

e.g. 8/16 bits CW: in linker parameter file (.prm) you can use:

ENTRIES   /* switch off smart linking to get unreferenced vector table */
 vectab                                                                            
END   
     

in other CW e.g. CW for MPC55xx  you can use  FORCEACTIVE keyword in the linker command file .lcf:

FORCEACTIVE { symbol1 symbol2 ... }


For more information I'd suggest you to see appropriate Build tools manual

Stanish
0 项奖励
回复

722 次查看
Lundin
Senior Contributor IV
In the .prm file, add each variable name below "ENTRIES":

ENTRIES
  x
END


/* C file */

#pragma CONST_SEG MY_CONST_DATA

int x my_table[N] = {...};

#pragma CONST_SEG DEFAULT

0 项奖励
回复