64,654
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
char* test(void)
{
char * p = "hello world";
return p;
}
int main(int argc,char** argv)
{
char * pLocal = NULL;
pLocal = test();
printf("%s\n", pLocal);
return 0;
}
.file "demo.c"
.section .rodata
.LC0:
.string "hello world"
.text
.p2align 4,,15
.globl test
.type test, @function
test:
.LFB3:
pushq %rbp
.LCFI0:
movq %rsp, %rbp
.LCFI1:
movq $.LC0, -8(%rbp)
movq -8(%rbp), %rax
leave
ret
.LFE3:
.size test, .-test
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB4:
pushq %rbp
.LCFI2:
movq %rsp, %rbp
.LCFI3:
subq $32, %rsp
.LCFI4:
movl %edi, -20(%rbp)
movq %rsi, -32(%rbp)
movq $0, -8(%rbp)
call test
movq %rax, -8(%rbp)
movq -8(%rbp), %rdi
call puts
movl $0, %eax
leave
ret
.LFE4:
.size main, .-main
.section .eh_frame,"a",@progbits
.Lframe1:
.long .LECIE1-.LSCIE1
.LSCIE1:
.long 0x0
.byte 0x1
.string "zR"
.uleb128 0x1
.sleb128 -8
.byte 0x10
.uleb128 0x1
.byte 0x3
.byte 0xc
.uleb128 0x7
.uleb128 0x8
.byte 0x90
.uleb128 0x1
.align 8
.LECIE1:
.LSFDE1:
.long .LEFDE1-.LASFDE1
.LASFDE1:
.long .LASFDE1-.Lframe1
.long .LFB3
.long .LFE3-.LFB3
.uleb128 0x0
.byte 0x4
.long .LCFI0-.LFB3
.byte 0xe
.uleb128 0x10
.byte 0x86
.uleb128 0x2
.byte 0x4
.long .LCFI1-.LCFI0
.byte 0xd
.uleb128 0x6
.align 8
.LEFDE1:
.LSFDE3:
.long .LEFDE3-.LASFDE3
.LASFDE3:
.long .LASFDE3-.Lframe1
.long .LFB4
.long .LFE4-.LFB4
.uleb128 0x0
.byte 0x4
.long .LCFI2-.LFB4
.byte 0xe
.uleb128 0x10
.byte 0x86
.uleb128 0x2
.byte 0x4
.long .LCFI3-.LCFI2
.byte 0xd
.uleb128 0x6
.align 8
.LEFDE3:
.ident "GCC: (GNU) 4.2.1 20070719 [FreeBSD]"