64 位应用程序的内存布局 [英] Layout in memory of 64-bit applications

查看:46
本文介绍了64 位应用程序的内存布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

64-bit OS 指的是通用寄存器的位宽.它能够一次处理 64 位(数据 + 操作).

64-bit OS refers to the bit width of the general purpose registers. It's able to process 64 bits (data + operations) at a time.

我们知道,为了让 64 位系统真正有用,程序员需要编写 64 位应用程序.

We know that in order for the 64-bit system to be truly useful, programmers need to write 64-bit applications.

但是,我想知道 32 位应用程序和 64 位应用程序之间的区别是什么?我不是在问编译 64 位应用程序需要进行哪些配置更改;相反,我想知道两个应用程序在内存中的结构差异.

However, I wonder what the difference is between a 32-bit application and a 64-bit application? I'm not asking what configuration changes I need to make to compile a 64-bit application; instead, I'd like to know the structural differences of the two applications in memory.

例如,Linux 上的 C 程序在内存中通常如下所示:

For example, a C program on Linux would typically look like this in memory:

  1. 文本片段
  2. 初始化数据段
  3. 未初始化的数据段
  4. 堆栈

我想 64 位应用程序在内存中的布局结构方面看起来是一样的,除了每个字节的地址(假设字节可寻址系统)有更多位.如果这是真的,那么 64 位意味着什么?只是更大的可寻址内存空间?

I'd imagine the 64-bit application would look the same in terms of layout structure in memory, except that the address for each byte (assuming byte addressable system) has more bits. If that's true, what does the 64-bit imply? simply larger addressable memory space?

另外,在编译 64 位应用程序时,让我们假设源代码中的一条指令被编译为汇编代码中的 add MIPS 指令:

Also, when a 64-bit application is compiled, let's assume one instruction in the source code is compiled into the add MIPS instruction in assembly code:

add $1 $2 $1 // $1 += $2;

每条 MIPS 指令都精确地编码为 32 位.那么问题来了,如果将应用程序配置为编译为 64 位应用程序,add 指令会是什么样子?它仍然有 32 位还是扩展到 64 位,这违反了 MIPS 规则?如果它仍然是 32 位,我看不出 64 位应用程序有什么不同,以便它充分发挥 64 位操作系统的作用".

Each MIPS instruction is encoded in exactly 32 bits. So here's the question, if an application is configured to be compiled as a 64-bit app, what would the add instruction look like? does it still have 32 bits or is it extended to 64 bit which breaks the MIPS rule? If it's still 32 bits, I don't see what difference a 64-bit app make so that it "brings 64 bit OS into full play".

请赐教.

推荐答案

首先,您使用 MIPS 标记了问题,但提出了一个一般性问题.MIPS 中 64 位应用程序的布局与其他 64 位架构不同.但是布局是事物在内存中的排列方式,而不是像你说的那样.这些段只是内存区域",几乎所有架构在其可执行文件中都有这些段

First, you tagged the question with MIPS but the ask a general question. The layout of 64-bit apps in MIPS aren't like in other 64-bit architectures. But layouts are how things are arranged in memory, not the segments like you said. Those segments are just memory "zones" and almost all architectures have those segments in their executables

64 位架构不仅是可寻址内存的扩展范围",而且还提供了新的指令集.因为一些旧指令不适用于 64 位数据,所以它们必须创建新指令来处理.

64-bit architectures are not simply an "extend range" of addressable memory but also provide a new instruction set. Because some of the old instructions don't work with 64-bit data so they must create new instructions to deal with.

关于指令,MIPS 64位仍然使用32位指令.如果它扩展到 64 位,那么它在添加的 32 位中包含什么,而另一个 32 位已经足够(如果不是有点多余)来表示所有参数.但是当然有许多针对 64 位数字的新指令(例如移位超过 31 或加载/存储双字...).顺便说一句,没有

About instructions, MIPS 64-bit still use 32-bit instruction. If it was extend to 64-bit then what would it contain in the added 32 bits while the other 32-bit was already enough (if not somewhat redundant) to represent all the arguments. But of course there were many new instructions for 64-bit numbers (such as shifting more than 31 or load/store double word...). And btw, the instruction is not correct without ,

这篇关于64 位应用程序的内存布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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