F
F
Fedor2015-04-15 17:36:17
assembler
Fedor, 2015-04-15 17:36:17

What is this piece of code for?

In the assembler code at the beginning of the function description, there is such a piece of code, what is it responsible for?

.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2015-04-15
@whyamiscott

This is the organization of the stack frame: pushq %rbp saves the current stack frame pointer, movq %rsp, %rbp sets a new one.
Annotations starting with .cfi_ control the debugging information used by the debugger and the stack unwinding mechanism on exceptions:
.cfi_startproc sets the start of the procedure and sets the start register and offset for calculating the CFA (Canonical Frame Address).
.cfi_def_cfa_offset 16 updates the CFA offset to be 16 relative to the register (%rsp) specified (by the .cfi_startproc directive).
.cfi_offset 6, -16 says that register 6 is now at offset -16 from CFA (thus the pushq %rbp instruction was described).
.cfi_def_cfa_register 6 says that register 6 is now used to calculate the CFA address.
Details about .cfi_ can be found in info as and the big picture in chapter 6.4 of the DWARF standard .

V
Vladimir Martyanov, 2015-04-15
@vilgeforce

en.wikibooks.org/wiki/X86_Disassembly/Functions_an... - I think it's
Only your assembler is kind of strange :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question