无法访问Ubuntu上0xe、kdbg处的内存
我正在学习杰夫·邓特曼的书:一步一步组装。以下是提供的源代码:无法访问Ubuntu上0xe、kdbg处的内存,ubuntu,assembly,kdbg,Ubuntu,Assembly,Kdbg,我正在学习杰夫·邓特曼的书:一步一步组装。以下是提供的源代码: 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 .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上运行了Ubuntu12.04 32位
我打电话:
kdbg eatsyscall
启动KDBG
在手表部分中,我有两个表达式:EatMsg和EatLen
当我为EatMsg使用KDBG运行代码时,我看到:544497989但对于EatLen,我看到:无法访问0xe处的内存
我有两个问题:
544497989的值是什么?为什么我看到EatLen的“无法访问”消息?
544497989
是EatMsg的地址,它只是内存位置,即一些巨大的数字。如果你知道C或C++,如果你的声明是“代码”,char * eATSG =“吃乔的”,则等于“代码>和EATSG G <代码>;代码>
EatLen
是EatMsg
的长度:$
代表“此点的地址”,它是EatMsg
所有字节之后的下一个位置。因此,$-EatMsg
是“所有EatMsg
字节后的地址减去EatMsg
开头的地址”=“EatMsg的长度”=14十进制=0x0E十六进制
调试器可能会将此长度解释为地址。像这样的小值不能作为地址引用。您应该仅将其显示为值,而不是将其解释为地址。但544497989不是2的幂。地址不应该是2的幂吗?完全不是。对于某些数据和体系结构,需要2(或4或8)的倍数,但对于
db
则不是这种情况。实际上,544497989(十进制),表示为十六进制的是20746145h-表示空间的ascii码,'t','a','E'-它显示为“向后”,因为多字节值存储为“小端”。如果你一次检查一个字节,它就会以“正确”的顺序出现。@FrankKotler很好!实际上,OP很可能显示的是EatMsg
的内容,而不是地址。