Code segment

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In computing, a code segment, also known as a text segment or simply as text, is one of the sections of a program in an object file or in memory, which contains executable instructions.[1]

It has a fixed size and is usually read-only. If the text section 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, a code segment may be placed below the heap or stack in order to prevent heap and stack overflows from overwriting it.[3]

See also[edit]


  1. ^ a b Jason W. Bacon (2012-03-13). "Chapter 10. Subprogram Calls and the Stack". 10.4. Memory Segments. Retrieved 2014-05-02. 
  2. ^ Kai Wang (2012-09-20). "Code Segment and Data Segment: Memory Layout of a Program". Retrieved 2014-05-02. 
  3. ^ Yu-An Tan; Ji-yan Zheng; Yuan-Da Cao; Xue-lan Zhang (October 2005). "Buffer overflow protection based on adjusting code segment limit". Retrieved 2014-05-02.