@@ -595,7 +595,17 @@ void LinkerDriver::setMachine(MachineTypes machine) {
595595 assert (machine != IMAGE_FILE_MACHINE_UNKNOWN);
596596
597597 ctx.config .machine = machine;
598- ctx.symtab .machine = machine;
598+
599+ if (machine != ARM64X) {
600+ ctx.symtab .machine = machine;
601+ if (machine == ARM64EC)
602+ ctx.symtabEC = &ctx.symtab ;
603+ } else {
604+ ctx.symtab .machine = ARM64;
605+ ctx.hybridSymtab .emplace (ctx, ARM64EC);
606+ ctx.symtabEC = &*ctx.hybridSymtab ;
607+ }
608+
599609 addWinSysRootLibSearchPaths ();
600610}
601611
@@ -2518,54 +2528,56 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25182528 if (config->imageBase == uint64_t (-1 ))
25192529 config->imageBase = getDefaultImageBase ();
25202530
2521- ctx.symtab .addSynthetic (mangle (" __ImageBase" ), nullptr );
2522- if (config->machine == I386) {
2523- ctx.symtab .addAbsolute (" ___safe_se_handler_table" , 0 );
2524- ctx.symtab .addAbsolute (" ___safe_se_handler_count" , 0 );
2525- }
2526-
2527- ctx.symtab .addAbsolute (mangle (" __guard_fids_count" ), 0 );
2528- ctx.symtab .addAbsolute (mangle (" __guard_fids_table" ), 0 );
2529- ctx.symtab .addAbsolute (mangle (" __guard_flags" ), 0 );
2530- ctx.symtab .addAbsolute (mangle (" __guard_iat_count" ), 0 );
2531- ctx.symtab .addAbsolute (mangle (" __guard_iat_table" ), 0 );
2532- ctx.symtab .addAbsolute (mangle (" __guard_longjmp_count" ), 0 );
2533- ctx.symtab .addAbsolute (mangle (" __guard_longjmp_table" ), 0 );
2534- // Needed for MSVC 2017 15.5 CRT.
2535- ctx.symtab .addAbsolute (mangle (" __enclave_config" ), 0 );
2536- // Needed for MSVC 2019 16.8 CRT.
2537- ctx.symtab .addAbsolute (mangle (" __guard_eh_cont_count" ), 0 );
2538- ctx.symtab .addAbsolute (mangle (" __guard_eh_cont_table" ), 0 );
2539-
2540- if (isArm64EC (config->machine )) {
2541- ctx.symtab .addAbsolute (" __arm64x_extra_rfe_table" , 0 );
2542- ctx.symtab .addAbsolute (" __arm64x_extra_rfe_table_size" , 0 );
2543- ctx.symtab .addAbsolute (" __arm64x_redirection_metadata" , 0 );
2544- ctx.symtab .addAbsolute (" __arm64x_redirection_metadata_count" , 0 );
2545- ctx.symtab .addAbsolute (" __hybrid_auxiliary_delayload_iat_copy" , 0 );
2546- ctx.symtab .addAbsolute (" __hybrid_auxiliary_delayload_iat" , 0 );
2547- ctx.symtab .addAbsolute (" __hybrid_auxiliary_iat" , 0 );
2548- ctx.symtab .addAbsolute (" __hybrid_auxiliary_iat_copy" , 0 );
2549- ctx.symtab .addAbsolute (" __hybrid_code_map" , 0 );
2550- ctx.symtab .addAbsolute (" __hybrid_code_map_count" , 0 );
2551- ctx.symtab .addAbsolute (" __hybrid_image_info_bitfield" , 0 );
2552- ctx.symtab .addAbsolute (" __x64_code_ranges_to_entry_points" , 0 );
2553- ctx.symtab .addAbsolute (" __x64_code_ranges_to_entry_points_count" , 0 );
2554- ctx.symtab .addSynthetic (" __guard_check_icall_a64n_fptr" , nullptr );
2555- ctx.symtab .addSynthetic (" __arm64x_native_entrypoint" , nullptr );
2556- }
2557-
2558- if (config->pseudoRelocs ) {
2559- ctx.symtab .addAbsolute (mangle (" __RUNTIME_PSEUDO_RELOC_LIST__" ), 0 );
2560- ctx.symtab .addAbsolute (mangle (" __RUNTIME_PSEUDO_RELOC_LIST_END__" ), 0 );
2561- }
2562- if (config->mingw ) {
2563- ctx.symtab .addAbsolute (mangle (" __CTOR_LIST__" ), 0 );
2564- ctx.symtab .addAbsolute (mangle (" __DTOR_LIST__" ), 0 );
2565- }
2566- if (config->debug || config->buildIDHash != BuildIDHash::None)
2567- if (ctx.symtab .findUnderscore (" __buildid" ))
2568- ctx.symtab .addUndefined (mangle (" __buildid" ));
2531+ ctx.forEachSymtab ([&](SymbolTable &symtab) {
2532+ symtab.addSynthetic (mangle (" __ImageBase" ), nullptr );
2533+ if (symtab.machine == I386) {
2534+ symtab.addAbsolute (" ___safe_se_handler_table" , 0 );
2535+ symtab.addAbsolute (" ___safe_se_handler_count" , 0 );
2536+ }
2537+
2538+ symtab.addAbsolute (mangle (" __guard_fids_count" ), 0 );
2539+ symtab.addAbsolute (mangle (" __guard_fids_table" ), 0 );
2540+ symtab.addAbsolute (mangle (" __guard_flags" ), 0 );
2541+ symtab.addAbsolute (mangle (" __guard_iat_count" ), 0 );
2542+ symtab.addAbsolute (mangle (" __guard_iat_table" ), 0 );
2543+ symtab.addAbsolute (mangle (" __guard_longjmp_count" ), 0 );
2544+ symtab.addAbsolute (mangle (" __guard_longjmp_table" ), 0 );
2545+ // Needed for MSVC 2017 15.5 CRT.
2546+ symtab.addAbsolute (mangle (" __enclave_config" ), 0 );
2547+ // Needed for MSVC 2019 16.8 CRT.
2548+ symtab.addAbsolute (mangle (" __guard_eh_cont_count" ), 0 );
2549+ symtab.addAbsolute (mangle (" __guard_eh_cont_table" ), 0 );
2550+
2551+ if (isArm64EC (ctx.config .machine )) {
2552+ symtab.addAbsolute (" __arm64x_extra_rfe_table" , 0 );
2553+ symtab.addAbsolute (" __arm64x_extra_rfe_table_size" , 0 );
2554+ symtab.addAbsolute (" __arm64x_redirection_metadata" , 0 );
2555+ symtab.addAbsolute (" __arm64x_redirection_metadata_count" , 0 );
2556+ symtab.addAbsolute (" __hybrid_auxiliary_delayload_iat_copy" , 0 );
2557+ symtab.addAbsolute (" __hybrid_auxiliary_delayload_iat" , 0 );
2558+ symtab.addAbsolute (" __hybrid_auxiliary_iat" , 0 );
2559+ symtab.addAbsolute (" __hybrid_auxiliary_iat_copy" , 0 );
2560+ symtab.addAbsolute (" __hybrid_code_map" , 0 );
2561+ symtab.addAbsolute (" __hybrid_code_map_count" , 0 );
2562+ symtab.addAbsolute (" __hybrid_image_info_bitfield" , 0 );
2563+ symtab.addAbsolute (" __x64_code_ranges_to_entry_points" , 0 );
2564+ symtab.addAbsolute (" __x64_code_ranges_to_entry_points_count" , 0 );
2565+ symtab.addSynthetic (" __guard_check_icall_a64n_fptr" , nullptr );
2566+ symtab.addSynthetic (" __arm64x_native_entrypoint" , nullptr );
2567+ }
2568+
2569+ if (config->pseudoRelocs ) {
2570+ symtab.addAbsolute (mangle (" __RUNTIME_PSEUDO_RELOC_LIST__" ), 0 );
2571+ symtab.addAbsolute (mangle (" __RUNTIME_PSEUDO_RELOC_LIST_END__" ), 0 );
2572+ }
2573+ if (config->mingw ) {
2574+ symtab.addAbsolute (mangle (" __CTOR_LIST__" ), 0 );
2575+ symtab.addAbsolute (mangle (" __DTOR_LIST__" ), 0 );
2576+ }
2577+ if (config->debug || config->buildIDHash != BuildIDHash::None)
2578+ if (symtab.findUnderscore (" __buildid" ))
2579+ symtab.addUndefined (mangle (" __buildid" ));
2580+ });
25692581
25702582 // This code may add new undefined symbols to the link, which may enqueue more
25712583 // symbol resolution tasks, so we need to continue executing tasks until we
@@ -2808,7 +2820,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
28082820 if (auto *arg = args.getLastArg (OPT_print_symbol_order))
28092821 config->printSymbolOrder = arg->getValue ();
28102822
2811- ctx.symtab .initializeECThunks ();
2823+ if (ctx.symtabEC )
2824+ ctx.symtabEC ->initializeECThunks ();
28122825
28132826 // Identify unreferenced COMDAT sections.
28142827 if (config->doGC ) {
0 commit comments