.section .text 和 .text with gas 的区别

Difference between .section .text and .text with gas

据我所知,使用 objdump,使用 gas

.section .text

.text

是等价的。这是真的?

来自气体手册 .section name:

Use the .section directive to assemble the following code into a section named name.

来自气体手册.text subsection:

Tells as to assemble the following statements onto the end of the text subsection numbered subsection, which is an absolute expression. If subsection is omitted, subsection number zero is used.

我的问题也适用于 .data

我认为有一点不同。

.section 允许程序员指定 any 部分名称,因此,如文档中所述,a.out 格式不支持(虽然它适用于 COFFELF).

This directive is only supported for targets that actually support arbitrarily named sections; on a.out targets, for example, it is not accepted, even with a standard a.out section name.

.text 相反,总是指定代码部分,而不管其在输出格式中的实际名称。

考虑到a.out之前被使用ELF是96年加回来的,兼容性我就不考虑了这么旧的格式是个问题。

.text.data 节省了几次击键,但为了保持一致性,始终使用 .section.

完全没问题