Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Code segment
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Segment== The term "segment" 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 | url = http://www.beingdeveloper.com/memory-layout-of-a-program/ | title = Code Segment and Data Segment: Memory Layout of a Program | date = 2012-09-20 | accessdate = 2014-05-02 | author = Kai Wang | website = beingdeveloper.com | archive-date = 2014-05-02 | archive-url = https://web.archive.org/web/20140502121214/http://www.beingdeveloper.com/memory-layout-of-a-program/ | url-status = dead }}</ref> As a memory region, the code segment may be placed below the heap or stack in order to prevent [[Heap overflow|heap]] and [[stack overflow]]s from overwriting it.<ref>{{Cite conference | doi = 10.1109/ISCIT.2005.1567023 | title = Buffer overflow protection based on adjusting code segment limit | conference = IEEE International Symposium on Communications and Information Technology | date = October 2005 | author1 = Yu-An Tan | author2 = Ji-yan Zheng | author3 = Yuan-Da Cao | author4 = Xue-lan Zhang | publisher = [[IEEE]] }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)