如何在gdb中使用逻辑地址? [英] How to use a logical address in gdb?

查看:217
本文介绍了如何在gdb中使用逻辑地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gdb提供读取或写入特定线性地址的功能,例如:

  (gdb)x / 1wx 0x080483e4 
0x80483e4< main> ;: 0x83e58955
(gdb)

但你如何指定一个逻辑地址?我来到以下指令:

  0x0804841a< + 6>:mov%gs:0x14,%eax 

如何在gdb的%gs:0x14处读取内存,或将此逻辑地址转换为线性地址我可以在 x 命令中使用吗?



注意:我知道我可以在此指令后简单读取%eax ,但这不是我关心的问题。 gdb中的0x14

您不能:GDB无法知道%gs 指已设置。


或将此逻辑地址转换为线性地址,即i可以在x命令中使用


同样,你不能一般这样做。但是,您似乎在32位x86 Linux上,并且可以 %gs 设置为指向线程描述符通过 set_thread_area 系统调用。



您可以执行 catch syscall set_thread_area 在GDB中,并检查参数(每个线程将有一个这样的调用)。实际执行的代码是这里。一旦你知道如何设置%gs ,只需将0x14加入 base_addr 中即可。 / p>

gdb provides functionality to read or write to a specific linear address, for example:

(gdb) x/1wx 0x080483e4
0x80483e4 <main>:       0x83e58955
(gdb) 

but how do you specify a logical address ? I came accross the following instruction:

   0x0804841a <+6>:     mov    %gs:0x14,%eax

how can i read the memory at "%gs:0x14" in gdb, or translate this logical address to a linear address that i could use in x command ?

note: i know that i could simply read %eax after this instruction, but that is not my concern

解决方案

how can i read the memory at "%gs:0x14" in gdb

You can't: there is no way for GDB to know how the segment to which %gs refers to has been set up.

or translate this logical address to a linear address that i could use in x command

Again, you can't do this in general. However, you appear to be on 32-bit x86 Linux, and there you can do that -- the %gs is set up to point to the thread descriptor via set_thread_area system call.

You can do catch syscall set_thread_area in GDB, and examine the parameters (each thread will have one such call). The code to actually do that is here. Once you know how %gs has been set up, just add 0x14 to the base_addr, and you are done.

这篇关于如何在gdb中使用逻辑地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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