How does Win32 implement assembly language sections?

From: William Hayes (whayes_at_hfx.andara.com)
Date: 09/27/04

  • Next message: hutch--: "Re: Wars, yummy"
    Date: Mon, 27 Sep 2004 15:34:55 -0300
    
    

    Hello,

    How are the sections defined in an assembly language program (e.g., .CODE,
    .DATA, .CONST, etc.) implemented under the Win32 flat memory model? I am
    aware that programmers don't have to concern themselves with segmentation,
    but I am curious about it's possible role behind the scenes.

    >From what I have read in this newsgroup and elsewhere, it looks like .CODE
    and .DATA sections end up as separate segments (even though their base
    address and limit are the same), with different access rights in their
    segment descriptors. Is that the case? Are the other pre-defined sections
    merged into those two segments (e.g., .CONST into the code segment, .DATA?
    into the data segment, and so on)?

    What about other sections defined using the SEGMENT directive? Are they
    always merged with the existing code or data segment?

    If the stack and the data section share a segment (SS and DS seem to hold
    the same selector), and therefore have the same access rights, base address,
    and limit, is there anything preventing accidental stack overwriting?

    Thanks.

    William Hayes


  • Next message: hutch--: "Re: Wars, yummy"

    Relevant Pages

    • Re: Visual C++ optimizer bug (reported by a friend in the Computer Chess Club)
      ... > unsigned int row, col; ... > INCLUDELIB LIBC ... > CONST SEGMENT ...
      (microsoft.public.dotnet.languages.vc)
    • Re: question about const and text segment
      ... >However, it is placing it in the text segment, and external references ... Taking the const off the ... >definition solves the problem (the variable is placed in the data segment). ... Did you declare the array with the "extern" keyword and export the ...
      (comp.lang.cpp)
    • RE: API : constness ?
      ... > using const helps gcc to move these data to the text segment ... > bust casting again again like this ...
      (comp.lang.python)
    • How does Win32 implement assembly language sections?
      ... ..DATA, .CONST, etc.) implemented under the Win32 flat memory model? ... segment descriptors. ... the same selector), and therefore have the same access rights, base address, ... is there anything preventing accidental stack overwriting? ...
      (comp.lang.asm.x86)