本部分内容了解一下,目前尚未见到谁在用。

S 标志(包含以零结尾的字符串)

文档说明:

“If flags contains the S flag then the section contains zero-terminated strings. The size of each character in the string is specified in octets by the entity size, entsize, which defaults to 1, but can be set using the syntax: .section name, “aS”, @progbits, entsize”

flag_specific_arguments 在这里是entsize(实体大小),指定字符串中每个字符的大小(以字节为单位)

M 标志(可合并段)

文档说明:

“If flags contains the M flag then the type argument must be specified as well as an extra argument—entsize—like this: .section name, “aM”, @progbits, entsize”

flag_specific_arguments 在这里是entsize(实体大小),指定合并段中每个元素的大小

文档进一步解释:

  • 对于有 M 标志但没有 S 标志的段,必须包含固定大小的常量
  • 链接器可以移除具有相同名称、相同实体大小和相同标志的段中的重复项
  • entsize 必须是一个绝对表达式

o 标志(引用其他段)

文档说明:

“If flags contains the o flag, then the type argument must be present along with an additional field like this: .section name, “ao”, @type, SymbolName”

flag_specific_arguments 在这里是

  • SymbolName:指定该段引用的符号名称
  • 或者 SectionIndex:段索引(用于测试目的)

G 标志(段组成员)

文档说明:

“If flags contains the G symbol then the type argument must be present along with an additional field like this: .section name, “aG”, @progbits, GroupName[, linkage]”

flag_specific_arguments 在这里是

  • GroupName:指定此段所属的段组名称
  • 可选的 linkage 字段可以是:
    • comdat:表示此段的唯一副本应被保留
    • one_onlycomdat 的别名

组合标志的参数顺序

文档中还详细说明了当多个标志组合时的参数顺序:

MSEo 标志组合

“Note: If both one of M, S, or E and o flags are present, then the type and entry size fields should come first, like this: .section name, “aMo”, @progbits, entsize, SymbolName”

MSEG 标志组合

“Note: If both one of M, S, or E and G flags are present then the type and entry size fields should come first, like this: .section name, “aMG”, @progbits, entsize, GroupName[, linkage]”

oG 标志组合

“If both o flag and G flag are present, then the SymbolName field for o comes first, like this: .section name, “aoG”, @type, SymbolName, GroupName[, linkage]”

其他相关说明

? 标志的特殊性

文档提到:

“If flags contains the ? symbol then it may not also contain the G symbol and the GroupName or linkage fields should not be present.”

? 标志表示继承前一段的属性,因此不需要额外的参数。

唯一标识符参数

文档最后提到:

“The optional unique, ID argument must come last. It assigns ID as a unique section ID to distinguish different sections with the same section name…”

这可以看作是 flag_specific_arguments 的一种特殊形式,用于为同名的段分配唯一ID。