I don't quite understand the 1.c. I can't find any syscall, when disas
the address as followed:
...
0x000000000040053d 4 write(1, "hi2\n", 4);
(gdb) si
0x0000000000400408 in write@plt ()
Current language: auto; currently asm
(gdb) disas 0x0000000000400408
Dump of assembler code for function write@plt:
0x0000000000400408 <write@plt+0>: jmpq *0x200bfa(%rip)
# 0x601008 <_GLOBAL_OFFSET_TABLE_+32>
0x000000000040040e <write@plt+6>: pushq $0x1
0x0000000000400413 <write@plt+11>: jmpq 0x4003e8 <_init+24>
End of assembler dump.
...
Not sure I got it right, but the instructions are confused. Can you
explain it in more detail? Thank you.
Truong.
I also have the same problem, I could only see "syscall" symbols
when "disas ADDRESS" of write() function, but when I disas "syscall"
or later addresses, neither "int" instruction nor "_write" symbol
found, it directly output "hi2" after following 3 "si" operations.
(gdb) si
0x00007f49618efd80 in write () from /lib/libc.so.6
(gdb) disas 0x00007f49618efd80
Dump of assembler code for function write:
0x00007f49618efd80 <write+0>: cmpl $0x0,0x298301(%rip) #
0x7f4961b880
88
0x00007f49618efd87 <write+7>: jne 0x7f49618efd99 <write+25>
0x00007f49618efd89 <write+9>: mov $0x1,%eax
0x00007f49618efd8e <write+14>: syscall
0x00007f49618efd90 <write+16>: cmp $0xfffffffffffff001,%rax
0x00007f49618efd96 <write+22>: jae 0x7f49618efdeb <write+107>
0x00007f49618efd98 <write+24>: retq
0x00007f49618efd99 <write+25>: sub $0x28,%rsp
0x00007f49618efd9d <write+29>: mov %rdi,0x8(%rsp)
0x00007f49618efda2 <write+34>: mov %rsi,0x10(%rsp)
0x00007f49618efda7 <write+39>: mov %rdx,0x18(%rsp)
0x00007f49618efdac <write+44>: callq 0x7f496190bbf0
0x00007f49618efdb1 <write+49>: mov 0x8(%rsp),%rdi
0x00007f49618efdb6 <write+54>: mov 0x10(%rsp),%rsi
0x00007f49618efdbb <write+59>: mov 0x18(%rsp),%rdx
0x00007f49618efdc0 <write+64>: mov %rax,(%rsp)
0x00007f49618efdc4 <write+68>: mov $0x1,%eax
0x00007f49618efdc9 <write+73>: syscall
0x00007f49618efdcb <write+75>: mov (%rsp),%rdi
0x00007f49618efdcf <write+79>: mov %rax,0x8(%rsp)
0x00007f49618efdd4 <write+84>: callq 0x7f496190bbc0
---Type <return> to continue, or q <return> to quit---
0x00007f49618efdd9 <write+89>: mov 0x8(%rsp),%rax
0x00007f49618efdde <write+94>: add $0x28,%rsp
0x00007f49618efde2 <write+98>: cmp $0xfffffffffffff001,%rax
0x00007f49618efde8 <write+104>: jae 0x7f49618efdeb <write+107>
0x00007f49618efdea <write+106>: retq
0x00007f49618efdeb <write+107>: mov 0x2931ae(%rip),%rcx #
0x7f4961b82f
a0
0x00007f49618efdf2 <write+114>: xor %edx,%edx
0x00007f49618efdf4 <write+116>: sub %rax,%rdx
0x00007f49618efdf7 <write+119>: mov %edx,%fs:(%rcx)
0x00007f49618efdfa <write+122>: or $0xffffffffffffffff,%rax
0x00007f49618efdfe <write+126>: jmp 0x7f49618efdea <write+106>
End of assembler dump.
(gdb) si
0x00007f49618efd89 in write () from /lib/libc.so.6
(gdb) si
0x00007f49618efd8e in write () from /lib/libc.so.6
(gdb) si
hi2
By the way, I want to check whether we are supposed to use the
server sf06.cs.umb.edu or not. Thanks!
Weiwei
On Sun, 14 Feb 2010, Weiwei wrote:
> Hi professor,
>
> I also have the same problem, I could only see "syscall" symbols
> when "disas ADDRESS" of write() function, but when I disas "syscall"
> or later addresses, neither "int" instruction nor "_write" symbol
> found, it directly output "hi2" after following 3 "si" operations.
>
> (gdb) si
> 0x00007f49618efd80 in write () from /lib/libc.so.6
> (gdb) disas 0x00007f49618efd80
> Dump of assembler code for function write:
> 0x00007f49618efd80 <write+0>: cmpl $0x0,0x298301(%rip) #
> 0x7f4961b880
> 88
> 0x00007f49618efd87 <write+7>: jne 0x7f49618efd99 <write+25>
> 0x00007f49618efd89 <write+9>: mov $0x1,%eax
> 0x00007f49618efd8e <write+14>: syscall <---Here it is!!
d. Use si to proceed across the system call. Note how the whole
system call execution appears at user level to be due to this one
instruction. Is it int $0x80 or sysenter or what?
Sorry, I should have edited the first ref. --Betty O.
windy@sf06:~/cs644/hw1$ gcc -g hi.c -o hi
windy@sf06:~/cs644/hw1$ ls
hi hi.c linux_syscalls.script
windy@sf06:~/cs644/hw1$ hi
The program 'hi' is currently not installed. To run 'hi' please ask
your administrator to install the package 'hmake'
-bash: hi: command not found
windy@sf06:~/cs644/hw1$
I have no problem to do this in Unix on Sun Blades.
What is wrong here?
Truong.