Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ toolchain support #90

Open
stephenrkell opened this issue Mar 6, 2024 · 0 comments
Open

C++ toolchain support #90

stephenrkell opened this issue Mar 6, 2024 · 0 comments

Comments

@stephenrkell
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant