[英]what is the difference of Address space segment and Program memory segment in memory?
1、there are sections like .text, .data, .bss etc in a executable file. 1,可执行文件中有.text,.data,.bss等部分。
2、and there are also Program memory segment(code,initialized data, uninitialized data(BSS),heap,stack)which can be mapped from sections in executable file. 2,还有程序存储段(代码,初始化数据,未初始化数据(BSS),堆,堆栈),可以从可执行文件的各个部分进行映射。
Above each, i can understand what it is,section is placed in disk while segment is placed in memory while the program is loaded. 在每个上方,我可以理解它是什么,在程序加载时,段放在磁盘中,而段放在内存中。 and when the program begins to run, Initialized data,BSS,Heap segment are all placed into Data segment, the following table describes more details:
当程序开始运行时,初始化数据,BSS,堆段都放入了数据段中,下表描述了更多详细信息:
This table is referenced from http://www.tenouk.com/ModuleW.html Table w.6: 可从http://www.tenouk.com/ModuleW.html表w.6引用此表:
my question is what is the difference of Address space segment and Program memory segment in memory?
我的问题是内存中的地址空间段和程序存储段有什么区别?
They're just different ways of referring to the same segments in memory.. 它们只是引用内存中相同段的不同方式。
The exact way in which these sections/segments are dealt with is obviously implementation specific - with the layout of the file depending on the specific executable format and linker used , and the layout of the program in memory again depends on the executable format utilised and the OS loader. 处理这些节/段的确切方法显然是特定于实现的-文件的布局取决于所使用的特定可执行文件格式和链接器,而程序在内存中的布局又取决于所使用的可执行文件格式和操作系统加载程序。 As an example of this, according to this discussion of the PE file format - http://msdn.microsoft.com/en-us/library/ms809762.aspx - one of the Borland linkers used to drop the .bss section from the executable file and instead combine it with the .data section - I suspect there are many examples of similar variabilities depending on the different flavors of OS/Linkers/Executable formats used.
例如,根据对PE文件格式的讨论-http: //msdn.microsoft.com/en-us/library/ms809762.aspx-一种Borland链接程序之一,用于从文件中删除.bss部分可执行文件,而不是将其与.data节结合使用-我怀疑有很多类似的示例,这些示例取决于所使用的OS / Linkers / Executable格式的不同形式。
In the memory no difference. 在内存上没有区别。
But, usually they have separated caches. 但是,通常它们具有分开的缓存。 Also, in the virtual memory table, code segment is marked as such, so trying to execute something that is not code segment will crash the program.
同样,在虚拟内存表中,代码段也被标记为这样,因此尝试执行非代码段的操作会使程序崩溃。
Note that this actually vary from platform to platform. 请注意,这实际上因平台而异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.