注册 登录
编程论坛 C语言论坛

.cfi_startproc作用是什么

PopToPush 发布于 2020-11-14 18:54, 2345 次点击
void *fxcg_memset(void *dest, int c, unsigned int n) {
    char* d = (char*)dest;
    while (n-- > 0) { *d++ = (char)c; }

    return dest;
}
下面是gcc生成的汇编代码:
__Z11fxcg_memsetPvij:                                                                                                                                           .LFB0:                                                                                                                                                                  .cfi_startproc                                                                                                                                                  tst     r6,r6                                                                                                                                                   bt      .L6                                                                                                                                                     sts.l   pr,@-r15                                                                                                                                                .cfi_def_cfa_offset 4                                                                                                                                           .cfi_offset 17, -4                                                                                                                                              mov.l   .L10,r0                                                                                                                                                 jsr     @r0                                                                                                                                                     exts.b  r5,r5                                                                                                                                                   lds.l   @r15+,pr                                                                                                                                                .cfi_restore 17                                                                                                                                                 .cfi_def_cfa_offset 0                                                                                                                                           rts                                                                                                                                                             nop                                                                                                                                                             .align 1                                                                                                                                                .L6:                                                                                                                                                                    rts                                                                                                                                                             mov     r4,r0                                                                                                                                           .L11:                                                                                                                                                                   .align 2                                                                                                                                                .L10:                                                                                                                                                                   .long   _memset                                                                                                                                                 .cfi_endproc                                                                                                                                            .LFE0:                                                                                                                                                                  .size   __Z11fxcg_memsetPvij, .-__Z11fxcg_memsetPvij                                                                                                            .section        .text.startup.main,"ax",@progbits                                                                                                               .align 1                                                                                                                                                        .align 2                                                                                                                                                        .global _main                                                                                                                                                   .type   _main, @function

对于汇编我并不熟悉,as汇编也缺乏资料。比如.cfi_startproc .cfi_endproc作用是什么?它们总是用在函数里
1 回复
#2
PopToPush2020-11-14 19:02
__Z11fxcg_memsetPvij:                                                                                                                                           .LFB0:                                                                                                                                                                  .cfi_startproc                                                                                                                                                  tst     r6,r6                                                                                                                                                   bt      .L6                                                                                                                                                     sts.l   pr,@-r15                                                                                                                                                .cfi_def_cfa_offset 4                                                                                                                                           .cfi_offset 17, -4                                                                                                                                              mov.l   .L10,r0                                                                                                                                                 jsr     @r0                                                                                                                                                     exts.b  r5,r5                                                                                                                                                   lds.l   @r15+,pr                                                                                                                                                .cfi_restore 17                                                                                                                                                 .cfi_def_cfa_offset 0                                                                                                                                           rts                                                                                                                                                             nop                                                                                                                                                             .align 1                                                                                                                                                .L6:                                                                                                                                                                    rts                                                                                                                                                             mov     r4,r0                                                                                                                                           .L11:                                                                                                                                                                   .align 2                                                                                                                                                .L10:                                                                                                                                                                   .long   _memset                                                                                                                                                 .cfi_endproc                                                                                                                                            .LFE0:                                                                                                                                                                  .size   __Z11fxcg_memsetPvij, .-__Z11fxcg_memsetPvij                                                                                                            .section        .text.startup.main,"ax",@progbits                                                                                                               .align 1                                                                                                                                                        .align 2                                                                                                                                                        .global _main                                                                                                                                                   .type   _main, @function     
#3
自由而无用2021-08-10 10:10
.cfi_startproc is used at the beginning of each function that should have an entry in .eh_frame. It initializes some internal data structures. Don’t forget to close the function by .cfi_endproc.
1