[英]Creating a C function without compiler generated prologue/epilogue & RET instruction?
[英]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.