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

时间:2014-12-31 09:59:25

标签: ubuntu assembly kdbg

我正在学习Jeff Duntemann的书:Step by Step Assembly。这是提供的源代码:

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

我在64位MacOS Yosemite上运行VirtualBoxVM上的Ubuntu 12.04 32位。

我在打电话:

kdbg eatsyscall

启动KDBG。

观察部分,我有2个表达式: EatMsg EatLen

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

我有两个问题:

这544497989的价值是什么以及为什么EatLen我看到“无法访问”的消息?

1 个答案:

答案 0 :(得分:3)

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

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

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