The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



"Выпуск отладчика GDB 8.3"
Версия для распечатки Пред. тема | След. тема
Форум Разговоры, обсуждение новостей
Исходное сообщение [ Отслеживать ]
Отдельный RSS теперь доступен для каждого обсуждения в форуме и каждого минипортала.
. "Выпуск отладчика GDB 8.3" +/
Сообщение от Аноним (14), 15-Май-19, 15:30 
> Почему этот gdb при отладке ассемблерного кода вместо того, чтобы работать с листингом или исходниками, занимается дизассемблированием?

Рили?

$ cat > hello.s
# ----------------------------------------------------------------------------------------
# Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
# To assemble and run:
#
#     gcc -c hello.s && ld hello.o && ./a.out
#
# or
#
#     gcc -nostdlib hello.s && ./a.out
# ----------------------------------------------------------------------------------------

        .global _start

        .text
_start:
        # write(1, message, 13)
        mov     $1, %rax                # system call 1 is write
        mov     $1, %rdi                # file handle 1 is stdout
        mov     $message, %rsi          # address of string to output
        mov     $13, %rdx               # number of bytes
        syscall                         # invoke operating system to do the write

        # exit(0)
        mov     $60, %rax               # system call 60 is exit
        xor     %rdi, %rdi              # we want return code 0
        syscall                         # invoke operating system to exit
message:
        .ascii  "Hello, world\n"
^D
$ gcc -g -no-pie -nostdlib hello.s
$ gdb a.out
GNU gdb (Debian 8.2.1-2) 8.2.1
Copyright (C) 2018 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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...done.
(gdb) break hello.s:20
Breakpoint 1 at 0x401015: file hello.s, line 20.
(gdb) run
Starting program: /home/anon/a.out

Breakpoint 1, _start () at hello.s:20
20            mov     $13, %rdx               # number of bytes
(gdb) list
15    _start:
16            # write(1, message, 13)
17            mov     $1, %rax                # system call 1 is write
18            mov     $1, %rdi                # file handle 1 is stdout
19            mov     $message, %rsi          # address of string to output
20            mov     $13, %rdx               # number of bytes
21            syscall                         # invoke operating system to do the write
22    
23            # exit(0)
24            mov     $60, %rax               # system call 60 is exit
(gdb) detach
Detaching from program: /home/anon/a.out, process 28910
[Inferior 1 (process 28910) detached]
Hello, world
(gdb) quit
$


Что это было, по-твоему, если не исходник?
Ответить | Правка | Наверх | Cообщить модератору

Оглавление
Выпуск отладчика GDB 8.3, opennews, 12-Май-19, 08:32  [смотреть все]
Форумы | Темы | Пред. тема | След. тема



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру