diff options
Diffstat (limited to 'lld/lib')
| -rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 39643379d78..5e21a3d6624 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -698,6 +698,19 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx, return false; } + // Handle /machine before parsing all the other options, as the target machine + // type affects how to handle other options. For example, x86 needs the + // leading underscore to mangle symbols, while x64 doesn't need it. + if (llvm::opt::Arg *inputArg = parsedArgs->getLastArg(OPT_machine)) { + StringRef arg = inputArg->getValue(); + llvm::COFF::MachineTypes type = stringToMachineType(arg); + if (type == llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN) { + diagnostics << "error: unknown machine type: " << arg << "\n"; + return false; + } + ctx.setMachineType(type); + } + // Handle /nodefaultlib:<lib>. The same option without argument is handled in // the following for loop. for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_nodefaultlib), @@ -786,17 +799,6 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx, break; } - case OPT_machine: { - StringRef arg = inputArg->getValue(); - llvm::COFF::MachineTypes type = stringToMachineType(arg); - if (type == llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN) { - diagnostics << "error: unknown machine type: " << arg << "\n"; - return false; - } - ctx.setMachineType(type); - break; - } - case OPT_version: { uint32_t major, minor; if (!parseVersion(inputArg->getValue(), major, minor)) |

