当可执行文件不可访问时,gdb 也会显示 ELF 节名称

问题描述 投票:0回答:1

在我的 Linux 系统上,当

gdb
可执行文件本身无法从
ELF
访问时,
ELF
显示已调试的
gdb
可执行文件中各部分的名称,因为它存在于安装在不同
mount
上的文件系统中命名空间。

root@host:/# gdb -q attach 7173
attach: No such file or directory.
Attaching to process 7173
[New LWP 17381]
[New LWP 17380]
[New LWP 17379]
[New LWP 17378]
[New LWP 9639]
[New LWP 9618]
[New LWP 9617]
[New LWP 7533]
[New LWP 7531]
[New LWP 7530]
[New LWP 7529]
[New LWP 7323]
[New LWP 7297]
[New LWP 7291]
[New LWP 7290]
[New LWP 7285]
[New LWP 7284]
(gdb) info files 
Symbols from "target:/proc/7173/exe".
Native process:
        Using the running image of attached process 7173.
        While running this, GDB does not access memory from...
Local exec file:
        `target:/proc/7173/exe', file type elf64-x86-64.
        Entry point: 0x564521600970
        0x00005645215fa200 - 0x00005645215fa21c is .interp
        0x00005645215fa21c - 0x00005645215fa23c is .note.ABI-tag
        0x00005645215fa23c - 0x00005645215fa260 is .note.gnu.build-id
        0x00005645215fa260 - 0x00005645215fb0b8 is .dynsym
        0x00005645215fb0b8 - 0x00005645215fb1ea is .gnu.version
        0x00005645215fb1ec - 0x00005645215fb23c is .gnu.version_r
        0x00005645215fb240 - 0x00005645215fb588 is .gnu.hash
        0x00005645215fb588 - 0x00005645215fcc2c is .dynstr
        0x00005645215fcc30 - 0x00005645215fe850 is .rela.dyn
        0x00005645215fe850 - 0x00005645215feaf0 is .rela.plt
        0x00005645215feaf0 - 0x00005645215fff41 is .rodata
        0x00005645215fff44 - 0x0000564521600140 is .eh_frame_hdr
        0x0000564521600140 - 0x000056452160096c is .eh_frame
        0x0000564521600970 - 0x00005645216012f1 is .text
        0x00005645216012f4 - 0x000056452160130e is .init
        0x0000564521601310 - 0x0000564521601319 is .fini
        0x0000564521601320 - 0x00005645216014f0 is .plt
        0x0000564521602000 - 0x0000564521602010 is .data
        0x0000564521602010 - 0x0000564521602018 is .jcr
        0x0000564521602018 - 0x0000564521602018 is .tm_clone_table
        0x0000564521602018 - 0x0000564521602020 is .fini_array
        0x0000564521602020 - 0x0000564521602028 is .init_array
        0x0000564521602028 - 0x0000564521602fe8 is .data.rel.ro
        0x0000564521602fe8 - 0x0000564521603298 is .dynamic
        0x0000564521603298 - 0x00005645216034e0 is .got
        0x00005645216034e0 - 0x00005645216035d8 is .got.plt
        0x00005645216035e0 - 0x0000564521603ee4 is .bss
        0x00007f0bfa9e4190 - 0x00007f0bfa9e41b4 is .note.gnu.build-id in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e41b8 - 0x00007f0bfa9e467c is .hash in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e4680 - 0x00007f0bfa9e56a0 is .dynsym in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e56a0 - 0x00007f0bfa9e60d1 is .dynstr in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e60d2 - 0x00007f0bfa9e622a is .gnu.version in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e6230 - 0x00007f0bfa9e62d0 is .gnu.version_r in target:/pkg/lib/libmemdbg.so
        0x00007f0bfa9e62d0 - 0x00007f0bfa9e6690 is .rela.dyn in target:/pkg/lib/libmemdbg.so
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
(gdb) 

据我所知,

gdb
实际上是直接从进程的内存映像中读取有关ELF可执行部分的信息。

然而重点是:由于

ELF
节头表(
SHT
)没有加载到进程的内存地址空间中,
gdb
如何获取那些
ELF
可执行文件节的名称?谢谢。

gdb symbols elf debug-symbols
1个回答
0
投票

gdb -q attach 7173

此命令指示 GDB 从名为

attach
的可执行文件加载符号。

您想要的命令是:

gdb -p 7173
© www.soinside.com 2019 - 2024. All rights reserved.