x86 procedure calling convention (again)

Ian Lance Taylor iant@google.com
Thu Nov 8 19:08:00 GMT 2012


On Thu, Nov 8, 2012 at 12:10 AM, phi gcc <phi.gcc@gmail.com> wrote:
>
> It is obvious that GCC don't care about this and assign some args
> tosome (scratch) registers, the problem is that what arg goes in what
> regs changes over time, and I need to know if there is a way to know
> this. I need this to automate linux crash dump analysis, that look at
> stack unwind programatically, and I recieve dumps from 'production
> system' that run old frozen kernel. So basically I need to adapt to
> gcc, to automate args retrieval and way obsolete gc :)

GCC is able to record stack unwind information in the executable
itself.  On x86_64 it does this by default.  On 32-bit x86 it only
does so when directed to by a command line option (-fexceptions,
-funwind-tables, -fasynchronous-unwind-tables) or when compiling a
language that requires unwinding the stack, such as C++.

Even when GCC does not record stack unwind information in the
executable, it records it in the debug info.

If you have an old 32-bit x86 executable that you can not rebuild,
that does not contain stack unwind information, and does not contain
debug info, then the only way to correctly unwind the stack is to
analyze the function prologue.  GDB does this; see gdb/i386-tdep.c in
the GDB sources.

Ian



More information about the Gcc-help mailing list