当前位置: 技术问答>linux和unix
一个汇编的问题
来源: 互联网 发布时间:2016-11-09
本文导语: .section .data output: .ascii "what the fuck~!!n" .section .text .global main main: movl $4,%eax #syscall_write movl $1,%ebx #(fd = 1 )== stdout movl $output,%ecx #string addr movl $1000,%edx #size,but overflo...
.section .data
output:
.ascii "what the fuck~!!n"
.section .text
.global main
main:
movl $4,%eax #syscall_write
movl $1,%ebx #(fd = 1 )== stdout
movl $output,%ecx #string addr
movl $1000,%edx #size,but overflow?
int $0x80
movl $1,%eax
movl $0,%ebx
int $0x80
/*我自己猜测的对应c代码为*/
#include
int main()
{
char *buf = "what the fuck~!!n";
write(1,buf,1000);
}
c语言编译后的可执行代码会溢出(打出n多垃圾...)汇编代码产生的可执行打印正确的字符串。
c语言打印出乱码可以理解,可是汇编不打印乱码不能理解。。。
编译都为命令:
gcc -o
output:
.ascii "what the fuck~!!n"
.section .text
.global main
main:
movl $4,%eax #syscall_write
movl $1,%ebx #(fd = 1 )== stdout
movl $output,%ecx #string addr
movl $1000,%edx #size,but overflow?
int $0x80
movl $1,%eax
movl $0,%ebx
int $0x80
/*我自己猜测的对应c代码为*/
#include
int main()
{
char *buf = "what the fuck~!!n";
write(1,buf,1000);
}
c语言编译后的可执行代码会溢出(打出n多垃圾...)汇编代码产生的可执行打印正确的字符串。
c语言打印出乱码可以理解,可是汇编不打印乱码不能理解。。。
编译都为命令:
gcc -o
|
对内核sys_write下断点调试结果
汇编的
Breakpoint 4, sys_write (fd=1, buf=0x80484a0 "what the fuck~!!n", count=1000) at fs/read_write.c:378
378 if (file) {
(gdb) c
Continuing.
[New Thread 3443]
[Switching to Thread 3443]
Breakpoint 4, sys_write (fd=3, buf=0xbfc2309b "", count=1) at fs/read_write.c:378
378 if (file) {
(gdb) c
Continuing.
[Switching to Thread 3155]
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "vmlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=12)
at fs/read_write.c:378
378 if (file) {
-----------------------------------
这个是c语言的
Breakpoint 4, sys_write (fd=1, buf=0x8049568 "waht the fuck~!!n", count=1000) at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
[Switching to Thread 3155]
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "vmlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=12)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 ".mlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "/mlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "amlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
应该是write处理不一样
汇编的
Breakpoint 4, sys_write (fd=1, buf=0x80484a0 "what the fuck~!!n", count=1000) at fs/read_write.c:378
378 if (file) {
(gdb) c
Continuing.
[New Thread 3443]
[Switching to Thread 3443]
Breakpoint 4, sys_write (fd=3, buf=0xbfc2309b "", count=1) at fs/read_write.c:378
378 if (file) {
(gdb) c
Continuing.
[Switching to Thread 3155]
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "vmlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=12)
at fs/read_write.c:378
378 if (file) {
-----------------------------------
这个是c语言的
Breakpoint 4, sys_write (fd=1, buf=0x8049568 "waht the fuck~!!n", count=1000) at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
[Switching to Thread 3155]
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "vmlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=12)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 ".mlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "/mlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
378 if (file) {
(gdb)
Continuing.
Breakpoint 4, sys_write (fd=2,
buf=0x937c808 "amlinux1:~# om[C33[C33[C33[C33[C33[C33[C33[Cls33[K", '锟? ..., count=1)
at fs/read_write.c:378
应该是write处理不一样