如何在gdb中的FS或GS基础上使用逻辑地址? [英] How to use a logical address with an FS or GS base in gdb?

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

问题描述

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

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

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

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 ?

注意:我知道我可以在执行此指令后简单地阅读%eax,但这不是我关心的问题

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

推荐答案

我该如何读取gdb中%gs:0x14"处的内存

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

您不能:GDB无法知道如何设置%gs 所指向的段.

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

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

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

同样,您通常无法执行此操作.但是,您似乎在32位x86 Linux上,并且可以进行操作-将%gs 设置为通过 set_thread_area 系统调用.

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.

您可以在GDB中执行 catch syscall set_thread_area 并检查参数(每个线程都会有一个这样的调用).实际执行此操作的代码是这里.一旦知道如何设置%gs ,只需将0x14添加到 base_addr ,就可以完成.

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中的FS或GS基础上使用逻辑地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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