• 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))

    1. #define DECLARE_RT_SVC(_name, _start, _end, _type, _setup, _smch) \
    2. static const rt_svc_desc_t __svc_desc_ ## _name \
    3. __section("rt_svc_descs") __used = { \
    4. .start_oen = _start, \
    5. .end_oen = _end, \
    6. .call_type = _type, \
    7. .name = #_name, \
    8. .init = _setup, \
    9. .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

    1. *
    2. * Convenience macro to declare cpu_ops structure.
    3. * Make sure the structure fields are as per the offsets
    4. * defined above.
    5. */
    6. .macro declare_cpu_ops _name:req, _midr:req, _noresetfunc = 0
    7. .section cpu_ops, "a"; .align 3 //allowable section
    8. .type cpu_ops_\_name, %object
    9. .quad \_midr
    10. #if IMAGE_BL1 || IMAGE_BL31
    11. .if \_noresetfunc
    12. .quad 0
    13. .else
    14. .quad \_name\()_reset_func
    15. .endif
    16. #endif
    17. #if IMAGE_BL31
    18. .quad \_name\()_core_pwr_dwn //8Byte
    19. .quad \_name\()_cluster_pwr_dwn
    20. #endif
    21. #if (IMAGE_BL31 && CRASH_REPORTING)
    22. .quad \_name\()_cpu_reg_dump
    23. #endif
    24. .endm



    来源出处:
    .section
    {,””}
    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:
    Meaning
    a allowable section
    w writable section
    x executable section

  • 相关阅读:
    一站制造项目及Spark核心面试 ,220808,,,
    协程并发下数据汇总:除了互斥锁,还有其他方式吗?
    小白文——计算机网络如何学??
    SHELL基础编程
    Java TreeMap类简介说明
    【Mapbox GL JS 入门】Hello world
    冯喜运:4.26最新外汇黄金美原油走势分析及操作策略
    设计模式学习笔记 - 规范与重构 - 5.如何通过封装、抽象、模块化、中间层解耦代码?
    鸿蒙知识点总结
    python魔术方法详解
  • 原文地址:https://blog.csdn.net/xuelin273/article/details/126487930