0Pricing
Reverse Engineering & Binary Analysis Basics · 강의

스택과 호출 규약

함수가 인수를 전달하고 값을 반환하며 스택 프레임을 관리하는 방식을 더 깊이 이해해 디스어셈블된 코드를 읽을 수 있는 지식을 익힙니다.

스택과 호출 규약은(는) CoddyKit의 무료 Reverse Engineering & Binary Analysis Basics 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Reverse Engineering & Binary Analysis Basics 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Reverse Engineering & Binary Analysis Basics 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Beyond a Single Call

You can read basic x86/x64 instructions and follow control flow. To truly understand function calls you must know the stack and calling conventions.

These rules govern how arguments arrive and how cleanup happens.

What the Stack Is

The stack is a region of memory that grows downward (toward lower addresses). It stores return addresses, saved registers, and local variables.

  • push decrements RSP and writes
  • pop reads and increments RSP
push rax   ; rsp -= 8, [rsp] = rax
pop  rbx   ; rbx = [rsp], rsp += 8

RSP and RBP

Two registers track the stack:

  • RSP (stack pointer) points to the current top
  • RBP (base pointer) anchors the current frame

Locals are addressed relative to RBP, like [rbp-8].

The Function Prologue

Most functions begin with a prologue that sets up the frame: save the old base pointer, then point RBP at the new frame.

push rbp
mov  rbp, rsp
sub  rsp, 0x20   ; reserve 32 bytes for locals

The Function Epilogue

The epilogue reverses the prologue, restoring the caller's frame before returning.

mov rsp, rbp
pop rbp
ret

Calling Conventions

A calling convention is the contract for passing arguments and returning values.

  • Where arguments go (registers or stack)
  • Who cleans up the stack
  • Which registers must be preserved

System V AMD64 (Linux x64)

On Linux x64 the first six integer arguments go in registers: rdi, rsi, rdx, rcx, r8, r9. The return value comes back in rax.

Extra arguments spill onto the stack.

; foo(1, 2, 3)
mov edi, 1
mov esi, 2
mov edx, 3
call foo

Microsoft x64 Convention

Windows x64 uses different registers: the first four arguments go in rcx, rdx, r8, r9, and the caller reserves 32 bytes of shadow space.

Recognizing the OS tells you which mapping to apply when reading arguments.

; Windows: bar(a, b)
mov rcx, a
mov rdx, b
sub rsp, 0x28   ; shadow space + alignment
call bar

Caller-Saved vs Callee-Saved

Some registers may be clobbered by a call (caller-saved), others must be preserved (callee-saved).

Seeing a function push rbx, rbp, and r12-r15 in its prologue is a strong hint about which registers it intends to use.

Reading Arguments in Practice

When you land in a function, mapping registers to arguments lets you label them. If the code reads rdi first on Linux, that is argument one.

This is how raw disassembly becomes readable pseudocode like send(sock, buf, len).

Stack-Passed Arguments

When a function has more arguments than the convention allows in registers, the extras are pushed onto the stack by the caller. The callee reads them at positive offsets from RBP, like [rbp+0x10].

Spotting these accesses helps you recover the full argument list.

; 7th System V argument
mov rax, [rbp+0x10]

Quick Check

Under the System V AMD64 convention, which register holds the FIRST integer argument?

Recap

You can now decode function calls at the metal level:

  • Stack grows down; RSP tops it, RBP anchors the frame
  • Prologue/epilogue set up and tear down frames
  • Calling conventions map registers to arguments (System V vs Microsoft x64)

This turns opaque disassembly into recognizable function signatures.

자주 묻는 질문

“스택과 호출 규약” 강의는 무료인가요?

네 — “스택과 호출 규약” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Reverse Engineering & Binary Analysis Basics 강의 전체를 잠금 해제할 수 있습니다. Reverse Engineering & Binary Analysis Basics 강의에는 총 4개의 강의가 포함되어 있습니다.

“스택과 호출 규약”에서 뭘 배우나요?

함수가 인수를 전달하고 값을 반환하며 스택 프레임을 관리하는 방식을 더 깊이 이해해 디스어셈블된 코드를 읽을 수 있는 지식을 익힙니다. 브라우저에서 직접 실행하는 실습 코드로 Reverse Engineering & Binary Analysis Basics을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Reverse Engineering & Binary Analysis Basics을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Reverse Engineering & Binary Analysis Basics은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“스택과 호출 규약” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Reverse Engineering & Binary Analysis Basics 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Reverse Engineering & Binary Analysis Basics 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. x86/x64 어셈블리 기초
  2. 레지스터 및 메모리 연산
  3. 제어 흐름 및 함수 호출
  4. 스택과 호출 규약
← Reverse Engineering & Binary Analysis Basics(으)로 돌아가기