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.
可以在代码中用#pragma DATA_SECTION ( symbol , " section name ")和#pragma CODE_SECTION (symbol , "section name ")伪指令来定义要显示的变量和函数,然后在cmd文件里把section name指定到具体的地址段。具体请参考下面的编译手册。
7.9.4 The CODE_SECTION Pragma
7.9.7 The DATA_SECTION Pragma
https://www.ti.com/lit/ug/sprui04b/sprui04b.pdf
/** * main.c */ #pragma DATA_SECTION ( s_Data , ".myData") #pragma CODE_SECTION ( s_func , ".text") int g_Data = 9; static int s_Data = 8; static int s_func() { return -1; } int g_func(int a) { return (a*5); } int main(void) { g_Data = s_func() + g_func(s_Data); return 0; }
GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name address name ------- ---- 008005c0 C$$EXIT 00830440 __TI_CINIT_Base 00830458 __TI_CINIT_Limit 00830434 __TI_Handler_Table_Base 0083043c __TI_Handler_Table_Limit 00830400 __TI_STACK_END 00000400 __TI_STACK_SIZE 0083040c __TI_STATIC_BASE UNDEFED __TI_TLS_INIT_Base UNDEFED __TI_TLS_INIT_Limit 008002c0 __TI_auto_init_nobinit_nopinit 00830400 __TI_cleanup_ptr 008005e0 __TI_decompress_none 00800600 __TI_decompress_rle24 00830404 __TI_dtors_ptr 00830408 __TI_enable_exit_profile_output ffffffff __TI_pprof_out_hndl ffffffff __TI_prof_data_size ffffffff __TI_prof_data_start 00800380 __TI_tls_init ffffffff __binit__ ffffffff __c_args__ 00800540 _args_main 00800620 _c_int00 00830000 _stack 00800580 _system_post_cinit 008005a0 _system_pre_init 008005c0 abort ffffffff binit 00800100 exit 0083040c g_Data 008004e8 g_func 00800508 main 00800440 memcpy 008001e0 memset
第一个是源代码,第二个是符号表,表中没有源代码中定义的静态变量s_Data和静态函数s_func的首地址。