94 lines
3.0 KiB
Plaintext
94 lines
3.0 KiB
Plaintext
1 et 2. systeme d'exploitation : Linux en 64 bits / architect : aarch64 / process: Little Endian
|
|
|
|
2.
|
|
|
|
as -gstabs -o printHW.o printHW.s
|
|
ld -O0 printHW.o
|
|
|
|
3.
|
|
|
|
./a.out => "Hello World!"
|
|
|
|
4]
|
|
raban@rp73:~/SCR/TP16-ARM$ gdb a.out
|
|
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
|
|
Copyright (C) 2021 Free Software Foundation, Inc.
|
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
This is free software: you are free to change and redistribute it.
|
|
There is NO WARRANTY, to the extent permitted by law.
|
|
Type "show copying" and "show warranty" for details.
|
|
This GDB was configured as "aarch64-linux-gnu".
|
|
Type "show configuration" for configuration details.
|
|
For bug reporting instructions, please see:
|
|
<https://www.gnu.org/software/gdb/bugs/>.
|
|
Find the GDB manual and other documentation resources online at:
|
|
<http://www.gnu.org/software/gdb/documentation/>.
|
|
|
|
For help, type "help".
|
|
Type "apropos word" to search for commands related to "word"...
|
|
Reading symbols from a.out...
|
|
(gdb) run
|
|
Starting program: /export/home/senart22/raban/SCR/TP16-ARM/a.out
|
|
Hello World!
|
|
[Inferior 1 (process 634476) exited normally]
|
|
(gdb) l 10,15
|
|
10 .text // tells assembler to assemble the following
|
|
11 // in the text (code) section
|
|
12 .globl _start // _start is there where the program starts,
|
|
13 // .globl makes it visible to the linker
|
|
14 _start:
|
|
15 mov x0,#1 // value 1 is placed in register x0
|
|
(gdb) b 12
|
|
Breakpoint 1 at 0x4000b0: file printHW.s, line 15.
|
|
(gdb) run
|
|
Starting program: /export/home/senart22/raban/SCR/TP16-ARM/a.out
|
|
|
|
Breakpoint 1, _start () at printHW.s:15
|
|
15 mov x0,#1 // value 1 is placed in register x0
|
|
(gdb) i r x0 x1 x2 w8
|
|
x0 0x0 0
|
|
x1 0x0 0
|
|
x2 0x0 0
|
|
w8 0x0 0
|
|
(gdb) step
|
|
16 adr x1,msg // the address retained by label msg is placed in register x1
|
|
(gdb) i r x0 x1 x2 w8
|
|
x0 0x1 1
|
|
x1 0x0 0
|
|
x2 0x0 0
|
|
w8 0x0 0
|
|
(gdb) s
|
|
17 mov x2,#13
|
|
(gdb) i r x0 x1 x2 w8
|
|
x0 0x1 1
|
|
x1 0x4100d0 4260048
|
|
x2 0x0 0
|
|
w8 0x0 0
|
|
(gdb) x /s 0x4100d0
|
|
0x4100d0: "Hello World!\n"
|
|
(gdb) x /14cb 0x4100d0
|
|
0x4100d0: 72 'H' 101 'e' 108 'l' 108 'l' 111 'o' 32 ' ' 87 'W' 111 'o'
|
|
0x4100d8: 114 'r' 108 'l' 100 'd' 33 '!' 10 '\n' 0 '\000'
|
|
(gdb) s
|
|
18 mov w8, #SYS_WRITE // svc must find the syscall number in w8
|
|
(gdb) i r x0 x1 x2 w8
|
|
x0 0x1 1
|
|
x1 0x4100d0 4260048
|
|
x2 0xd 13
|
|
w8 0x0 0
|
|
(gdb) s
|
|
20 svc #0 // invoke syscall: displays on the screen
|
|
(gdb) i r x0 x1 x2 w8
|
|
x0 0x1 1
|
|
x1 0x4100d0 4260048
|
|
x2 0xd 13
|
|
w8 0x40 64
|
|
(gdb) s
|
|
Hello World!
|
|
21 mov x0, #0 // in x0 put the value you want to exit with
|
|
(gdb) c
|
|
Continuing.
|
|
[Inferior 1 (process 634489) exited normally]
|
|
(gdb)
|
|
|