I have a shared library /opt/evince-3.28.4/lib/evince/4/backends/libpdfdocument.so
. In GDB
, I can easily detect a function at offset 0xa830
of this library, as shown below:
(gdb) disas 0xa830
Dump of assembler code for function ev_link_from_action(PdfDocument*, PopplerAction*):
0x000000000000a830 <+0>: cmpl $0xa,(%rsi)
0x000000000000a833 <+3>: ja 0xaaf0 <ev_link_from_action(PdfDocument*, PopplerAction*)+704>
0x000000000000a839 <+9>: push %r15
0x000000000000a83b <+11>: push %r14
0x000000000000a83d <+13>: lea 0x5f28(%rip),%rdx # 0x1076c
The output of objdump -D
on the library for this offset is shown below:
a826: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
a82d: 00 00 00
a830: 83 3e 0a cmpl $0xa,(%rsi)
a833: 0f 87 b7 02 00 00 ja aaf0 <__cxa_finalize@plt+0x1d10>
a839: 41 57 push %r15
No function name is printed at 0xa830
. Also, the output of objdump -t
on the library does not contain this offset. How can I detect the symbol name assuming the offset is known and GDB is not available?
P.S.: The shared library contains debuginfo
. The relevant portion of objdump -h
on the library is shown below:
25 .debug_aranges 00000030 0000000000000000 0000000000000000 00014bd9 2**0
CONTENTS, READONLY, DEBUGGING
26 .debug_info 00014b8d 0000000000000000 0000000000000000 00014c09 2**0
CONTENTS, READONLY, DEBUGGING
27 .debug_abbrev 00000773 0000000000000000 0000000000000000 00029796 2**0
CONTENTS, READONLY, DEBUGGING
28 .debug_line 00002036 0000000000000000 0000000000000000 00029f09 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_str 0000c377 0000000000000000 0000000000000000 0002bf3f 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_loc 0000d45f 0000000000000000 0000000000000000 000382b6 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_ranges 00001080 0000000000000000 0000000000000000 00045715 2**0
CONTENTS, READONLY, DEBUGGING
I have a shared library /opt/evince-3.28.4/lib/evince/4/backends/libpdfdocument.so
. In GDB
, I can easily detect a function at offset 0xa830
of this library, as shown below:
(gdb) disas 0xa830
Dump of assembler code for function ev_link_from_action(PdfDocument*, PopplerAction*):
0x000000000000a830 <+0>: cmpl $0xa,(%rsi)
0x000000000000a833 <+3>: ja 0xaaf0 <ev_link_from_action(PdfDocument*, PopplerAction*)+704>
0x000000000000a839 <+9>: push %r15
0x000000000000a83b <+11>: push %r14
0x000000000000a83d <+13>: lea 0x5f28(%rip),%rdx # 0x1076c
The output of objdump -D
on the library for this offset is shown below:
a826: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
a82d: 00 00 00
a830: 83 3e 0a cmpl $0xa,(%rsi)
a833: 0f 87 b7 02 00 00 ja aaf0 <__cxa_finalize@plt+0x1d10>
a839: 41 57 push %r15
No function name is printed at 0xa830
. Also, the output of objdump -t
on the library does not contain this offset. How can I detect the symbol name assuming the offset is known and GDB is not available?
P.S.: The shared library contains debuginfo
. The relevant portion of objdump -h
on the library is shown below:
25 .debug_aranges 00000030 0000000000000000 0000000000000000 00014bd9 2**0
CONTENTS, READONLY, DEBUGGING
26 .debug_info 00014b8d 0000000000000000 0000000000000000 00014c09 2**0
CONTENTS, READONLY, DEBUGGING
27 .debug_abbrev 00000773 0000000000000000 0000000000000000 00029796 2**0
CONTENTS, READONLY, DEBUGGING
28 .debug_line 00002036 0000000000000000 0000000000000000 00029f09 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_str 0000c377 0000000000000000 0000000000000000 0002bf3f 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_loc 0000d45f 0000000000000000 0000000000000000 000382b6 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_ranges 00001080 0000000000000000 0000000000000000 00045715 2**0
CONTENTS, READONLY, DEBUGGING
Share
Improve this question
edited Nov 17, 2024 at 23:12
TheAhmad
asked Nov 17, 2024 at 0:52
TheAhmadTheAhmad
9401 gold badge11 silver badges29 bronze badges
3
|
1 Answer
Reset to default 1How can I detect the symbol name assuming the offset is known and GDB is not available?
You'll have to use the same mechanism GDB used.
Unfortunately, you haven't told us where the libpdfdocument.so
came from, and without that we can't tell you what mechanism GDB actually used.
There are two likely candidates (that I know about):
- a separate debug info file.
- a special
.gnu_debugdata
mini-symbols section (see this answer).
GDB
. I need mangled symbols, whileGDB
forces demangling even withset print demangle off
andset print asm-demangle off
. This occurs even on the most recentGDB
version. Hence, I fell back onObjdump
. – TheAhmad Commented Nov 17, 2024 at 11:58