What segments does C compiled program use?

Posted by b-gen-jack-o-neill on Stack Overflow See other posts from Stack Overflow or by b-gen-jack-o-neill
Published on 2010-05-02T17:33:16Z Indexed on 2010/05/02 17:38 UTC
Read the original article Hit count: 199

Filed under:
|
|

Hi, I read on OSDev wiki, that protected mode of x86 architecture allow you to create separate segments for code and data, while you cannot write into code section. That Windows (yes, this is the platform) loads new code into code segment, and data are created on data segment. But, if this is the case, how does program know it must switch segments to the data segment? Becouse if I understand it right, all adress instructions point to the segment you run the code from, unless you switch the descriptor. But I also read, that so colled flat memory model allows you to run code and data within one segment. But I read this only in connection to assembler. So, please, what is the case with C compiled code on Windows? Thanks.

© Stack Overflow or respective owner

Related posts about c

    Related posts about Windows