关于.cfl指令的简单介绍

本文探讨了现代应用程序二进制接口(ABI)如何不再强制使用帧指针(FP),并介绍了当函数中缺少帧指针时进行回溯带来的困难。为解决这一问题,文章提出了使用DWARF-2 CFI数据的方法,并详细解释了如何通过GCC等工具自动生成或手动编写汇编语言中的相关指令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Modern ABIs don't require frame pointers to be usedin functions. However missing FPs bring difficulties when doing a backtrace.One solution is to provide Dwarf-2 CFI data for each suchfunction. This can be easily done for example by GCC in it's output,but isn't that easy to write by hand for pure assembler functions.

With the help of these .cfi_* directivesone can add appropriate unwind info into his asm source without too muchtrouble.

Directives implemented so far:

.cfi_startproc

Use at thebeginning of each function. It initializes some internal data structures andemits initial CFI instructions.

.cfi_endproc

Opens .eh_frame,generates appropriate binary structures (CIE, FDE) and sets up relocationrecords.

.cfi_def_cfa reg,imm

Set a rule forcomputing CFA to: take content of register reg and add imm toit.

.cfi_def_cfa_register reg

Change rule forCFA to use reg. Offset remains the same.

.cfi_def_cfa_offset imm

Change rule forCFA to use offset imm. Register remains the same.

.cfi_adjust_cfa_offset imm

Like the previousone but imm is a relative value that will be added to currentoffset instead of an absolute value as in .cfi_def_cfa_offset.

.cfi_offset reg,imm

Generate a rulesaying that register reg is saved at offset imm fromCFA.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值