Skip to content

C++ toolchain support #90

@stephenrkell

Description

@stephenrkell

Conceptually, very little is missing for us to introspect on C++. But one unfortunate thing is that dumpallocs.ml does not work on C++ source, so we will need a C++ified version of that anyway... there is at least one C++ clang-based tool in toolsub that would be a good base.

Continuing that thought: if it uses (built-in) operator new then we need to add this to our list of allocation functions. The binary analysis (objdumpallocs / objdumpmeta) should have no trouble with this. At source level, the built-in operator new is polymorphic, but at linker level it always seems to come out as operator new[](unsigned long). If I write a simple bit of C++ code that does new...

$ diff -u <( objdump -rd test.o ) <( objdump -rd test.o| c++filt )
--- /dev/fd/63  2024-03-06 11:14:14.893088042 +0000
+++ /dev/fd/62  2024-03-06 11:14:14.893088042 +0000
@@ -10,40 +10,40 @@
    4:  48 83 ec 10             sub    $0x10,%rsp
    8:  bf a8 00 00 00          mov    $0xa8,%edi
    d:  e8 00 00 00 00          callq  12 <main+0x12>
-                       e: R_X86_64_PLT32       _Znam-0x4
+                       e: R_X86_64_PLT32       operator new[](unsigned long)-0x4
   12:  48 89 45 f8             mov    %rax,-0x8(%rbp)
   16:  be 2a 00 00 00          mov    $0x2a,%esi
   1b:  48 8d 3d 00 00 00 00    lea    0x0(%rip),%rdi        # 22 <main+0x22>
                        1e: R_X86_64_PC32       e+0xc
...

So in our C++ified version ofdumpallocs.ml, as well as doing the sizeofness analysis for C-style allocation functions (or maybe the generalised version of it mooted in #63), we need something simpler for C++ that can dump the source type of a built-in operator new application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions