RFC: Disassembly with call frame information

Nick Clifton nickc@redhat.com
Thu Oct 19 15:59:24 GMT 2023
Hi Guys,

  I am currently working on a patch (attached) to add an option to the
  disassembler to display call frame information alongside the
  disassembly.  This is a work in progress, but I wanted to see if
  anyone was interested in the current state or had suggestions for
  improvements.

  The output currently looks like this:

    $ objdump hello.o --disassemble-with-cfi

    hello.o:     file format elf64-x86-64

    Disassembly of section .text:

    0000000000000000 <main>:
       0:	55                   	push   %rbp            # cfi: rsp+8    
       1:	48 89 e5             	mov    %rsp,%rbp       # cfi: rsp+16   
       4:	bf 00 00 00 00       	mov    $0x0,%edi       # cfi: rbp+16   
       9:	b8 00 00 00 00       	mov    $0x0,%eax
       e:	e8 00 00 00 00       	call   13 <main+0x13>
      13:	5d                   	pop    %rbp
      14:	c3                   	ret                    # cfi: rsp+8    

  The patch works by taking advantage of the code in the dwarf library
  to display interpreted call frame information.  This interpreted
  information is recorded and then replayed as the disassembly takes
  place.

  I am not sure how much information to display.  Currently I am just
  showing the CFA assignments, but maybe I need to include the rbp and
  ra updates as well ?

    $ objdump hello.o --dwarf=frames-interp

    Contents of the .eh_frame section:
    00000018 000000000000001c 0000001c FDE cie=00000000 pc=0000000000000000..0000000000000015
       LOC           CFA      rbp   ra    
    0000000000000000 rsp+8    u     c-8   
    0000000000000001 rsp+16   c-16  c-8   
    0000000000000004 rbp+16   c-16  c-8   
    0000000000000014 rsp+8    c-16  c-8   

  Anyway that is where I am at the moment.

Cheers
  Nick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: disassembly-with-cfi.patch
Type: text/x-patch
Size: 36370 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20231019/b37dbeca/attachment-0001.bin>


More information about the Binutils mailing list