最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

about #pragma arm section in C source code for ARM platform

工作和技术 crifan 4039浏览 0评论

RealView® Compilation Tools
Version 3.0
Compiler and Libraries Guide

Pragmas controlling code generation
The following pragmas control how code is generated (other code generation options
are available from the compiler command line, see Controlling code generation on
page 2-43):

arm section section_sort_list
Specifies that the Code or Data section name is used for subsequent
functions or objects. This includes definitions of anonymous objects the
compiler creates for initializations. The option has no effect on:
• inline functions (and their local static variables)
• template instantiations (and their local static variables)

• elimination of unused variables and functions. (Although, using
#pragma arm section might enable the linker to eliminate a function
or variable that would otherwise be kept because it is in the same
section as a used function or variable.)
• the order that definitions are written to the object file.

The full syntax for the pragma is:
#pragma arm section [sort_type[[=]"name"]] [,sort_type="name"]*
Where name is the name to use for the section, and sort_type is one of:
• code
• rodata
• rwdata
• zidata.
If sort_type is specified but name is not, the section name for sort_type is
reset to the default value. Enter #pragma arm section on its own to restore
the names of all object sections to their defaults (see Example 3-1).

Example 3-1 Section naming
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

As an alternative to #pragma arm section, use GNU __attribute__((section(..))) for
functions or variables, as described in Function attributes on page 3-51.
Use a scatter-loading description file with the ARM linker to control how to place a
named section at a particular address in memory (see the chapter Using Scatter-loading
description files in RealView Compilation Tools v3.0 Linker and Utilities Guide).

转载请注明:在路上 » about #pragma arm section in C source code for ARM platform

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 还是没看明白
    匿名网友15年前 (2009-09-07)回复
82 queries in 0.191 seconds, using 22.08MB memory