gpt4 book ai didi

c - gdb - 在 Ubuntu 14.04 上加载内核模块

转载 作者:行者123 更新时间:2023-11-30 17:12:50 25 4
gpt4 key购买 nike

Ubuntu 14.04 LTS:

user@peterubuntu0:$ insmod mymodule
user@peterubuntu0:/sys/module/mymodule/sections$ cat .text .data .bss
0x0000000000000000
0x0000000000000000
0x0000000000000000

那么,当我远程调试时,如何告诉 gdb 我的模块在目标计算机上加载的位置?我是否只在 add-symbol-file 命令中使用偏移量(那么 .text 的十进制数为 0x64 或 64?)?

user@peterubuntu0:~$ objdump mymodule.ko --section-headers

mymodule.ko: file format elf64-x86-64

Sections:
Idx Name Size VMA LMA File off Algn
0 .note.gnu.build-id 00000024 0000000000000000 0000000000000000 00000040 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 0000b345 0000000000000000 0000000000000000 00000064 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
12 .data 000001e4 0000000000000000 0000000000000000 00012620 2**5
CONTENTS, ALLOC, LOAD, RELOC, DATA, LINK_ONCE_DISCARD
15 .bss 00000014 0000000000000000 0000000000000000 00012a80 2**3
ALLOC

最佳答案

cat .text .data .bss 仅当作为 root 执行时才返回数据节的地址(对我来说有意义),否则返回 0x0000000000000000:

user@peterubuntu0:~$ su
user@peterubuntu0:~$
root@peterubuntu0:~$ cat .text .data .bss
root@peterubuntu0:~$ 0xffffffffa0518000
root@peterubuntu0:~$ 0xffffffffa073b000
root@peterubuntu0:~$ 0xffffffffa089b460

关于c - gdb - 在 Ubuntu 14.04 上加载内核模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com