非常大的地址被复制为负值 [英] Very large address copied as negative value

查看:59
本文介绍了非常大的地址被复制为负值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览与C程序相对应的二进制文件.
我有一个很大的地址存储在%eax 中.
当尝试通过 gdb 查看该值时,它会显示一个负值(原因在此处).

I was going through a binary file corresponding to a C program.
I have a very large address stored in %eax.
When tried to see the value via gdb, it prints a negative value (reason here).

现在,当执行 mov%eax,0x4c(%esp)时, 0x4c(%esp)中的结果有时为正,有时为负.随后出现 cmp $ 0,0x4c(%esp)语句!

Now when mov %eax, 0x4c(%esp) is performed, the resulted value in 0x4c(%esp) is sometimes positive and sometimes negative. This effect cmp $0, 0x4c(%esp) statement that follows!

有人可以解释这种行为吗?

Can someone please explain this behavior?

如果这有帮助:
core:ELF 32位LSB核心文件Intel 80386,版本1(SYSV),SVR4样式

推荐答案

寄存器没有符号;他们持有位.如何解释它们取决于您.堆栈也是如此:它包含位,并且如何解释它们取决于您.如果将值从寄存器移至堆栈,则会复制这些位.而且,如果您像解释寄存器中的位一样解释堆栈中的位,您将获得相同的值.

Registers do not have signs; they hold bits. It's up to you how you interpret them. The same holds for the stack: it holds bits, and it's up to you how to interpret them. If you move a value from a register to the stack, the bits are copied. And if you interpret bits on the stack like you interpret bits in a register, you get the same value.

请注意,有 条指令将这些位解释为值-乘法,比较等.但是 MOV 不是其中之一.

Note that there are instructions which interpret those bits as values - multiply, compare, etcetera. But MOV isn't one of those.

这篇关于非常大的地址被复制为负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆