-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add support for initializing vtable pointer of types without constructors #31
Comments
Some C++ compilers will sometimes generate an implicit constructor to handle this. For example, Test(): # @Test()
push rbp
mov rbp, rsp
sub rsp, 16
lea rdi, [rbp - 8]
call DefaultImpl::DefaultImpl() [base object constructor]
lea rax, [rbp - 8]
mov rdi, rax
call UseAllocator(AbstractBase*)
add rsp, 16
pop rbp
ret and impl$ = 32
void Test(void) PROC ; Test
$LN3:
sub rsp, 56 ; 00000038H
lea rcx, QWORD PTR impl$[rsp]
call DefaultImpl::DefaultImpl(void)
lea rcx, QWORD PTR impl$[rsp]
call void UseAllocator(AbstractBase *) ; UseAllocator
add rsp, 56 ; 00000038H
ret 0
void Test(void) ENDP ; Test |
This is blocking the use of |
Turns out this will be a bit of a pain since we can't synthesize We'll probably need to add synthesizing functions (which is very odd outside this situation) as well as special-case for generating these trampolines. It might also be worth checking if Clang is internally synthesizing a constructor declaration or not so we can maybe avoid doing it ourselves. |
…nstructors since they can't be initialized from C# yet. Relates to #31
…PxDefaultAllocator.
I added a warning to |
For types without constructors, the C++ compiler may initialize the vtable pointer wherever the type is initialized.
This was encountered with PxDefaultAllocator.
Here's a simple example: (Godbolt)
With GCC x86-64 10.2,
Test
is generated as follows:The easiest solution here is probably to use C trampolines for object construction (when necessary?)
The text was updated successfully, but these errors were encountered: