Author Topic: 64 bit ABI  (Read 13444 times)


  • Guest
64 bit ABI
« on: March 04, 2009, 02:39:11 PM »

I am a little puzzled about the linux ABI (64 bit).

I have already found that some 64 bit linux syscalls do not follow the amd64 ABI (see my previous qestion about mmap).
Now I tried to use a gcc compiled library which does not follow the amd64 ABI but not the same way as the mmap syscall (which uses r10 instead of rcx for the fourth parameter) but uses qwords instead of words on the stack for the last two parameters (width,height - last on the stack as they are passed in the opposite order).
What I tried:

call xcb_create_window

The declaration of the method is:

xcb_create_window (xcb_connection_t *c  /**< */,
uint8_t           depth  /**< */,
xcb_window_t      wid  /**< */,
xcb_window_t      parent  /**< */,
int16_t           x  /**< */,
int16_t           y  /**< */,
uint16_t          width  /**< */,
uint16_t          height  /**< */,
uint16_t          border_width  /**< */,
uint16_t          _class  /**< */,
xcb_visualid_t    visual  /**< */,
uint32_t          value_mask  /**< */,
const uint32_t   *value_list  /**< */);

So in this case from the width parameter they are passed on the stack.
Passing the parameters on the stack as it was described in amd64 ABI did not work.
Finally disassembling gcc output I figured out that the first two parameters on the stack (width and height) are passed not as word but qword. This solved the problem. But it is very confusing that e.g. border width is the very same type and not qword but word is used when it is passed on the stack.

Is there an easyer way to figure out the ABIs without trying and disassembling (it is very time consuming this way)? Do you know what ABI is followed in this cases? And where is it documented somewhere?