搬迁任务

发布于 2024-07-28 05:24:33 字数 160 浏览 10 评论 0原文

地址空间重定位和链接器完成的重定位任务有什么区别吗?据我所知,链接器完成的重定位任务包括将符号引用连接到符号定义的过程。当地址空间重定位时,就涉及到地址空间重定位。可执行文件将被带入内存,并且它的所有地址引用都是参考它被放置在内存中的位置的起始地址来解析的,不是吗?我也想知道这个地址空间重定位是谁做的??

Is there any difference between the address space relocation and the relocation task done by the linker??As far as I know ,relocation task done by the linker includes process of connecting the symbolic references to symbolic definitions.And address space relocation is concerned when the executable file is to be brought into the memory and all its address references are resolved with reference to the starting address of the place where it is being placed in the memory,isnt it??And I also want to know who does this address space relocation??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假装爱人 2024-08-04 05:25:01

你是对的。 操作系统中的进程加载器执行加载时重定位。 它实际上充当运行时链接器。

Yes, you're right. The process loader in the operating system does the load-time relocation. It in fact acts as a run-time linker.

小姐丶请自重 2024-08-04 05:24:51

处理器中有MMU(Memory Manegememt Unit)。 它为每个进程/程序提供了自己有限的内存空间。 这就是当今程序中的缓冲区溢出不会造成太大损害的原因。 这样每个程序都存在于自己的内存中。 操作系统处理这个。

编辑:

程序通常从仅红色位置(ROM/磁盘/闪存)运行,并且它们需要堆栈来存储临时值。 例如,在 c/c++ 中,几乎所有但定义为 char/int/long/float 的特殊值和数组当然都在堆栈上。
这意味着链接器仅使用并期望堆栈或程序本身中的数据(通常是只读的)

当程序需要额外的内存大小而无法在编译时定义时,它需要堆。 堆是通过 malloc 或 new (c/c++) 分配的,

但由于从 ram 读取通常比从其他类型的内存存储设备读取速度更快,因此操作系统将程序从磁盘复制到 ram 上并从那里开始执行程序。

There is MMU (Memory Manegememt Unit) in procesors. It gives each process/program its own limited memory space. This is the reason that buffer overflow in programs can not do much damage nowdays. This way each program lives in its own memory. OS handle this.

EDIT:

Programs generaly runs from red only locations (ROM/Disk/Flash) and they need stack for temporary values. For instatnce in c/c++ almost evertying but specialy values defined as char/int/long/float and arrays of course go on stack.
That mean that linker use and expect only data on stack or in program itself (which is generaly read only)

When program need extra memory in sizes which can not be defined in time of compilation it need heap. Heap is allocated whit malloc or new (c/c++)

But becuase reading from ram is usually faster than from other kind of memory storage divice, OS copy the program from disk on ram and start executing program from there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文