ELF:使用段大小计算地址跨度
ELF: Using the section size to calculate an address span
我想知道一个部分的大小与该部分占用的地址 space 的关系。 (我在这里不假设动态加载或 MMU)
如果有的话,section size 是否包括 0 size 符号?
例如,假设一个部分大小为 100 字节长,从地址 0 开始。我天真地假设该部分采用的地址 space 将从 0 到 100。
但是假设在地址 0、1、2 和 3 处有符号,它们的大小为 0 但确实有一个与之关联的地址,那么实际地址 space 将是 0-103 0-3 为空?
有这样的符号吗?
我是 ELF 格式的新手,不是 100% 确定它是如何工作的。
I was wondering about the size of a section in relation to the address space the section occupies.
节通常不占用任何地址——段占用。
ELF
代表可执行和 link 可用格式,具有双重用途:(静态)linking 和执行。
在 linking 阶段,linker 对 sections 进行操作,并将它们分配给 0 个或多个段(但通常最多1 个可加载段)。某些部分,例如 .note
或 .comment
通常没有设置 SHF_ALLOC
标志,并且不会在 any 可加载段中结束。
请注意,静态 link 之后不需要部分,可以完全删除。
在执行阶段,可加载段被mmap
编入地址space。如果一个部分的大小为 100,有 SHF_ALLOC
标志,并被分配给某个 PT_LOAD
段,那么该部分将占用地址 space.
的 100 个字节
(I am not assuming dynamic loading or MMUs here)
动态 linking 和 MMU 与这里发生的事情完全正交。提起他们只会把水搅浑。
For instance say a section size is 100 bytes long and starts at address 0. Naively I would assume that the address space taken by this section would be from 0 to 100.
如上所述,您的世界观并不完全准确,该部分不太可能实际占据 [0, 100)
地址范围。
Assuming however that there are symbols there at address 0, 1, 2 and 3 which have a size of 0 but do have an address associated with them then the actual address space would be 0-103 with 0-3 as being empty?
符号只是 标签 附加到某些地址。他们自己不占用任何地址space。它们也可以在(静态)link 之后完全剥离,尽管通常它们被保留以简化调试。这些符号/标签的存在允许调试器告诉您您的程序在例如崩溃。 fscanf
从 foo
调用,从 main
调用。
我想知道一个部分的大小与该部分占用的地址 space 的关系。 (我在这里不假设动态加载或 MMU)
如果有的话,section size 是否包括 0 size 符号?
例如,假设一个部分大小为 100 字节长,从地址 0 开始。我天真地假设该部分采用的地址 space 将从 0 到 100。
但是假设在地址 0、1、2 和 3 处有符号,它们的大小为 0 但确实有一个与之关联的地址,那么实际地址 space 将是 0-103 0-3 为空?
有这样的符号吗? 我是 ELF 格式的新手,不是 100% 确定它是如何工作的。
I was wondering about the size of a section in relation to the address space the section occupies.
节通常不占用任何地址——段占用。
ELF
代表可执行和 link 可用格式,具有双重用途:(静态)linking 和执行。
在 linking 阶段,linker 对 sections 进行操作,并将它们分配给 0 个或多个段(但通常最多1 个可加载段)。某些部分,例如 .note
或 .comment
通常没有设置 SHF_ALLOC
标志,并且不会在 any 可加载段中结束。
请注意,静态 link 之后不需要部分,可以完全删除。
在执行阶段,可加载段被mmap
编入地址space。如果一个部分的大小为 100,有 SHF_ALLOC
标志,并被分配给某个 PT_LOAD
段,那么该部分将占用地址 space.
(I am not assuming dynamic loading or MMUs here)
动态 linking 和 MMU 与这里发生的事情完全正交。提起他们只会把水搅浑。
For instance say a section size is 100 bytes long and starts at address 0. Naively I would assume that the address space taken by this section would be from 0 to 100.
如上所述,您的世界观并不完全准确,该部分不太可能实际占据 [0, 100)
地址范围。
Assuming however that there are symbols there at address 0, 1, 2 and 3 which have a size of 0 but do have an address associated with them then the actual address space would be 0-103 with 0-3 as being empty?
符号只是 标签 附加到某些地址。他们自己不占用任何地址space。它们也可以在(静态)link 之后完全剥离,尽管通常它们被保留以简化调试。这些符号/标签的存在允许调试器告诉您您的程序在例如崩溃。 fscanf
从 foo
调用,从 main
调用。