场景:
正常 经过 gcc -o loccheck loccheck.c
[root@luozhonghua 9]# ./loccheck
in main(),pooh=2 and &pooh=0xbfcfa31c
in main(),bah=5 and &bah=0xbfcfa318
------------------------
in main(),pooh=10 and &pooh=0xbfcfa2ec
in main(),bah=2 and &bah=0xbfcfa300
然后想看c中的&pooh地址值的变化
loccheck.c 经 gcc -S loccheck.c
汇编器汇编 as -gstabs -o locckeck1.o loccheck.s
连接器链接
[root@luozhonghua 9]# ld -dynamic-linker /lib/ld-linux.so.2 -lc -o loccheck1 locckeck1.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000080481d8
[root@luozhonghua 9]# ./loccheck1
in main(),pooh=2 and &pooh=0xbfd209ec
in main(),bah=5 and &bah=0xbfd209e8
------------------------
in main(),pooh=10 and &pooh=0xbfd209bc
in main(),bah=2 and &bah=0xbfd209d0
Segmentation fault (core dumped)
警告表示汇编没有从_start开始 ,嗯看看
[root@luozhonghua 9]# cat loccheck.s
.file "loccheck.c"
.section .rodata
.align 4
.LC0:
.string "in main(),pooh=%d and &pooh=%p\n"
.LC1:
.string "in main(),bah=%d and &bah=%p\n"
.LC2:
.string "------------------------"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
movl $2, 28(%esp)
movl $5, 24(%esp)
movl 28(%esp), %edx
movl $.LC0, %eax
leal 28(%esp), %ecx
movl %ecx, 8(%esp)
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
movl 24(%esp), %edx
movl $.LC1, %eax
leal 24(%esp), %ecx
movl %ecx, 8(%esp)
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
movl $.LC2, (%esp)
call puts
movl 28(%esp), %eax
movl %eax, (%esp)
call mikado
movl $0, %eax
leave
ret
.size main, .-main
.globl mikado
.type mikado, @function
mikado:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
movl $10, -12(%ebp)
movl -12(%ebp), %edx
movl $.LC0, %eax
leal -12(%ebp), %ecx
movl %ecx, 8(%esp)
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
movl 8(%ebp), %edx
movl $.LC1, %eax
leal 8(%ebp), %ecx
movl %ecx, 8(%esp)
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
leave
ret
.size mikado, .-mikado
.ident "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-4)"
.section .note.GNU-stack,"",@progbits
ok! 确实没有
使用gcc -S 把原始c汇编成汇编,确实少了_start 开始标志
但依然还是能汇编成正常的可执行文件且结果正常
因此,这里警告依然是没问题的,可忽略,这是工具gcc自身反汇编机制