64 bit application: layout in memory

本秂侑毒 提交于 2019-12-06 07:51:03

问题


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.

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

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.

For example, a C program on Linux would typically look like this in memory: 1, text segment 2, initialized data segment 3, uninitialized data segment 4, heap 5, stack

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?

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;

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".

Please enlighten me.


回答1:


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-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.

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 ,



来源:https://stackoverflow.com/questions/20679770/64-bit-application-layout-in-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!