Why is ESP masking with 0xFFFFFFF0?

I took apart the program. First, I see instructions ANDwith ESPand 0xFFFFFFF0.

What is the meaning of this mask? Is this a leveling problem?

This is the ELF executable for x86 32-bit.

+4
source share
1 answer

gcc for i386 Linux by default -mpreferred-stack-boundary=4(which means 2 4 = 16 bytes) . (Other non-Linux systems also use ELF executables, but they also have the same default values ​​for stack alignment and SysV ABI.)

clang, gcc , main, AND . .

, , , , :

extern int bar(void);
int foo(int x) { return x+bar(); }

  gcc 5.3 -O3
    sub     esp, 12                   # align the stack for another call
    call    bar
    add     eax, DWORD PTR [esp+16]   # add our arg (from the stack) to bar() return value (in eax)
    add     esp, 12
    ret

. Godbolt, .

-mincoming-stack-boundary=3 ( ) ( ). -mstackrealign -mno-stackrealign foo() main(), -mincoming-stack-boundary . gcc, , , , .


32- x86 SysV ABI, 4- , 16 %esp call.

2.2.2 -

... , (%esp + 4) 16, . (32, 32- ymm )

gcc -mpreferred-stack-boundary=4 - , ( , Linux, ABI, , ). , main, SSE/ . (, movaps) . , .


AND

32- ABI , 32- <... > t217 > %esp 16 . ( 2.3.1 , . %esp, .)

, gcc- main , , CRT, main, .

clang , , , 64- gcc.

16B- x86-64 SysV ABI , , , .

wiki ABI .

+6

All Articles