开发者

Why do we need to define .data and .text section in assembly?

开发者 https://www.devze.com 2023-04-01 03:25 出处:网络
I\'m reading an assembly book. The book explains that there are .text and .data section in a computer\'s memory. An example in the book also use the following source code.

I'm reading an assembly book. The book explains that there are .text and .data section in a computer's memory. An example in the book also use the following source code.

[SECTION .data]

[SECTION .text]

since the above code snippet is written in assembly, I have a question.

Do .data and .text codes separated in ph开发者_如何转开发ysical memory (if so why? and does CPU care?) ? or is it just us (human) to separate them in the assembly language?


Text section of application is read-only while Data is not. Many OS load Text section into memory only once no matter how many times application was launched. This reduce memory usage and launch time and is safe because code doesn't change. Data section contains informations that could be changed during application execution and this section must be copied for every instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号