Linker Scripts SECTIONS 部分的一個疑問

在M4 裏面Linker Scripts 看到有如下部分描述

SECTIONS
{
     .AppinInfo :
    {
        KEEP(*(.AppinInfo))
    }>FLASH = 0xff

}

一直沒搞明白 這個= 0xff 是什麼意思,相關中文網是找遍了也沒這部分解釋,於是只能找老外的網站了,尤其是要找到官方資料。

https://sourceware.org/binutils/docs/ld/Output-Section-Fill.html#Output-Section-Fill

3.6.8.8 Output Section Fill

You can set the fill pattern for an entire section by using ‘=fillexp’. fillexp is an expression (see Expressions). Any otherwise unspecified regions of memory within the output section (for example, gaps left due to the required alignment of input sections) will be filled with the value, repeated as necessary. If the fill expression is a simple hex number, ie. a string of hex digit starting with ‘0x’ and without a trailing ‘k’ or ‘M’, then an arbitrarily long sequence of hex digits can be used to specify the fill pattern; Leading zeros become part of the pattern too. For all other cases, including extra parentheses or a unary +, the fill pattern is the four least significant bytes of the value of the expression. In all cases, the number is big-endian.

You can also change the fill value with a FILL command in the output section commands; (see Output Section Data).

Here is a simple example:

SECTIONS { .text : { *(.text) } =0x90909090 }

原來是用來填充的!

We showed above that the full description of an output section looked like this:

section [address] [(type)] :
  [AT(lma)]
  [ALIGN(section_align) | ALIGN_WITH_INPUT]
  [SUBALIGN(subsection_align)]
  [constraint]
  {
    output-section-command
    output-section-command
    …
  } [>region] [AT>lma_region] [:phdr :phdr …] [=fillexp]

具體詳情可以看gcc ld 中文手冊,裏面很詳細介紹了Linker Scripts 的語法,看來還是要找對資料纔行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章