Mail Archives: djgpp/2000/04/14/13:29:20
Eli Zaretskii wrote:
>
> "Alexei A. Frounze" wrote:
> >
> > But don't put something like:
> >
> > mov [cs:number], value
> >
> > use
> >
> > mov [ds:number], value
> >
> > since you're in PMode with flat memory model.
>
> Flat memory model is not an issue here. The problem is that the code segment
> whose selector is loaded into the CS register is marked as executable, and
> such segments cannot be written in protected mode.
Please read all the following text until its end. Then reply.
You're right, we can not modify segment marked as executable/read. But since
data segment is mapped on the code segment as well, you may modify it just uding
the DS selector.
>
> Btw, DJGPP doesn't use a flat memory model at all. The details of this were
> discussed several months ago here, so you can find them by searching at
> http://www.delorie.com/djgpp/mail-archives/.
Wait a minute. Some string constants are stored to the code segment by GCC. And
they are accessible in data segment as well, since data segment is mapped onto
the code segment too.
Or do you mean, that EXE files contain all the relocation entries?
If so, why I see in each EXE only the following:
1. COFF header
2. optional COFF header (for already linked programs)
3. .text section (w/o relocation entries)
4. .data section (w/o relocation entries)
5. .bss section (w/o relocation entries)
6. string table
7. symbol table
According to the sections, the .data section starts just after the .text section
and the .bss esctions starts just after the .data section.
So, it's a true flat memory model (but only virtual addresses don't equal
physicals. i.e. VGA video buffer is not accessible at the 0xA0000 virtual
address).
The only problem might be that code segment pages are marked as read-only. But
since sections are not always 4KB aligned and their sizes are not in 4KB blocks,
I can tell you that there is no page level protection for writing.
bye.
Alexei A. Frounze
-----------------------------------------
Homepage: http://alexfru.chat.ru
Mirror: http://members.xoom.com/alexfru
- Raw text -