首页  >  问答  >  正文

c++ - 用gcc 如何在 .text section的某个特定的地址写入数据

1、现在我需要往.text(代码段)的某个地址插入一些数据。比如{'a','b','c','d','e','f','g','g'}
用的代码是char sgy_data2[32] __attribute__((section(".mysection1"))) = {'a','b','c','d','e','f','g','g'};
我的.text段起始地址为0XFFFE8000,然后我想在0XFFFE8400(.text总长大于1024)处写入数据,应该怎么操作?
2、如果有用过E2操作成功的能否告知是怎么设置的呐?

PHP中文网PHP中文网2660 天前977

全部回复(1)我来回复

  • phpcn_u1582

    phpcn_u15822017-06-10 09:50:37

    For E2:In order to have your data populated into your sections, you should take some additional steps. After adding the section, right click on it and add the following two expressions:
    .section-name
    .section-name.*
    (GNU 官方的解释)
    如果你不增加keep选项的话,不管你如何定义变量,都应该“用”一下这个变量,不然编译器会忽略这个变量,并且不会往bin文件中写入你想要的数据。
    至于其他的情况类似。

    .text 0xFFE00000 : AT (0xFFE00000)
        {
            *(.text)
            *(.text.*)
            *(P)
            etext = .;
        } > ROM
        
        相对应的你的gsi文件应该是这么样的

    回复
    0
  • 取消回复