如何使用 MinGW 创建固定大小的内存段,将数据放置在段内的固定位置

How to create memory segment with fixed size, place data in fixed position inside the segment, using MinGW

我正在使用 MinGW 创建一个 win32 exe。 我想创建一个固定大小的内存段,然后将变量放在该段内相对于段开头的固定地址处。有没有人知道如何做到这一点?

我能够通过以下方式声明我自己的细分市场:

  .codeflash BLOCK(__section_alignment__) :
  {
    __codeflash_start__ = . ;
    *(.codeflash)
    __codeflash_end__ = . ;    
  }

并使用以下方法将变量放入此段中:

__attribute__((section(".codeflash"))) 

我正在使用默认链接描述文件。

谢谢。

比方说从段开始的 0x100 个字节

  .codeflash BLOCK(__section_alignment__) :
  {
    . += 0x100;
    __codeflash_start__ = . ;
    KEEP(*(.codeflash))
    KEEP(*(.codeflash*))
    __codeflash_end__ = . ;    
  }

我使用上面的建议来解决问题: 将所有内容添加到结构并将此结构放入部分。