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

标签 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。

watch 第一部分有 2 个表达式:吃信息吃货

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

我有两个问题:

这个 544497989 的值是多少?为什么我看到 EatLen 的“无法访问”消息?

最佳答案

544497989EatMsg 的地址,它只是内存位置,即一些巨大的数字。如果您了解 C 或 C++,则相当于 &eatMsg如果您的声明是 char * eatMsg = "Eat at Joe's!";EatLenEatMsg 的长度: $代表“此时的地址”,即EatMsg的所有字节之后的下一个位置.所以$-EatMsg是“EatMsg 的所有字节后的地址减去 EatMsg 的开头地址” = “EatMsg 的长度” = 14 十进制 = 0x0E 十六进制。

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

关于ubuntu - 无法在 0xe 访问内存,Ubuntu 上的 kdbg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27719411/

相关文章:

linux - 如何在 Linux 上安装后隐藏设备/卷

c# - Visual Studio 代码 sh : 0: Can't open undefined/build. sh

c++ - 用 C 或汇编制作一个简单的 CRT0

c - KDBG 监视所有 arg 变量

ubuntu - KDbg 无法在 ubuntu 上运行/启动

node.js - 我正在尝试在 Ubuntu 16.04 中安装 nginx,但出现有关语言环境设置的错误

git - 设置FORCE=yes后安装openstack时出错

c - 如何用c编译汇编语言

assembly - 如何在emu8086中创建和绘制 Sprite ?

c++ - Kdbg 不允许检查 std::string 或 std::vector 的内容