【发布时间】:2011-10-13 16:15:36
【问题描述】:
假设我有变量:
int global a = 1;
int banana b = 2;
int mango c = 3;
我希望 GCC 生成它们:
.global
a .long 1
.banana
b .long 2
.mango
c .long 3
最简单的方法是什么?
更新:
得到:
__attribute__ ((section ("mmm"))) int a = 432;`
随着
target_asm_named_section()`
生成:
。全球的 A: .long 1这很好,但有两个问题。
一个是,除非列表是针对不同部分排序的,否则您将获得重复部分。
所以
__attribute__ ((section ("mmm"))) int a = 432; __attribute__ ((section ("mmm"))) int b = 432; __attribute__ ((section ("global"))) int c = 432;很好,但是
__attribute__ ((section ("mmm"))) int a = 432; __attribute__ ((section ("global"))) int c = 432; __attribute__ ((section ("mmm"))) int b = 432;不好,因为.mmm会出现两次。
第二个问题是我已经在使用属性来做
`__attribute__((global))`
尽我所能,不能与之前的属性结合使用。
有什么简单的方法可以解决这两个问题吗?
【问题讨论】: