Date: Mon, 9 Aug 1999 17:39:19 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: OSO cc: djgpp AT delorie DOT com Subject: Re: -ffresstanding? In-Reply-To: <19990807190513.26366.rocketmail@web206.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sat, 7 Aug 1999, OSO wrote: > Basically, the docs say this is a suitable command for > writing OS kernels or when a libc is not present in > memory. But I have question about it. Since nobody replied, and I don't have time to look into GCC sources (which is IMHO what one should do when one has such questions), I'll try to answer. But please take what's below with a grain of salt, since I didn't really see what GCC does under -freestanding. As far as I understand, this option simply restricts GCC to emitting code that doesn't rely on any library facilities. For example, it doesn't use built-in functions. But this option has no effect on the machine instructions generated by the compiler. The code still assumes flat model with no segmentation, and by default it is a 32-bit code. > Do Linux & DJGPP GCCs still generate code which is PMODE (and > DPMI for DJGPP) dependent? This is a misunderstanding. Code generated by GCC in its DJGPP port does not depend on DPMI. It doesn't even depend on the CPU being in protected mode. The DPMI dependence is in the library and in the startup code. If your program doesn't have more than 64KB of code and data, you can toss the startup code and have your program run in real mode (of course, you will have to write your own library functions for I/O etc.) The only thing that GCC assumes is that the memory address space is flat, and that the CPU can execute 32-bit instruction. How this is set up is left for the run-time environment and the startup code. In the DJGPP case, these rely on DPMI. But we use DPMI and protected mode simply because it is one way of running GCC-produced code on top of a real-mode operating system such as DOS. > Can this option force GCC into a Flat Real Mode (1MB Max Code, 4GB Max > Data) compatible code generator? As far as I understand, you can force GCC into any flat mode, provided that you supply the startup code and a library that arranges for it. You don't even need -freestanding to do that.