PE 二进制文件中的部分名称真的有限制吗?

Is there really a limit to sections name in PE binaries?

一个awesome article关于PE格式的说明如下:

Name. Each section header has a name field up to eight characters long, for which the first character must be a period.

但我知道有几个例子违反了这一点,从二进制文件中的 .gnu_debuglink 部分开始,它们以 DWARF 格式分离了调试符号。 DWARF 的 .debug_arranges.debug_info 和其他人也违反了这一点。 (为了比较,PDB 的 "detached" 部分名称只是 .debug。)

所以我想知道这篇文章是否只是 outdated/incomplete,或者它可能是 Windows 特定的指南,或者对部分名称的长度从来没有任何限制?

另外,如果有人给我任何关于 PE/COFF 二进制文件(ELF 也很棒)的书,我会很高兴,比在线文章更全面,如果它存在的话。或者关于一般的系统编程——关于这个主题的信息非常稀少或者已经过时了 20 多年。 :)

COFF 中有一个 "long section names" 功能来支持不适合节名称字段的节名称。

对于长节名,正常的节名字段包含一个看起来像/4的名称,通常是/后跟一些十进制数字作为ASCII字符串。它编码的数字是符号 table 中的偏移量,因此在 PointerToSymbolTable(来自文件头)加上该偏移量。

目标文件中的段名没有限制,但可执行文件中的段名不能超过 8 个字节。来自 Microsoft 可移植可执行文件和 通用对象文件格式规范

An 8-byte, null-padded UTF-8 encoded string. If the string is exactly 8 characters long, there is no terminating null. For longer names, this field contains a slash (/) that is followed by an ASCII representation of a decimal number that is an offset into the string table. Executable images do not use a string table and do not support section names longer than 8 characters. Long names in object files are truncated if they are emitted to an executable file.

请注意,Windows PECOFF 加载器会忽略节的名称,因此除了作为调试信息的简单形式外,它们实际上并没有用于任何其他用途。

此外,名称不必以句号开头。这只是一个惯例,因此它们不会与用户定义的符号冲突。