Bug 29930 - disassemble does not show symbol name sometimes
Summary: disassemble does not show symbol name sometimes
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 12.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-21 22:18 UTC by Glenn Washburn
Modified: 2023-02-10 18:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2023-02-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Glenn Washburn 2022-12-21 22:18:54 UTC
Here is the output of disassemble that shows this issue:

(gdb) disassemble
Dump of assembler code for function grub_cmd_read:
   0x000000007bec6720 <+0>:     push   %r15
   0x000000007bec6722 <+2>:     push   %r14
   0x000000007bec6724 <+4>:     push   %r13
   0x000000007bec6726 <+6>:     push   %r12
   0x000000007bec6728 <+8>:     mov    %esi,%r12d
   0x000000007bec672b <+11>:    push   %rbp
   0x000000007bec672c <+12>:    push   %rbx
   0x000000007bec672d <+13>:    sub    $0x18,%rsp
   0x000000007bec6731 <+17>:    mov    0x8(%rdi),%rax
=> 0x000000007bec6735 <+21>:    mov    $0x5,%edi
   0x000000007bec673a <+26>:    mov    %rdx,0x8(%rsp)
   0x000000007bec673f <+31>:    mov    (%rax),%r14d
   0x000000007bec6742 <+34>:    movabs $0x7da81596,%rax
   0x000000007bec674c <+44>:    call   *%rax
   0x000000007bec674e <+46>:    test   %rax,%rax
   0x000000007bec6751 <+49>:    je     0x7bec67f7 <grub_cmd_read+215>
   0x000000007bec6757 <+55>:    movabs $0x7da87eff,%r15
   0x000000007bec6761 <+65>:    mov    %rax,%rbp
...

(gdb) info symbol 0x7da81596
grub_malloc in section .text of /home/grub-tester/bootloader/build/obj-x86_64-efi/grub-core/kernel.exec


We can see here that gdb knows of symbol grub_malloc at 0x7da81596, however, in the disassembly at the second line below the one starting with '=>', the value $0x7da81596 is not substituted for "grub_malloc".

Perhaps this can be turned on by setting special flags to the disassembler, but I've not encountered any. Nor have I seen any gdb settings that might turn this on.

I believe this happens for all literals that are in instructions that do not potentially change the instruction pointer, like movabs, whereas instructions that do, like je, have the symbol.
Comment 1 Tom Tromey 2023-02-10 18:44:44 UTC
Offhand I don't know whether this is a bug in gdb or in libopcodes.