凡在栈,数据和指令段实施? [英] Where are the stack, data and instruction segments implemented?

查看:148
本文介绍了凡在栈,数据和指令段实施?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以内存分割在x86-64的抛弃,但是当我们使用汇编,我们可以指定。code和我们code。数据段/网段,而且还有堆栈指针寄存器。

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.

和堆栈段,数据段和code段寄存器。

And the stack segment, data segment and code segment registers.

如何以及哪里code /数据/堆栈中的那个部门情况发生,它是由CPU或操作系统实现的?

How and where does that division of code/data/stack happens, is it implemented by the CPU or OS?

由于当我们调试,看到一些C程序反汇编视图,地址空间是没有分歧的线性。

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:


  • code:可执行性,可读性,没有写

  • 静态数据:不可执行性,可读性,NOWRITE

  • 修改的数据:不可执行的,可读,可写
    (您也可以补充需求为零的区域)

这些属性可以在页面级别进行设置。在一个系统中,你可以有网页交错

These attributes can be set at the page level. In a system you could have the pages interleaved

code-数据 - code-数据 - code-数据

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.

您没有被分割系统从叶奥尔德8086限制。

You are no restricted by the segmentation system from Ye Olde 8086.

的部件,然后由操作系统和接头管辖。

The parts are then governed by the operating system and the linker.

这篇关于凡在栈,数据和指令段实施?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆