Where are the stack, data and instruction segments implemented?
So memory segmentation was abandoned in x86-64, but when we use assembly we can specify .code and .data sections/segments in our code, and there is also the stack pointer register.
And the stack segment, data segment and code segment registers.
How and where does that division of code/data/stack happens, is it implemented by the CPU or OS?
Because when we debug and see the disassembly view of some C program, the address space is linear with no divisions.
And when they say that the data segment has "parts" for the globals, statics and the heap, this is OS abstraction?
You need to use a different model to think of memory usage. Think of memory using a program sections with attributes like:
These attributes can be set at the page level. In a system you could have the pages interleaved
Code-Data-Code-Data-Code-Data
Normally, linkers will put similar sections together but it can lay out the memory in nearly any way with paging. The usual mechanism is that if you give names to sections, linkers will collect and group things with the same section together.
You are no restricted by the segmentation system from Ye Olde 8086.
The parts are then governed by the operating system and the linker.
链接地址: http://www.djcxy.com/p/14454.html上一篇: Java的隐藏特性
下一篇: 堆栈,数据和指令段在哪里实施?