forked from OSchip/llvm-project
parent
061bec802e
commit
a4a643c6b9
|
@ -360,7 +360,7 @@ static UnresolvedPolicy getUnresolvedSymbolPolicy(opt::InputArgList &Args) {
|
|||
// -noinhibit-exec or -r imply some default values.
|
||||
if (Args.hasArg(OPT_noinhibit_exec))
|
||||
return UnresolvedPolicy::WarnAll;
|
||||
if (Config->Relocatable)
|
||||
if (Args.hasArg(OPT_relocatable))
|
||||
return UnresolvedPolicy::IgnoreAll;
|
||||
|
||||
UnresolvedPolicy ErrorOrWarn =
|
||||
|
@ -421,7 +421,7 @@ static bool isOutputFormatBinary(opt::InputArgList &Args) {
|
|||
}
|
||||
|
||||
static DiscardPolicy getDiscardOption(opt::InputArgList &Args) {
|
||||
if (Config->Relocatable)
|
||||
if (Args.hasArg(OPT_relocatable))
|
||||
return DiscardPolicy::None;
|
||||
auto *Arg =
|
||||
Args.getLastArg(OPT_discard_all, OPT_discard_locals, OPT_discard_none);
|
||||
|
@ -503,6 +503,77 @@ static std::vector<StringRef> getLines(MemoryBufferRef MB) {
|
|||
|
||||
// Initializes Config members by the command line options.
|
||||
void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
||||
Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition);
|
||||
Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
|
||||
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
|
||||
Config->DefineCommon = getArg(Args, OPT_define_common, OPT_no_define_common,
|
||||
!Args.hasArg(OPT_relocatable));
|
||||
Config->Demangle = getArg(Args, OPT_demangle, OPT_no_demangle, true);
|
||||
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
|
||||
Config->Discard = getDiscardOption(Args);
|
||||
Config->DynamicLinker = getDynamicLinkerOption(Args);
|
||||
Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
|
||||
Config->EmitRelocs = Args.hasArg(OPT_emit_relocs);
|
||||
Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
|
||||
Config->Entry = getString(Args, OPT_entry);
|
||||
Config->ExportDynamic =
|
||||
getArg(Args, OPT_export_dynamic, OPT_no_export_dynamic, false);
|
||||
Config->FatalWarnings =
|
||||
getArg(Args, OPT_fatal_warnings, OPT_no_fatal_warnings, false);
|
||||
Config->Fini = getString(Args, OPT_fini, "_fini");
|
||||
Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false);
|
||||
Config->GdbIndex = Args.hasArg(OPT_gdb_index);
|
||||
Config->ICF = Args.hasArg(OPT_icf);
|
||||
Config->Init = getString(Args, OPT_init, "_init");
|
||||
Config->LTOAAPipeline = getString(Args, OPT_lto_aa_pipeline);
|
||||
Config->LTONewPmPasses = getString(Args, OPT_lto_newpm_passes);
|
||||
Config->LTOO = getInteger(Args, OPT_lto_O, 2);
|
||||
Config->LTOPartitions = getInteger(Args, OPT_lto_partitions, 1);
|
||||
Config->MapFile = getString(Args, OPT_Map);
|
||||
Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
|
||||
Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);
|
||||
Config->Nostdlib = Args.hasArg(OPT_nostdlib);
|
||||
Config->OFormatBinary = isOutputFormatBinary(Args);
|
||||
Config->OMagic = Args.hasArg(OPT_omagic);
|
||||
Config->OptRemarksFilename = getString(Args, OPT_opt_remarks_filename);
|
||||
Config->OptRemarksWithHotness = Args.hasArg(OPT_opt_remarks_with_hotness);
|
||||
Config->Optimize = getInteger(Args, OPT_O, 1);
|
||||
Config->OutputFile = getString(Args, OPT_o);
|
||||
Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
|
||||
Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
|
||||
Config->Relocatable = Args.hasArg(OPT_relocatable);
|
||||
Config->SaveTemps = Args.hasArg(OPT_save_temps);
|
||||
Config->SectionStartMap = getSectionStartMap(Args);
|
||||
Config->Shared = Args.hasArg(OPT_shared);
|
||||
Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);
|
||||
Config->SoName = getString(Args, OPT_soname);
|
||||
Config->SortSection = getSortKind(Args);
|
||||
Config->Sysroot = getString(Args, OPT_sysroot);
|
||||
Config->Target1Rel = getArg(Args, OPT_target1_rel, OPT_target1_abs, false);
|
||||
Config->Target2 = getTarget2Option(Args);
|
||||
Config->ThinLTOJobs = getInteger(Args, OPT_thinlto_jobs, -1u);
|
||||
Config->Threads = getArg(Args, OPT_threads, OPT_no_threads, true);
|
||||
Config->Trace = Args.hasArg(OPT_trace);
|
||||
Config->UnresolvedSymbols = getUnresolvedSymbolPolicy(Args);
|
||||
Config->Verbose = Args.hasArg(OPT_verbose);
|
||||
Config->WarnCommon = Args.hasArg(OPT_warn_common);
|
||||
Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
|
||||
Config->ZExecstack = hasZOption(Args, "execstack");
|
||||
Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
|
||||
Config->ZNodelete = hasZOption(Args, "nodelete");
|
||||
Config->ZNow = hasZOption(Args, "now");
|
||||
Config->ZOrigin = hasZOption(Args, "origin");
|
||||
Config->ZRelro = !hasZOption(Args, "norelro");
|
||||
Config->ZStackSize = getZOptionValue(Args, "stack-size", 0);
|
||||
Config->ZWxneeded = hasZOption(Args, "wxneeded");
|
||||
|
||||
if (Config->LTOO > 3)
|
||||
error("invalid optimization level for LTO: " + getString(Args, OPT_lto_O));
|
||||
if (Config->LTOPartitions == 0)
|
||||
error("--lto-partitions: number of threads must be > 0");
|
||||
if (Config->ThinLTOJobs == 0)
|
||||
error("--thinlto-jobs: number of threads must be > 0");
|
||||
|
||||
for (auto *Arg : Args.filtered(OPT_L))
|
||||
Config->SearchPaths.push_back(Arg->getValue());
|
||||
|
||||
|
@ -521,79 +592,6 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
|||
Config->Emulation = S;
|
||||
}
|
||||
|
||||
Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition);
|
||||
Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
|
||||
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
|
||||
Config->Demangle = getArg(Args, OPT_demangle, OPT_no_demangle, true);
|
||||
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
|
||||
Config->EmitRelocs = Args.hasArg(OPT_emit_relocs);
|
||||
Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
|
||||
Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
|
||||
Config->ExportDynamic =
|
||||
getArg(Args, OPT_export_dynamic, OPT_no_export_dynamic, false);
|
||||
Config->FatalWarnings =
|
||||
getArg(Args, OPT_fatal_warnings, OPT_no_fatal_warnings, false);
|
||||
Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false);
|
||||
Config->GdbIndex = Args.hasArg(OPT_gdb_index);
|
||||
Config->ICF = Args.hasArg(OPT_icf);
|
||||
Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
|
||||
Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);
|
||||
Config->Nostdlib = Args.hasArg(OPT_nostdlib);
|
||||
Config->OMagic = Args.hasArg(OPT_omagic);
|
||||
Config->OptRemarksWithHotness = Args.hasArg(OPT_opt_remarks_with_hotness);
|
||||
Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
|
||||
Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
|
||||
Config->Relocatable = Args.hasArg(OPT_relocatable);
|
||||
Config->DefineCommon = getArg(Args, OPT_define_common, OPT_no_define_common,
|
||||
!Config->Relocatable);
|
||||
Config->Discard = getDiscardOption(Args);
|
||||
Config->SaveTemps = Args.hasArg(OPT_save_temps);
|
||||
Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);
|
||||
Config->Shared = Args.hasArg(OPT_shared);
|
||||
Config->Target1Rel = getArg(Args, OPT_target1_rel, OPT_target1_abs, false);
|
||||
Config->Threads = getArg(Args, OPT_threads, OPT_no_threads, true);
|
||||
Config->Trace = Args.hasArg(OPT_trace);
|
||||
Config->Verbose = Args.hasArg(OPT_verbose);
|
||||
Config->WarnCommon = Args.hasArg(OPT_warn_common);
|
||||
Config->Entry = getString(Args, OPT_entry);
|
||||
Config->Fini = getString(Args, OPT_fini, "_fini");
|
||||
Config->Init = getString(Args, OPT_init, "_init");
|
||||
Config->LTOAAPipeline = getString(Args, OPT_lto_aa_pipeline);
|
||||
Config->LTONewPmPasses = getString(Args, OPT_lto_newpm_passes);
|
||||
Config->MapFile = getString(Args, OPT_Map);
|
||||
Config->OptRemarksFilename = getString(Args, OPT_opt_remarks_filename);
|
||||
Config->OutputFile = getString(Args, OPT_o);
|
||||
Config->SoName = getString(Args, OPT_soname);
|
||||
Config->Sysroot = getString(Args, OPT_sysroot);
|
||||
|
||||
Config->Optimize = getInteger(Args, OPT_O, 1);
|
||||
Config->LTOO = getInteger(Args, OPT_lto_O, 2);
|
||||
if (Config->LTOO > 3)
|
||||
error("invalid optimization level for LTO: " + getString(Args, OPT_lto_O));
|
||||
Config->LTOPartitions = getInteger(Args, OPT_lto_partitions, 1);
|
||||
if (Config->LTOPartitions == 0)
|
||||
error("--lto-partitions: number of threads must be > 0");
|
||||
Config->ThinLTOJobs = getInteger(Args, OPT_thinlto_jobs, -1u);
|
||||
if (Config->ThinLTOJobs == 0)
|
||||
error("--thinlto-jobs: number of threads must be > 0");
|
||||
|
||||
Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
|
||||
Config->ZExecstack = hasZOption(Args, "execstack");
|
||||
Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
|
||||
Config->ZNodelete = hasZOption(Args, "nodelete");
|
||||
Config->ZNow = hasZOption(Args, "now");
|
||||
Config->ZOrigin = hasZOption(Args, "origin");
|
||||
Config->ZRelro = !hasZOption(Args, "norelro");
|
||||
Config->ZStackSize = getZOptionValue(Args, "stack-size", 0);
|
||||
Config->ZWxneeded = hasZOption(Args, "wxneeded");
|
||||
|
||||
Config->DynamicLinker = getDynamicLinkerOption(Args);
|
||||
Config->OFormatBinary = isOutputFormatBinary(Args);
|
||||
Config->SectionStartMap = getSectionStartMap(Args);
|
||||
Config->SortSection = getSortKind(Args);
|
||||
Config->Target2 = getTarget2Option(Args);
|
||||
Config->UnresolvedSymbols = getUnresolvedSymbolPolicy(Args);
|
||||
|
||||
if (Args.hasArg(OPT_print_map))
|
||||
Config->MapFile = "-";
|
||||
|
||||
|
|
Loading…
Reference in New Issue