无法访问内存 在 0xe,在 Ubuntu 上访问 kdbg



我正在学习杰夫·邓特曼(Jeff Duntemann)的书:一步一步的组装。以下是提供的源代码:

SECTION .data           ; Section containing initialised data
    EatMsg: db "Eat at Joe's!",10
    EatLen: equ $-EatMsg    
SECTION .bss            ; Section containing uninitialized data 
SECTION .text           ; Section containing code
global  _start          ; Linker needs this to find the entry point!
_start:
    nop         ; This no-op keeps gdb happy...
    mov eax,4       ; Specify sys_write call
    mov ebx,1       ; Specify File Descriptor 1: Standard Output
    mov ecx,EatMsg      ; Pass offset of the message
    mov edx,EatLen      ; Pass the length of the message
    int 80H         ; Make kernel call
    MOV eax,1       ; Code for Exit Syscall
    mov ebx,0       ; Return a code of zero 
    int 80H         ; Make kernel call

我有Ubuntu 12.04 32位运行在VirtualBoxVM上,位于64位MacOS Yosemite之上。

我打电话给:

kdbg eatsyscall

以启动 KDBG。

手表部分,我有 2 个表达式:EatMsgEatLen

当我使用 KDBG 为 EatMsg 运行代码时,我看到: 544497989但对于 EatLen,我看到:无法访问内存 0xe

我有两个问题:

这个544497989值是多少,为什么对于 EatLen,我会看到"无法访问"消息?

544497989EatMsg的地址,它只是内存位置,即一些巨大的数字。如果您知道 C 或 C++,则相当于 &eatMsg 如果您的声明是char * eatMsg = "Eat at Joe's!";

EatLenEatMsg的长度:$代表"此时的地址",这是EatMsg所有字节之后的下一个位置。所以$-EatMsg是"EatMsg 所有字节后的地址减去EatMsg开头的地址"="EatMsg长度"= 14 十进制 = 0x0E十六进制。

调试器可能会将此长度解释为地址。诸如此类的小值不能作为地址引用。您应该仅将其显示为值,而不是解释为地址。

最新更新