public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc with no stack at all?
@ 2000-03-30 17:11 Jeff Garzik
  2000-03-31  6:20 ` Erik Mouw
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2000-03-30 17:11 UTC (permalink / raw)
  To: gcc

For low-level BIOS type code, some portions of early chipset init must
run without a stack.

Is it possible to write gcc-compilable C code which doesn't require a
stack at all?

I don't see any '-fno-stack' option in gcc.info*, but I was wondering if
it could be done implicitly, for example '-fno-builtin' plus no local
vars plus an all-register calling convention.

Thanks for any insight.

	Jeff




-- 
Jeff Garzik              | Tact is the ability to tell a man 
Building 1024            | he has an open mind when he has a
MandrakeSoft, Inc.       | hole in his head.  (-random fortune)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc with no stack at all?
  2000-03-30 17:11 gcc with no stack at all? Jeff Garzik
@ 2000-03-31  6:20 ` Erik Mouw
  0 siblings, 0 replies; 3+ messages in thread
From: Erik Mouw @ 2000-03-31  6:20 UTC (permalink / raw)
  To: jgarzik; +Cc: gcc

On Thu, 30 Mar 2000 20:11:31 -0500, Jeff Garzik wrote:
> For low-level BIOS type code, some portions of early chipset init must
> run without a stack.

That's tricky. AFAIK gcc always needs a stack to store function return
addresses, although it depends on the platform (ARM uses r14, for
example).

> Is it possible to write gcc-compilable C code which doesn't require a
> stack at all?

I'm afraid not, but again, it depends on the platform.

> I don't see any '-fno-stack' option in gcc.info*, but I was wondering if
> it could be done implicitly, for example '-fno-builtin' plus no local
> vars plus an all-register calling convention.

The way it is usually done is to write a small piece of assembly code that
does the basic stack setup and call a C function as soon as possible. I've
done it that way in blob, a GPL'ed boot loader for the LART (an SA-1100
based computer board, see signature for URL). IIRC, the Linux kernel does
it the same way.


Erik

-- 
LART. 250 MIPS under one Watt. Free hardware design files.
http://www.lart.tudelft.nl/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc with no stack at all?
@ 2000-03-30 19:05 Mike Stump
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Stump @ 2000-03-30 19:05 UTC (permalink / raw)
  To: gcc, jgarzik

> Date: Thu, 30 Mar 2000 20:11:31 -0500
> From: Jeff Garzik <jgarzik@mandrakesoft.com>
>
> For low-level BIOS type code, some portions of early chipset init must
> run without a stack.

Right.

> Is it possible to write gcc-compilable C code which doesn't require a
> stack at all?

Sure, trivial:

foo() { asm ("startupocode: bla bla bla; jsr main ; bla bla bla ..."); }

> I don't see any '-fno-stack' option in gcc.info*, but I was
> wondering if it could be done implicitly, for example '-fno-builtin'
> plus no local vars plus an all-register calling convention.

No.

Welcome to startup code programming.  This is the wrong list to ask
how to program kernels.  If you want a hint, look at newlib's
libgloss.  See sourceware.cygnus.com to find newlib.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-03-31  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-30 17:11 gcc with no stack at all? Jeff Garzik
2000-03-31  6:20 ` Erik Mouw
2000-03-30 19:05 Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).