what's the meaning of the syscall related asm code in uclibc for i386 architecture

StackOverflow https://stackoverflow.com/questions/21726672

  •  10-10-2022
  •  | 
  •  

Question

#define INLINE_SYSCALL(name, nr, args...) \
  ({                                          \
    unsigned int resultvar;                           \
    asm volatile (                                \
    LOADARGS_##nr                                 \
    "movl %1, %%eax\n\t"                              \
    "int $0x80\n\t"                               \
     RESTOREARGS_##nr                                 \
    : "=a" (resultvar)                                \
    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc");              \
   if (resultvar >= 0xfffff001)                       \
     {                                        \
        __set_errno (-resultvar);                         \
        resultvar = 0xffffffff;                           \
      }                                       \
    (int) resultvar; })

#define LOADARGS_0
#define LOADARGS_1 \
"bpushl .L__X'%k2, %k2\n\t"                           \
"bmovl .L__X'%k2, %k2\n\t"
#define LOADARGS_2  LOADARGS_1
#define LOADARGS_3  LOADARGS_1
#define LOADARGS_4  LOADARGS_1
#define LOADARGS_5  LOADARGS_1

who knows the meaning of the following asm code

#define LOADARGS_1 \
"bpushl .L__X'%k2, %k2\n\t"                           \
"bmovl .L__X'%k2, %k2\n\t"

can someone explain this to me %2 means the third parameters in asm input and output so %k2 means what and what's meaning of .L__X bpushl and bmovl seems no such instruction for ia32

Était-ce utile?

La solution

The %2 and %k2 are register constraints, which are described well here: Simple Constraints

bpushl and bmovl are macros defined by uClibc in syscalls.h, and seems to be meant to preserve the previous value in %ebx before clobbering it.

.L__X is defined in the same file.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top