diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -398,7 +398,7 @@ // Parses LC_LINKER_OPTION contents, which can add additional command line // flags. void macho::parseLCLinkerOption(InputFile *f, unsigned argc, StringRef data) { - SmallVector argv; + SmallVector argv; size_t offset = 0; for (unsigned i = 0; i < argc && offset < data.size(); ++i) { argv.push_back(data.data() + offset); @@ -407,18 +407,10 @@ if (argv.size() != argc || offset > data.size()) fatal(toString(f) + ": invalid LC_LINKER_OPTION"); - MachOOptTable table; - unsigned missingIndex, missingCount; - InputArgList args = table.ParseArgs(argv, missingIndex, missingCount); - if (missingCount) - fatal(Twine(args.getArgString(missingIndex)) + ": missing argument"); - for (const Arg *arg : args.filtered(OPT_UNKNOWN)) - error("unknown argument: " + arg->getAsString(args)); - - for (const Arg *arg : args) { - switch (arg->getOption().getID()) { - case OPT_l: { - StringRef name = arg->getValue(); + for (unsigned i = 0; i < argv.size(); ++i) { + StringRef arg = argv[i]; + if (arg.startswith("-l")) { + StringRef name = arg.drop_front(2); ForceLoad forceLoadArchive = config->forceLoadSwift && name.startswith("swift") ? ForceLoad::Yes : ForceLoad::No; @@ -426,13 +418,15 @@ /*isReexport=*/false, /*isExplicit=*/false, forceLoadArchive); break; } - case OPT_framework: - addFramework(arg->getValue(), /*isNeeded=*/false, /*isWeak=*/false, + + if (arg == "-framework") { + StringRef name = argv[++i]; + addFramework(name, /*isNeeded=*/false, /*isWeak=*/false, /*isReexport=*/false, /*isExplicit=*/false, ForceLoad::No); break; - default: - error(arg->getSpelling() + " is not allowed in LC_LINKER_OPTION"); } + + error(arg + " is not allowed in LC_LINKER_OPTION"); } }