gdb - 在 Ubuntu 14.04 上加载内核模块
gdb - load kernel module on Ubuntu 14.04
Ubuntu 14.04 LTS:
user@peterubuntu0:$ insmod mymodule
user@peterubuntu0:/sys/module/mymodule/sections$ cat .text .data .bss
0x0000000000000000
0x0000000000000000
0x0000000000000000
那么,当我远程调试时,如何告诉 gdb 我的模块加载到目标机器上的什么位置?我是否只在添加符号文件命令中使用偏移量(那么 .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
returns 仅当作为 root 执行时数据部分的地址(对我来说有意义),否则 returns 0x0000000000000000:
user@peterubuntu0:~$ su
user@peterubuntu0:~$
root@peterubuntu0:~$ cat .text .data .bss
root@peterubuntu0:~$ 0xffffffffa0518000
root@peterubuntu0:~$ 0xffffffffa073b000
root@peterubuntu0:~$ 0xffffffffa089b460
Ubuntu 14.04 LTS:
user@peterubuntu0:$ insmod mymodule
user@peterubuntu0:/sys/module/mymodule/sections$ cat .text .data .bss
0x0000000000000000
0x0000000000000000
0x0000000000000000
那么,当我远程调试时,如何告诉 gdb 我的模块加载到目标机器上的什么位置?我是否只在添加符号文件命令中使用偏移量(那么 .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
returns 仅当作为 root 执行时数据部分的地址(对我来说有意义),否则 returns 0x0000000000000000:
user@peterubuntu0:~$ su
user@peterubuntu0:~$
root@peterubuntu0:~$ cat .text .data .bss
root@peterubuntu0:~$ 0xffffffffa0518000
root@peterubuntu0:~$ 0xffffffffa073b000
root@peterubuntu0:~$ 0xffffffffa089b460