@@ -971,18 +971,26 @@ static GlobalVariable *emit_shard_table(Module &M, Type *T_size, Type *T_psize,
971971    return  tables_gv;
972972}
973973
974+ static  Function *emit_pgcstack_default_func (Module &M, Type *T_ptr) {
975+     auto  FT = FunctionType::get (T_ptr, false );
976+     auto  F = Function::Create (FT, GlobalValue::InternalLinkage, " pgcstack_default_func" 
977+     llvm::IRBuilder<> builder (BasicBlock::Create (M.getContext (), " top" 
978+     builder.CreateRet (Constant::getNullValue (T_ptr));
979+     return  F;
980+ }
981+ 
974982//  See src/processor.h for documentation about this table. Corresponds to jl_image_ptls_t.
975- static  GlobalVariable *emit_ptls_table (Module &M, Type *T_size, Type *T_psize ) {
983+ static  GlobalVariable *emit_ptls_table (Module &M, Type *T_size, Type *T_ptr ) {
976984    std::array<Constant *, 3 > ptls_table{
977-         new  GlobalVariable (M, T_size , false , GlobalValue::ExternalLinkage, Constant::getNullValue (T_size ), " jl_pgcstack_func_slot" 
985+         new  GlobalVariable (M, T_ptr , false , GlobalValue::ExternalLinkage, emit_pgcstack_default_func (M, T_ptr ), " jl_pgcstack_func_slot" 
978986        new  GlobalVariable (M, T_size, false , GlobalValue::ExternalLinkage, Constant::getNullValue (T_size), " jl_pgcstack_key_slot" 
979987        new  GlobalVariable (M, T_size, false , GlobalValue::ExternalLinkage, Constant::getNullValue (T_size), " jl_tls_offset" 
980988    };
981989    for  (auto  &gv : ptls_table) {
982990        cast<GlobalVariable>(gv)->setVisibility (GlobalValue::HiddenVisibility);
983991        cast<GlobalVariable>(gv)->setDSOLocal (true );
984992    }
985-     auto  ptls_table_arr = ConstantArray::get (ArrayType::get (T_psize , ptls_table.size ()), ptls_table);
993+     auto  ptls_table_arr = ConstantArray::get (ArrayType::get (T_ptr , ptls_table.size ()), ptls_table);
986994    auto  ptls_table_gv = new  GlobalVariable (M, ptls_table_arr->getType (), false ,
987995                                            GlobalValue::ExternalLinkage, ptls_table_arr, " jl_ptls_table" 
988996    ptls_table_gv->setVisibility (GlobalValue::HiddenVisibility);
@@ -2181,6 +2189,7 @@ void jl_dump_native_impl(void *native_code,
21812189
21822190        Type *T_size = DL.getIntPtrType (Context);
21832191        Type *T_psize = T_size->getPointerTo ();
2192+         Type *T_ptr = PointerType::get (Context, 0 );
21842193
21852194        auto  FT = FunctionType::get (Type::getInt8Ty (Context)->getPointerTo ()->getPointerTo (), {}, false );
21862195        auto  F = Function::Create (FT, Function::ExternalLinkage, " get_jl_RTLD_DEFAULT_handle_addr" 
@@ -2204,7 +2213,7 @@ void jl_dump_native_impl(void *native_code,
22042213            builder.CreateRet (ConstantInt::get (T_int32, 1 ));
22052214        }
22062215        if  (imaging_mode) {
2207-             auto  specs = jl_get_llvm_clone_targets ();
2216+             auto  specs = jl_get_llvm_clone_targets (jl_options. cpu_target );
22082217            const  uint32_t  base_flags = has_veccall ? JL_TARGET_VEC_CALL : 0 ;
22092218            SmallVector<uint8_t , 0 > data;
22102219            auto  push_i32 = [&] (uint32_t  v) {
@@ -2223,7 +2232,7 @@ void jl_dump_native_impl(void *native_code,
22232232                                        GlobalVariable::InternalLinkage,
22242233                                        value, " jl_dispatch_target_ids" 
22252234            auto  shards = emit_shard_table (metadataM, T_size, T_psize, threads);
2226-             auto  ptls = emit_ptls_table (metadataM, T_size, T_psize );
2235+             auto  ptls = emit_ptls_table (metadataM, T_size, T_ptr );
22272236            auto  header = emit_image_header (metadataM, threads, nfvars, ngvars);
22282237            auto  AT = ArrayType::get (T_size, sizeof (jl_small_typeof) / sizeof (void *));
22292238            auto  jl_small_typeof_copy = new  GlobalVariable (metadataM, AT, false ,
0 commit comments