@@ -1242,6 +1242,8 @@ static void materializePreserved(Module &M, Partition &partition) {
1242
1242
GV.setInitializer (nullptr );
1243
1243
GV.setLinkage (GlobalValue::ExternalLinkage);
1244
1244
GV.setVisibility (GlobalValue::HiddenVisibility);
1245
+ if (GV.getDLLStorageClass () != GlobalValue::DLLStorageClassTypes::DefaultStorageClass)
1246
+ continue ; // Don't mess with exported or imported globals
1245
1247
GV.setDSOLocal (true );
1246
1248
}
1247
1249
@@ -1773,6 +1775,7 @@ void jl_dump_native_impl(void *native_code,
1773
1775
if (jl_small_typeof_copy) {
1774
1776
jl_small_typeof_copy->setVisibility (GlobalValue::HiddenVisibility);
1775
1777
jl_small_typeof_copy->setDSOLocal (true );
1778
+ jl_small_typeof_copy->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DefaultStorageClass);
1776
1779
}
1777
1780
}
1778
1781
@@ -1804,16 +1807,18 @@ void jl_dump_native_impl(void *native_code,
1804
1807
// reflect the address of the jl_RTLD_DEFAULT_handle variable
1805
1808
// back to the caller, so that we can check for consistency issues
1806
1809
GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var (&metadataM);
1807
- addComdat (new GlobalVariable (metadataM,
1808
- jlRTLD_DEFAULT_var->getType (),
1809
- true ,
1810
- GlobalVariable::ExternalLinkage,
1811
- jlRTLD_DEFAULT_var,
1812
- " jl_RTLD_DEFAULT_handle_pointer" ), TheTriple);
1813
1810
1814
1811
Type *T_size = DL.getIntPtrType (Context);
1815
1812
Type *T_psize = T_size->getPointerTo ();
1816
1813
1814
+ auto FT = FunctionType::get (Type::getInt8Ty (Context)->getPointerTo ()->getPointerTo (), {}, false );
1815
+ auto F = Function::Create (FT, Function::ExternalLinkage, " get_jl_RTLD_DEFAULT_handle_addr" , metadataM);
1816
+ llvm::IRBuilder<> builder (BasicBlock::Create (Context, " top" , F));
1817
+ builder.CreateRet (jlRTLD_DEFAULT_var);
1818
+ F->setLinkage (GlobalValue::ExternalLinkage);
1819
+ if (TheTriple.isOSBinFormatCOFF ())
1820
+ F->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DLLExportStorageClass);
1821
+
1817
1822
if (TheTriple.isOSWindows ()) {
1818
1823
// Windows expect that the function `_DllMainStartup` is present in an dll.
1819
1824
// Normal compilers use something like Zig's crtdll.c instead we provide a
0 commit comments