public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* C main 32/64 bit prologues differ
@ 2008-02-22 20:39 Bob Plantz
  2008-02-23 18:23 ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Plantz @ 2008-02-22 20:39 UTC (permalink / raw)
  To: gcc-help

The prologues for the main function in C differ (at the assembly
language level) depending on whether it is compiled for 32-bit or 64-bit
in the x86 architecture.

Also, adding a dwarf2 unwind table is the default in 64-bit mode, but
not in 32-bit.

Can anyone point me to discussions about why it's done this way?


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

* Re: C main 32/64 bit prologues differ
  2008-02-22 20:39 C main 32/64 bit prologues differ Bob Plantz
@ 2008-02-23 18:23 ` Andrew Haley
  2008-02-23 22:05   ` Bob Plantz
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2008-02-23 18:23 UTC (permalink / raw)
  To: Bob Plantz; +Cc: gcc-help

Bob Plantz wrote:
> The prologues for the main function in C differ (at the assembly
> language level) depending on whether it is compiled for 32-bit or 64-bit
> in the x86 architecture.
> 
> Also, adding a dwarf2 unwind table is the default in 64-bit mode, but
> not in 32-bit.
> 
> Can anyone point me to discussions about why it's done this way?

The DWARF question I can answer: it's required by the processor-
specific ABI.

Andrew.


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

* Re: C main 32/64 bit prologues differ
  2008-02-23 18:23 ` Andrew Haley
@ 2008-02-23 22:05   ` Bob Plantz
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Plantz @ 2008-02-23 22:05 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

On Sat, 2008-02-23 at 15:40 +0000, Andrew Haley wrote:
> The DWARF question I can answer: it's required by the processor-
> specific ABI.
> 
> Andrew.
> 
Thank you.

I should explain my application. I'm working on an introductory machine
organization textbook. It's based on x86-64 running a GNU/Linux system.
My approach is to start with C, look at gcc's assembly language, then
show how a programmer might write the assembly language. Since it's
introductory, I'm less concerned about industrial quality error
handling.

I use gdb to single-step through code and look at registers and memory.

I don't need to explain all the details in my book, but I would like to
be able to say something beyond "the stork brought it."

My take at this point is that the DWARF is used for 64 bit because
parameters are passed in registers, making it more difficult to unwind
the stack. Since 32 bit passes parameters only in the stack frame, it is
easier to unwind the stack. (Pointing out my misconceptions is much
appreciated.)

Bob

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

end of thread, other threads:[~2008-02-23 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-22 20:39 C main 32/64 bit prologues differ Bob Plantz
2008-02-23 18:23 ` Andrew Haley
2008-02-23 22:05   ` Bob Plantz

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).