Re: x86 procedure calling convention (again)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 9, 2012 at 12:43 PM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
> On 9 November 2012 11:18, phi gcc wrote:
>>
>> Just wanted to precise that I was asking for x32 (x86 32 bits) not
>
> If you want to be precise then don't call it x32, that's something
> completely different: http://en.wikipedia.org/wiki/X32_ABI
>
> If you mean x86 then just say x86, or IA-32 in Intel-speak.



Well the suject is 'x86...' yet I got comment on x64 :) no blame, it
is confusing :)

To reply to Ian, yes I do unwind binary for wich I "don't want" to
recompile, these are linux crashdump from all different kind of
sources, often pretty old version, because production customers do
keep old versions. Basically I triage them, before digging more in
them. "Don't want" because no time for this, got the crashdump, run my
kernel crashdump debugger, and that's it. This is even worst than that
because linux world keep stripping the debug infos, and then they are
non reliable when eventually retrieved back.

So far I saw those calling conv

non-static   static   non-static-fastcall old-gcc
a4 16(%esp)  4(%esp)  8(%esp)             8(%esp)
a3 12(%esp)  0(%esp)  4(%esp)             4(%esp)
a2  8(%esp)  ecx      0(%esp)             0(%esp)
a1  4(%esp)  edx      edx                 edx
a0  0(%esp)  eax      ecx                 eax

The idea is to figure out in the call site what arg location has been
loaded (if lucky)
na=0
if ax is loaded it is a0 na=1
if dx is loaded it is a1 na=2
if cx is loaded
   if ax not loaded it is a0 if(!na)na=1
   if ax     loaded it is a3 na=3
0(sp) is a$na na++
4(sp) is a$na na++
8(sp) is a$na na++

I guess that for x86 (32 bits) gcc could do more  tricks on static
leaf (terminal) functions, but I never got a panic in such functions,
probably because they simply got inlined then :)

the old-gcc path could be hosed if a cx is loaded as temporary during
the call site, it would make my heuristics think we are in hte cx as
a2 case...

All this is just for naming the args (regs or stack loc) this is not
for fetching their values, this is another story that goes with callee
save propagation from save state, frame tracking, and stack access.

When asking I was hoping that I could find out quicker than just
probing dumps to find out how many calling conv was use with gcc.

I am gcc internals ignorant, I can download each gcc source code used
for a given kernel build (got the gcc version there), then try to see
if there is a config file for x86 (32bits) that would describe the
calling conv for this version of gcc, but could not find this so far
for old gcc. What would be a common place to look? I did loolk at
libffi but it doesn't help.

Thanx to all.
Cheers,
Phi


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux