当前位置: 代码迷 >> 综合 >> 在ARM平台上的C使用#pragma arm section
  详细解决方案

在ARM平台上的C使用#pragma arm section

热度:27   发布时间:2024-01-19 20:49:42.0

arm section section_sort_list

指定的代码或数据的节的名称用于随后的函数或对象。这包括编译器初始化创建的匿名对象的定义。选项??有没有效果:

内联函数(及其局部静态变量)
模板实例(及其局部静态变量)
消除未使用的变量和函数。 (虽然使用
pragma arm section可能使连接器,以消除函数或变量,否则将被保留,因为它是在同一节中使用的函数或变量。)
定义写入对象文件的顺序。
 pragma的完整语法是:

#pragma arm section [sort_type[[=]"name"]] [,sort_type="name"]*

其中name是名称使用的部分,sort_type是一个:


 rodata
 rwdata
 zidata

如果sort_type被指定名称不是sort_type 重置为默认值输入#pragma arm section所有对象部分名称,它们的默认值

int x1 = 5; // in .data (default)
int y1[100]; // in .bss (default)
int const z1[3] = {1,2,3}; // in .constdata (default)
#pragma arm section rwdata = "foo", rodata = "bar"
int x2 = 5; // in foo (data part of region)
int y2[100]; // in .bss
int const z2[3] = {1,2,3}; // in bar
char *s2 = "abc"; // s2 in foo, "abc" in .conststring
#pragma arm section rodata
int x3 = 5; // in foo
int y3[100]; // in .bss
int const z3[3] = {1,2,3}; // in .constdata
char *s3 = "abc"; // s3 in foo, "abc" in .conststring
#pragma arm section code = "foo"
int add1(int x) // in foo (code part of region)
{
return x+1;
}
#pragma arm section code


作为替代的#pragma arm section,使用GNU__ attribute__的功能属性描述函数或变量,。
使用ARM链接器来控制如何放置在内存中的一个特定的地址(见章RealView编译工具3.0版链接程序和实用程序指南中使用分散加载描述文件)分散加载描述文件。

  相关解决方案