La pile et les conventions d’appel
Approfondissez le fonctionnement du passage des arguments aux fonctions, du renvoi des valeurs et de la gestion de la trame de pile, des connaissances qui rendent le code désassemblé lisible.
La pile et les conventions d’appel est une leçon Reverse Engineering & Binary Analysis Basics gratuite sur CoddyKit. Ceci est la leçon 4 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Reverse Engineering & Binary Analysis Basics, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Reverse Engineering & Binary Analysis Basics comprend 4 leçons au total.
Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.
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.
pushdecrements RSP and writespopreads and increments RSP
push rax ; rsp -= 8, [rsp] = rax
pop rbx ; rbx = [rsp], rsp += 8RSP 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 localsThe Function Epilogue
The epilogue reverses the prologue, restoring the caller's frame before returning.
mov rsp, rbp
pop rbp
retCalling 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 fooMicrosoft 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 barCaller-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.
Questions Fréquemment Posées
La leçon « La pile et les conventions d’appel » est-elle gratuite ?
Oui — le texte complet de « La pile et les conventions d’appel » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Reverse Engineering & Binary Analysis Basics, passe à CoddyKit PRO. Le cours Reverse Engineering & Binary Analysis Basics comprend 4 leçons au total.
Qu'est-ce que j'apprendrai dans « La pile et les conventions d’appel » ?
Approfondissez le fonctionnement du passage des arguments aux fonctions, du renvoi des valeurs et de la gestion de la trame de pile, des connaissances qui rendent le code désassemblé lisible. Tu pratiques Reverse Engineering & Binary Analysis Basics avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.
Dois-je avoir de l'expérience pour commencer Reverse Engineering & Binary Analysis Basics ?
Aucune expérience préalable n'est requise. Reverse Engineering & Binary Analysis Basics sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 4 sur 4.
Combien de temps prend la leçon « La pile et les conventions d’appel » ?
La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.
Peux-tu écrire et exécuter du code dans cette leçon Reverse Engineering & Binary Analysis Basics ?
Oui. Chaque leçon Reverse Engineering & Binary Analysis Basics inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.
Toutes les leçons de ce cours
- Bases de l’assembleur x86/x64
- Registres et opérations mémoire
- Flux de contrôle et appels de fonctions
- La pile et les conventions d’appel