[GNU] regparm (number)

Jeongkyu(Jun)·2022년 12월 21일

C/C++

목록 보기
2/3

regparm (number)
On x86-32 targets, the regparm attribute causes the compiler to pass arguments number one to number if they are of integral type in registers EAX, EDX, and ECX instead of on the stack. Functions that take a variable number of arguments continue to be passed all of their arguments on the stack.

Beware that on some ELF systems this attribute is unsuitable for global functions in shared libraries with lazy binding (which is the default). Lazy binding sends the first call via resolving code in the loader, which might assume EAX, EDX and ECX can be clobbered, as per the standard calling conventions. Solaris 8 is affected by this. Systems with the GNU C Library version 2.1 or higher and FreeBSD are believed to be safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be disabled with the linker or the loader if desired, to avoid the problem.)


요약 : regparm 속성은 레지스터(%eax, %edx, %ecx)를 이용하여 전달한 인자의 수를 지정한다. 함수앞에 키워들르 선언하면 인자값을 레지스터로 넘기므로 스택을 사용하지 않아 빠르다

profile
안녕하세요

0개의 댓글