In studying operating systems (primarily with Linux as reference), there are a few points that I don't find well explained in the material that I have studied.
Programs loaded into memory are often described as being divided into segments of text, data, stack etc., even in the context of operating systems like Linux where virtual memory is based purely on paging. Is it the case that it is just the program, and not the memory itself that is referred to as segmented? If so, I find the terminology confusing.
I saw that malloc can be implemented in Linux using the call 'sbrk' that increases the size of the data segment. Again, is this 'data segment' just a region of memory that is used for data by convention and not a 'real' segment? (Extra question: 'sbrk' does not seem to be able to decrease the size of the 'segment'. Does this mean that a process can never release memory to the OS other than quitting?)
Also I am interested in knowing why modern operating systems seems not to be using (paged) segmentation. Wouldn't it prevent certain kinds of attacks to have the code residing in it's own protected segment, thereby increasing security? On the other hand, would this make e.g. JIT compilation impossible/difficult?
Besides "yes"/"no" answers to the questions above, I am interested in any insightful elaboration on the subject.
brk
, which can set the program break to a lower value. And the segments are partitioned into pages, and each page can indeed be read-only or no-execute, and the text segment and ro-data segment will usually be set thus. – Overstuff