Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

Add Linux support to `InlineExportHelper`

Open PathogenDavid opened this issue 2 years ago • 3 comments

InlineExportHelper is currently very Windows-centric. The strategy for forcing exports with GCC/Clang targeting Linux is actually quite a bit simpler from some preliminary tests.

Our function pointer export already works the same for functions/normal methods. The linker pragma is not necessary (and probably has no equivalent.)

Unlike with Windows, we do not need to call via trampolines to call inline constructors/destructors. Simply calling them somewhere in dummy code will cause them to appear in the export table. For example, this function declaration will cause the based object constructor and base object destructor to be exported:

__attribute__((visibility("hidden"))) void __BiohazrdForceExportOfConstructors()
{
    delete new TestClass2();
    delete new TestClass3();
}

Still need to do some more research on how to cause the other kinds of constructors/destructors to be exported.

PathogenDavid avatar Aug 05 '21 17:08 PathogenDavid

This would be useful here: https://github.com/InfectedLibraries/Biohazrd/issues/211

PathogenDavid avatar Aug 05 '21 19:08 PathogenDavid

Added bare minimum support in https://github.com/InfectedLibraries/Biohazrd/commit/da037f714128797fdd36032e9374adfe87a60607. Would like to transition from trampolines to exporting constructors/destructors via dummy calls instead though.

PathogenDavid avatar Aug 05 '21 20:08 PathogenDavid

Note that doing this without trampolines is blocked by getting the correct mangling for Itanium destructors since the trampolines are hiding this issue. (https://github.com/InfectedLibraries/Biohazrd/issues/210 and https://github.com/InfectedLibraries/Biohazrd/issues/159 are somewhat related.)

PathogenDavid avatar Aug 26 '21 21:08 PathogenDavid