Function in AOT executable:
[UnmanagedCallersOnly(EntryPoint = "Add")]
static int Add(int a, int b)
{
return a + b;
}
C++ loader code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
typedef int (*add_func)(int, int);
int main()
{
void* handle;
add_func add;
handle = LoadLibrary(L"AOTTest.exe");
if (!handle) {
fprintf(stderr, "Failed to load library");
return 1;
}
add = (add_func)GetProcAddress((HMODULE)handle, "Add");
if (!add) {
fprintf(stderr, "No add");
FreeLibrary((HMODULE)handle);
return 1;
}
int result = add(3, 5);
printf("Result of Add(3, 5): %dn", result);
FreeLibrary((HMODULE)handle);
return 0;
}
The output of the loader is: No add
.
I also ran dumpbin /EXPORTS
to see what symbols are exported and the output was:
File Type: EXECUTABLE IMAGE
Summary
2000 .data
2000 .pdata
A000 .rdata
1000 .reloc
1000 .rsrc
17000 .text
1000 _RDATA
Is it limitation of the AOT?