Biohazrd
Biohazrd copied to clipboard
Add Linux support to `InlineExportHelper`
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.
This would be useful here: https://github.com/InfectedLibraries/Biohazrd/issues/211
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.
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.)