V
V
Venot2020-12-19 02:11:55
assembler
Venot, 2020-12-19 02:11:55

Are the data segments of the code a division for the assembler or is it stored in the machine code like that?

In assembler, the program has a section .text, .bss, .data. I understand that the data and program code are stored there, it’s interesting when compiling into machine code, is it also divided into segments for execution by the processor, or is it just for syntax convenience?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-12-19
@jcmvbkbc

In assembler, the program has a section .text, .bss, .data

Usually these sections are called sections and not segments. Because there are segments in ELF files too, but they don't have names.
when compiling to machine code, it is also divided into segments there

Broken, yes. And when linking, some sections can be combined. Usually immutable sections (eg .text, .rodata, .tls) are merged into one heap, and all mutable ones (eg .bss, .data) are merged into another heap. On "large" operating systems (such as linux), these heaps are page-aligned and make the immutable sections read-only. This helps to save memory and use the same pages to represent immutable data across processes.
to be executed by the processor

The processor, by and large, does not care how what it performs is located in memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question