使用__attribute__((at()))来进行绝对定位

  • 定位结构体地址

typedef struct {
    uint32_t magic_word;        /*!< Magic word ESP_APP_DESC_MAGIC_WORD */
    uint32_t secure_version;    /*!< Secure version */
    uint32_t reserv1[2];        /*!< --- */
    char version[32];           /*!< Application version */
    char project_name[32];      /*!< Project name */
    char time[16];              /*!< Compile time */
    char date[16];              /*!< Compile date*/
    char idf_ver[32];           /*!< Version IDF */
    uint8_t app_elf_sha256[32]; /*!< sha256 of elf file */
    uint32_t reserv2[20];       /*!< --- */
} sprt_app_desc_t;

/* MDK AC5 */
__attribute__((at(0x08000000))) const uint32_t cnt;
//cnt                                      0x08000000   Data           4  main.o(.ARM.__AT_0x08000000)

__attribute__((at(0x08000004))) const sprt_app_desc_t sprt_app_desc = {
	.version = "version",
	.time = __TIME__,
	.date = __DATE__,
};
//sprt_app_desc                            0x08000004   Data         256  main.o(.ARM.__AT_0x08000004)

__attribute__((at(0x20000000))) sprt_app_desc_t sprt_app_desc = {
	.version = "version",
	.time = __TIME__,
	.date = __DATE__,
};
//sprt_app_desc                            0x20000000   Data         256  main.o(.ARM.__AT_0x20000000)

__attribute__((at(0x20001000))) uint32_t cnt;
//cnt                                      0x20001000   Data           4  main.o(.ARM.__AT_0x20001000)

/* MDK AC6 */
/* section 等价 __section__ */
__attribute__((section(".ARM.__at_0x08000000"))) const uint32_t cnt;
//cnt                                      0x08000000   Data           4  main.o(.ARM.__at_0x08000000)

__attribute__((__section__(".ARM.__at_0x08000004"))) const sprt_app_desc_t sprt_app_desc = {
	.version = "version",
	.time = __TIME__,
	.date = __DATE__,
};
//sprt_app_desc                            0x08000004   Data         256  main.o(.ARM.__at_0x08000004)

__attribute__((section(".ARM.__at_0x20000000"))) uint32_t cnt;
//cnt                                      0x20000000   Data           4  main.o(.ARM.__at_0x20000000)

__attribute__((section(".ARM.__at_0x20000004"))) sprt_app_desc_t sprt_app_desc = {
	.version = "version",
	.time = __TIME__,
	.date = __DATE__,
};
//sprt_app_desc                            0x20000004   Data         256  main.o(.ARM.__at_0x20000004)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值