Re: Documentation: Architecture/ABI calling convention table - syscall( )

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

 



On Wed, Feb 14, 2024 at 11:26:39PM +1000, Ronald Monthero wrote:
> Hello,
> Below is in relation to architecture calling standards table for man
> syscall, for the indicated at [1] , [2]  and [3]   need to be changed
> perhaps.  ( arg4 of x86-64 architecture needs to be rcx instead of r10
> and the x32 arch table values needs replacement with exx register
> naming respectively. And also the return value register table for x32
> needs to be eax and edx for return val and return val2 respectively )
> ------------
> 
>        Arch/ABI      arg1  arg2  arg3  arg4  arg5  arg6  arg7  Notes
>        ─────────────────────────────
> ────────
>        alpha            a0    a1    a2    a3    a4    a5    -
>        arc                r0    r1    r2    r3    r4    r5    -
>        arm/OABI     r0    r1    r2    r3    r4    r5    r6
>        arm/EABI      r0    r1    r2    r3    r4    r5    r6
>        arm64          x0    x1    x2    x3    x4    x5    -
>        blackfin       R0    R1    R2    R3    R4    R5    -
>        i386            ebx   ecx   edx   esi   edi   ebp   -
>        ia64            out0  out1  out2  out3  out4  out5  -
>        m68k          d1    d2    d3    d4    d5    a0    -
>        microblaze    r5    r6    r7    r8    r9    r10   -
>        mips/o32      a0    a1    a2    a3    -     -     -     1
>        mips/n32,64   a0    a1    a2    a3    a4    a5    -
>        nios2          r4    r5    r6    r7    r8    r9    -
>        parisc        r26   r25   r24   r23   r22   r21   -
>        powerpc       r3    r4    r5    r6    r7    r8    r9
>        powerpc64     r3    r4    r5    r6    r7    r8    -
>        riscv         a0    a1    a2    a3    a4    a5    -
>        s390          r2    r3    r4    r5    r6    r7    -
>        s390x         r2    r3    r4    r5    r6    r7    -
>        superh        r4    r5    r6    r7    r0    r1    r2
>        sparc/32      o0    o1    o2    o3    o4    o5    -
>        sparc/64      o0    o1    o2    o3    o4    o5    -
>        tile          R00   R01   R02   R03   R04   R05   -
>        x86-64        rdi   rsi   rdx   r10   r8    r9    -
>                                                  ^^-----   ==> need to
> be rcx ?          <<   [1]
>        x32           rdi   rsi   rdx   r10   r8    r9    - ==>  to be
> exx regs   << [2]
> 
> 
>        =>  For x86-64 architecture the function calling standards
>          the arg4 register should be rcx

On what basis are you suggesting that?  [1] says otherwise, and [2]
concurs.

> 
>        => And for x32 it needs to be replaced with x86 32 bit register variants
>          as arg1 = edi , arg2 = esi , arg3 = edx, arg4 = ecx

I'm pretty sure that x32 ABI uses the same registers as x86_64.
strace's src/linux/x32/get_syscall_args.c[3] corroborates that.

>     2)  Also noticed the return value register table needs similar
> change for x86-32 bit
>      it needs to be eax instead of rax and edx instead of rdx.
> 
>        Arch/ABI    Instruction      System  Ret  Ret  Error    Notes
>                                                  call #    val   val2
>        ─────────────────────────────
> 
>       < snipped >
> 
>        sparc/32    t 0x10                 g1      o0   o1   psr/csr  1, 6
>        sparc/64    t 0x6d                 g1      o0   o1   psr/csr  1, 6
>        tile             swint1                R10     R00  -    R01      1
>        x86-64      syscall                rax     rax  rdx  -        5
>        x32            syscall               rax     rax  rdx  -        5
> 
> ^^^-----^^^--^^^------------------->            <<  [3]
> 
>          =>      for x32 return register has to be changed as
>                    rax => eax  and rdx => edx
> 

Same, x32 ABI is identical to x86_64 in that regard.

[1] https://www.uclibc.org/docs/psABI-x86_64.pdf#page=125
[2] https://gitlab.com/strace/strace/-/blob/8fa8a8886966fb873a67074c67eabf6be63535c0/src/linux/x86_64/get_syscall_args.c#L31
[3] https://gitlab.com/strace/strace/-/blob/8fa8a8886966fb873a67074c67eabf6be63535c0/src/linux/x32/get_syscall_args.c#L31




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux