@@ -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
@@ -1778,6 +1780,7 @@ void jl_dump_native_impl(void *native_code,
1778
1780
if (jl_small_typeof_copy) {
1779
1781
jl_small_typeof_copy->setVisibility (GlobalValue::HiddenVisibility);
1780
1782
jl_small_typeof_copy->setDSOLocal (true );
1783
+ jl_small_typeof_copy->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DefaultStorageClass);
1781
1784
}
1782
1785
}
1783
1786
@@ -1811,19 +1814,18 @@ void jl_dump_native_impl(void *native_code,
1811
1814
// reflect the address of the jl_RTLD_DEFAULT_handle variable
1812
1815
// back to the caller, so that we can check for consistency issues
1813
1816
GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var (&metadataM);
1814
- if (TheTriple.isOSBinFormatCOFF ()) {
1815
- jlRTLD_DEFAULT_var->setDLLStorageClass (GlobalValue::DLLImportStorageClass);
1816
- }
1817
- addComdat (new GlobalVariable (metadataM,
1818
- jlRTLD_DEFAULT_var->getType (),
1819
- true ,
1820
- GlobalVariable::ExternalLinkage,
1821
- jlRTLD_DEFAULT_var,
1822
- " jl_RTLD_DEFAULT_handle_pointer" ), TheTriple);
1823
1817
1824
1818
Type *T_size = DL.getIntPtrType (Context);
1825
1819
Type *T_psize = T_size->getPointerTo ();
1826
1820
1821
+ auto FT = FunctionType::get (Type::getInt8Ty (Context)->getPointerTo ()->getPointerTo (), {}, false );
1822
+ auto F = Function::Create (FT, Function::ExternalLinkage, " get_jl_RTLD_DEFAULT_handle_addr" , metadataM);
1823
+ llvm::IRBuilder<> builder (BasicBlock::Create (Context, " top" , F));
1824
+ builder.CreateRet (jlRTLD_DEFAULT_var);
1825
+ F->setLinkage (GlobalValue::ExternalLinkage);
1826
+ if (TheTriple.isOSBinFormatCOFF ())
1827
+ F->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DLLExportStorageClass);
1828
+
1827
1829
if (TheTriple.isOSWindows ()) {
1828
1830
// Windows expect that the function `_DllMainStartup` is present in an dll.
1829
1831
// Normal compilers use something like Zig's crtdll.c instead we provide a
0 commit comments