簡體   English   中英

使gcc在功能結束時不發出“ ret”指令

[英]Make gcc not issue a 'ret' instruction at the end of function

如果我編譯這段C代碼:

void _start() {
}

通過gcc的此調用:

gcc -nostdlib -Os -S foo.c

我得到此程序集清單:

        .file   "foo.c"
        .section        .text.unlikely,"x"
LCOLDB0:
        .text
LHOTB0:
        .globl  __start
        .def    __start;        .scl    2;      .type   32;     .endef
__start:
        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        ret
        .section        .text.unlikely,"x"
LCOLDE0:
        .text
LHOTE0:
        .ident  "GCC: (GNU) 4.9.2"

如您所見,gcc在代碼末尾發出了“ ret”指令。 有沒有辦法使它發出那個?

調用__builtin_unreachable(); 函數中的告訴gcc它不需要在末尾返回,因為它不會到達末尾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM