@@ -668,6 +668,11 @@ Expected<DriverConfig> parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
668
668
669
669
Config.PreserveDates = InputArgs.hasArg (OBJCOPY_preserve_dates);
670
670
671
+ if (Config.PreserveDates &&
672
+ (Config.OutputFilename == " -" || Config.InputFilename == " -" ))
673
+ return createStringError (errc::invalid_argument,
674
+ " --preserve-dates requires a file" );
675
+
671
676
for (auto Arg : InputArgs)
672
677
if (Arg->getOption ().matches (OBJCOPY_set_start)) {
673
678
auto EAddr = getAsInteger<uint64_t >(Arg->getValue ());
@@ -736,7 +741,7 @@ Expected<DriverConfig> parseStripOptions(ArrayRef<const char *> ArgsArr) {
736
741
exit (0 );
737
742
}
738
743
739
- SmallVector<const char * , 2 > Positional;
744
+ SmallVector<StringRef , 2 > Positional;
740
745
for (auto Arg : InputArgs.filtered (STRIP_UNKNOWN))
741
746
return createStringError (errc::invalid_argument, " unknown argument '%s'" ,
742
747
Arg->getAsString (InputArgs).c_str ());
@@ -801,13 +806,18 @@ Expected<DriverConfig> parseStripOptions(ArrayRef<const char *> ArgsArr) {
801
806
InputArgs.getLastArgValue (STRIP_output, Positional[0 ]);
802
807
DC.CopyConfigs .push_back (std::move (Config));
803
808
} else {
804
- for (const char * Filename : Positional) {
809
+ for (StringRef Filename : Positional) {
805
810
Config.InputFilename = Filename;
806
811
Config.OutputFilename = Filename;
807
812
DC.CopyConfigs .push_back (Config);
808
813
}
809
814
}
810
815
816
+ if (Config.PreserveDates && (is_contained (Positional, " -" ) ||
817
+ InputArgs.getLastArgValue (STRIP_output) == " -" ))
818
+ return createStringError (errc::invalid_argument,
819
+ " --preserve-dates requires a file" );
820
+
811
821
return std::move (DC);
812
822
}
813
823
0 commit comments