@@ -1166,6 +1166,8 @@ static void materializePreserved(Module &M, Partition &partition) {
1166
1166
GV.setInitializer (nullptr );
1167
1167
GV.setLinkage (GlobalValue::ExternalLinkage);
1168
1168
GV.setVisibility (GlobalValue::HiddenVisibility);
1169
+ if (GV.getDLLStorageClass () != GlobalValue::DLLStorageClassTypes::DefaultStorageClass)
1170
+ continue ; // Don't mess with exported or imported globals
1169
1171
GV.setDSOLocal (true );
1170
1172
}
1171
1173
@@ -1645,6 +1647,7 @@ void jl_dump_native_impl(void *native_code,
1645
1647
if (jl_small_typeof_copy) {
1646
1648
jl_small_typeof_copy->setVisibility (GlobalValue::HiddenVisibility);
1647
1649
jl_small_typeof_copy->setDSOLocal (true );
1650
+ jl_small_typeof_copy->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DefaultStorageClass);
1648
1651
}
1649
1652
}
1650
1653
@@ -1673,16 +1676,17 @@ void jl_dump_native_impl(void *native_code,
1673
1676
// reflect the address of the jl_RTLD_DEFAULT_handle variable
1674
1677
// back to the caller, so that we can check for consistency issues
1675
1678
GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var (&metadataM);
1676
- addComdat (new GlobalVariable (metadataM,
1677
- jlRTLD_DEFAULT_var->getType (),
1678
- true ,
1679
- GlobalVariable::ExternalLinkage,
1680
- jlRTLD_DEFAULT_var,
1681
- " jl_RTLD_DEFAULT_handle_pointer" ), TheTriple);
1682
-
1683
1679
Type *T_size = DL.getIntPtrType (Context);
1684
1680
Type *T_psize = T_size->getPointerTo ();
1685
1681
1682
+ auto FT = FunctionType::get (Type::getInt8Ty (Context)->getPointerTo ()->getPointerTo (), {}, false );
1683
+ auto F = Function::Create (FT, Function::ExternalLinkage, " get_jl_RTLD_DEFAULT_handle_addr" , metadataM);
1684
+ llvm::IRBuilder<> builder (BasicBlock::Create (Context, " top" , F));
1685
+ builder.CreateRet (jlRTLD_DEFAULT_var);
1686
+ F->setLinkage (GlobalValue::ExternalLinkage);
1687
+ if (TheTriple.isOSBinFormatCOFF ())
1688
+ F->setDLLStorageClass (GlobalValue::DLLStorageClassTypes::DLLExportStorageClass);
1689
+
1686
1690
if (TheTriple.isOSWindows ()) {
1687
1691
// Windows expect that the function `_DllMainStartup` is present in an dll.
1688
1692
// Normal compilers use something like Zig's crtdll.c instead we provide a
0 commit comments