diff options
author | Fangrui Song <i@maskray.me> | 2021-05-04 17:30:57 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-05-04 17:30:57 -0700 |
commit | 96f3a6307670bc6c79c44bf01be507dd8a1af30e (patch) | |
tree | 1a6fb717f2b9a3127053f4c1eac711ccbef485fc /llvm/tools/llvm-objcopy/CopyConfig.cpp | |
parent | f016c06abb1d20a8a9b4a8b33f123852b69371c8 (diff) | |
download | llvm-96f3a6307670bc6c79c44bf01be507dd8a1af30e.zip llvm-96f3a6307670bc6c79c44bf01be507dd8a1af30e.tar.gz llvm-96f3a6307670bc6c79c44bf01be507dd8a1af30e.tar.bz2 |
[llvm-objcopy] --dump-section: error if '=' is missing or filename is empty
Fix PR45416: the diagnostic when '=' is missing is misleading.
`FileOutputBuffer::create` returns successfully when the filename is empty
(the temporary file is `.tmp%%%%%%%`), but `FileOutputBuffer::commit` will error when
renaming `.tmp%%%%%%%` to the empty name).
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D101697
Diffstat (limited to 'llvm/tools/llvm-objcopy/CopyConfig.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/CopyConfig.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp index 3ecf45d..5669928 100644 --- a/llvm/tools/llvm-objcopy/CopyConfig.cpp +++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp @@ -700,8 +700,14 @@ parseObjcopyOptions(ArrayRef<const char *> ArgsArr, "bad format for --add-section: missing file name"); Config.AddSection.push_back(ArgValue); } - for (auto Arg : InputArgs.filtered(OBJCOPY_dump_section)) - Config.DumpSection.push_back(Arg->getValue()); + for (auto *Arg : InputArgs.filtered(OBJCOPY_dump_section)) { + StringRef Value(Arg->getValue()); + if (Value.split('=').second.empty()) + return createStringError( + errc::invalid_argument, + "bad format for --dump-section, expected section=file"); + Config.DumpSection.push_back(Value); + } Config.StripAll = InputArgs.hasArg(OBJCOPY_strip_all); Config.StripAllGNU = InputArgs.hasArg(OBJCOPY_strip_all_gnu); Config.StripDebug = InputArgs.hasArg(OBJCOPY_strip_debug); |