I work with pe files analyzer sofwares like exeinfoPe and in section list part there are both .text and CODE section types that we can use them for example change .data name to .text or CODE or other section names. are these section typesthe same? what is difference between them?
2 Answers
There is no functional difference between the .text
and .code
sections of a binary.
In almost all cases, they are completely synonymous (meaning that they refer to the same section), but even when they're not (e.g. due to the actual order of sections in the binary), they are semantically identical.
This is the section of the object file or address space that contains executable instructions ("code"), which are stored as plain text ("text"). It is almost always read-only, unlike the .data
section.
Consult the documentation for your assembler, compiler, linker, or disassembler to see which name it prefers. The PE format uses .text
.
There is no semantic difference between the .CODE
and .TEXT
sections.
Just as in the MASM
assembler, the instruction space address is named by .CODE
section, and in other compilers is named by .CODE
.
So when you assemble your code with MASM
you will see .CODE
section as well as .TEXT
.
.code
and.text
segments are synonymous. Otherwise segments are usually not interchangeable. For example, those are read-only on many architectures.CODE
is a section flag and.text
a section name. While the name of a section gives a pretty good clue what its used for, a section can be named anything and it's the section flags that determine what it can be used for.CODE
, specificallyIMAGE_SCN_CNT_CODE
, is a section flag that could, in combination with other flags, or absence of other flags, be considered to denote the type of a section,.text
is just section name. By convention it has the flagsIMAGE_SCN_CNT_CODE|IMAGE_SCN_MEM_EXECUTE|IMAGE_SCN_MEM_READ
but sections with different names can also have this "type", and a section named.text
can, at least in theory, have other flags. See the PECOFF spec for more details: msdn.microsoft.com/en-us/library/windows/desktop/…