Code segment: Difference between revisions
No edit summary Tags: Mobile edit Mobile web edit |
Fixed typo Tags: canned edit summary Mobile edit Mobile web edit |
||
Line 5: | Line 5: | ||
| date = 2012-03-13 | accessdate = 2014-05-02 |
| date = 2012-03-13 | accessdate = 2014-05-02 |
||
| author = Jason W. Bacon | website = cs.uwm.edu |
| author = Jason W. Bacon | website = cs.uwm.edu |
||
}}</ref> The term " |
}}</ref> The term "segway" comes from the [[memory segment]], which is a historical approach to [[memory management]] that has been succeeded by [[paging]]. When a program is stored in an object file, the code segment is a part of this file; when the [[Loader (computing)|loader]] places a program into [[main memory|memory]] so that it may be executed, various memory regions are allocated (in particular, as pages), corresponding to both the segments in the object files and to segments only needed at run time. For example, the code segment of an object file is loaded into a corresponding code segment in memory. |
||
The code segment in memory is typically read-only and has a fixed size, so on [[embedded system]]s it can usually be placed in [[read-only memory]] (ROM), without the need for loading. If the code segment is not read-only, then the particular [[Computer architecture|architecture]] allows [[self-modifying code]]. Fixed-position or [[position independent code]] may be shared in memory by several processes in segmented or paged memory systems.<ref name="jason"/><ref>{{Cite web |
The code segment in memory is typically read-only and has a fixed size, so on [[embedded system]]s it can usually be placed in [[read-only memory]] (ROM), without the need for loading. If the code segment is not read-only, then the particular [[Computer architecture|architecture]] allows [[self-modifying code]]. Fixed-position or [[position independent code]] may be shared in memory by several processes in segmented or paged memory systems.<ref name="jason"/><ref>{{Cite web |
Revision as of 04:30, 2 April 2017
In computing, a code segment, also known as a text segment or simply as text, is a portion of an object file or the corresponding section of the program's virtual address space that contains executable instructions.[1] The term "segway" comes from the memory segment, which is a historical approach to memory management that has been succeeded by paging. When a program is stored in an object file, the code segment is a part of this file; when the loader places a program into memory so that it may be executed, various memory regions are allocated (in particular, as pages), corresponding to both the segments in the object files and to segments only needed at run time. For example, the code segment of an object file is loaded into a corresponding code segment in memory.
The code segment in memory is typically read-only and has a fixed size, so on embedded systems it can usually be placed in read-only memory (ROM), without the need for loading. If the code segment is not read-only, then the particular architecture allows self-modifying code. Fixed-position or position independent code may be shared in memory by several processes in segmented or paged memory systems.[1][2] As a memory region, the code segment may be placed below the heap or stack in order to prevent heap and stack overflows from overwriting it.[3]
See also
References
- ^ a b Jason W. Bacon (2012-03-13). "Chapter 10. Subprogram Calls and the Stack". cs.uwm.edu. Section 10.4. Memory Segments. Retrieved 2014-05-02.
- ^ Kai Wang (2012-09-20). "Code Segment and Data Segment: Memory Layout of a Program". beingdeveloper.com. Retrieved 2014-05-02.
- ^ Yu-An Tan; Ji-yan Zheng; Yuan-Da Cao; Xue-lan Zhang (October 2005). Buffer overflow protection based on adjusting code segment limit. IEEE International Symposium on Communications and Information Technology. IEEE. doi:10.1109/ISCIT.2005.1567023.
{{cite conference}}
:|access-date=
requires|url=
(help)