ATF lds和代码section如何关联

lds 文件关联某些section ------汇编xx.s代码和xx.c代码


ATF bl31.ld.s 文件,其中一部分
/* Ensure 8-byte alignment for descriptors and ensure inclusion */
. = ALIGN(8);
__RT_SVC_DESCS_START__ = .;
KEEP(*(rt_svc_descs))  //保持不被gc 回收掉
__RT_SVC_DESCS_END__ = .;


c 语言定义section ,使用__attribute(section(xx))

#define DECLARE_RT_SVC(_name, _start, _end, _type, _setup, _smch) \
static const rt_svc_desc_t __svc_desc_ ## _name \
__section("rt_svc_descs") __used = { \
.start_oen = _start, \
.end_oen = _end, \
.call_type = _type, \
.name = #_name, \
.init = _setup, \
.handle = _smch }


出处来源:gcc complete ref
The __attribute__ keyword can be used to assign an attribute to a function or data
declaration. The primary purpose of assigning an attribute to a function is to make it
possible for the compiler to perform optimization. The attribute is assigned to a function
in the declaration of the function prototype,

section ---A function with this attribute will have its assembly language code placed into the named section instead of the default text section. The following is an example of a function being put
into a section named specials: void mspec(void) __attribute__((section(“specials”)));
This attribute will be ignored on systems that do not support sectioning. Also see -ffunction-sections in Appendix D



lds 文件定义
/*
* Ensure 8-byte alignment for cpu_ops so that its fields are also
* aligned. Also ensure cpu_ops inclusion.
*/
. = ALIGN(8);
__CPU_OPS_START__ = .; //new symbol,vma location counter assigns
KEEP(*(cpu_ops))
__CPU_OPS_END__ = .;

 



汇编中定义section

*
     * Convenience macro to declare cpu_ops structure.
     * Make sure the structure fields are as per the offsets
     * defined above.
     */
    .macro declare_cpu_ops _name:req, _midr:req, _noresetfunc = 0
    .section cpu_ops, "a"; .align 3 //allowable section
    .type cpu_ops_\_name, %object
    .quad \_midr
#if IMAGE_BL1 || IMAGE_BL31
    .if \_noresetfunc
    .quad 0
    .else
    .quad \_name\()_reset_func
    .endif
#endif
#if IMAGE_BL31
    .quad \_name\()_core_pwr_dwn //8Byte
    .quad \_name\()_cluster_pwr_dwn
#endif
#if (IMAGE_BL31 && CRASH_REPORTING)
    .quad \_name\()_cpu_reg_dump
#endif
    .endm



来源出处:
.section <section_name>
{,”<flags>”}
Starts a new code or data section. Sections in GNU are called
.text, a code section, .data, an initialized data section, and
.bss, an uninitialized data section. These sections have default
flags, and the linker understands the default names (similar
directive to the armasm directive AREA). The following are
allowable .section flags for ELF format files:
<Flag> Meaning
a allowable section
w writable section
x executable section

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值