summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-objcopy/CopyConfig.cpp14
-rw-r--r--llvm/tools/llvm-objcopy/ObjcopyOpts.td4
2 files changed, 16 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index d814df10525..2c3551ba026 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -247,8 +247,18 @@ DriverConfig parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
CopyConfig Config;
Config.InputFilename = Positional[0];
Config.OutputFilename = Positional[Positional.size() == 1 ? 0 : 1];
- Config.InputFormat = InputArgs.getLastArgValue(OBJCOPY_input_target);
- Config.OutputFormat = InputArgs.getLastArgValue(OBJCOPY_output_target);
+ if (InputArgs.hasArg(OBJCOPY_target) &&
+ (InputArgs.hasArg(OBJCOPY_input_target) ||
+ InputArgs.hasArg(OBJCOPY_output_target)))
+ error("--target cannot be used with --input-target or --output-target");
+
+ if (InputArgs.hasArg(OBJCOPY_target)) {
+ Config.InputFormat = InputArgs.getLastArgValue(OBJCOPY_target);
+ Config.OutputFormat = InputArgs.getLastArgValue(OBJCOPY_target);
+ } else {
+ Config.InputFormat = InputArgs.getLastArgValue(OBJCOPY_input_target);
+ Config.OutputFormat = InputArgs.getLastArgValue(OBJCOPY_output_target);
+ }
if (Config.InputFormat == "binary") {
auto BinaryArch = InputArgs.getLastArgValue(OBJCOPY_binary_architecture);
if (BinaryArch.empty())
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
index 18b270b7758..f6c8a959e8b 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td
+++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
@@ -10,6 +10,10 @@ defm binary_architecture : Eq<"binary-architecture">,
HelpText<"Used when transforming an architecture-less format (such as binary) to another format">;
def B : JoinedOrSeparate<["-"], "B">,
Alias<binary_architecture>;
+defm target : Eq<"target">,
+ HelpText<"Format of the input and output file">,
+ Values<"binary">;
+def F : JoinedOrSeparate<[ "-" ], "F">, Alias<target>;
defm input_target : Eq<"input-target">,
HelpText<"Format of the input file">,
Values<"binary">;
OpenPOWER on IntegriCloud