@@ -57,29 +57,44 @@ void tools::uefi::Linker::ConstructJob(Compilation &C, const JobAction &JA,
5757 assert ((Output.isFilename () || Output.isNothing ()) && " invalid output" );
5858 if (Output.isFilename ())
5959 CmdArgs.push_back (
60- Args.MakeArgString (std::string (" - out:" ) + Output.getFilename ()));
60+ Args.MakeArgString (std::string (" / out:" ) + Output.getFilename ()));
6161
62- CmdArgs.push_back (" -nologo" );
63-
64- // TODO: Other UEFI binary subsystems that are currently unsupported:
65- // efi_boot_service_driver, efi_rom, efi_runtime_driver.
66- CmdArgs.push_back (" -subsystem:efi_application" );
62+ CmdArgs.push_back (" /nologo" );
6763
6864 // Default entry function name according to the TianoCore reference
69- // implementation is EfiMain.
70- // TODO: Provide a flag to override the entry function name.
71- CmdArgs.push_back (" -entry:EfiMain" );
65+ // implementation is EfiMain. -Wl,/subsystem:... or -Wl,/entry:... can
66+ // override these since they will be added later in AddLinkerInputs.
67+ CmdArgs.push_back (" /subsystem:efi_application" );
68+ CmdArgs.push_back (" /entry:EfiMain" );
7269
7370 // "Terminal Service Aware" flag is not needed for UEFI applications.
74- CmdArgs.push_back (" - tsaware:no" );
71+ CmdArgs.push_back (" / tsaware:no" );
7572
7673 if (Args.hasArg (options::OPT_g_Group, options::OPT__SLASH_Z7))
77- CmdArgs.push_back (" - debug" );
74+ CmdArgs.push_back (" / debug" );
7875
7976 Args.AddAllArgValues (CmdArgs, options::OPT__SLASH_link);
8077
8178 AddLinkerInputs (TC, Inputs, Args, CmdArgs, JA);
8279
80+ // Sample these options first so they are claimed even under -nostdlib et al.
81+ bool NoLibc = Args.hasArg (options::OPT_nolibc);
82+ if (!Args.hasArg (options::OPT_nostdlib, options::OPT_nodefaultlibs,
83+ options::OPT_r)) {
84+ addSanitizerRuntimes (TC, Args, CmdArgs);
85+
86+ addXRayRuntime (TC, Args, CmdArgs);
87+
88+ TC.addProfileRTLibs (Args, CmdArgs);
89+
90+ // TODO: When compiler-rt/lib/builtins is ready, enable this call:
91+ // AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
92+
93+ if (!NoLibc) {
94+ // TODO: When there is a libc ready, add it here.
95+ }
96+ }
97+
8398 // This should ideally be handled by ToolChain::GetLinkerPath but we need
8499 // to special case some linker paths. In the case of lld, we need to
85100 // translate 'lld' into 'lld-link'.
0 commit comments