星期三, 1月 30, 2008

__attribute__ 用法 - 續

會用到這個部份是在uboot中,有個特別section(.u_boot_cmd),從Makefile trace到code中,看到神奇的一行code
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
將所以有的cmd fuction都定義成這樣的模式並且在Struct_Section中為
#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))

所以在compile的時候,他就會把__u_boot_cmd_XXX的object code放到.u_boot_cmd的section中。

0 意見: