hanchenye-llvm-project/llvm/tools/llvm-objcopy
Jordan Rupprecht 7481540fd9 [llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.
The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out).

Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression.

llvm-svn: 340996
2018-08-29 23:21:56 +00:00
..
CMakeLists.txt [tools] Introduce llvm-strip 2018-05-07 19:32:09 +00:00
LLVMBuild.txt Recommit "[llvm-objcopy] Switch over to using TableGen for parsing arguments" 2018-04-24 05:43:32 +00:00
ObjcopyOpts.td [llvm-objcopy] Implement -G/--keep-global-symbol(s). 2018-08-17 22:34:48 +00:00
Object.cpp [llvm-objcopy] Add support for -I binary -B <arch>. 2018-08-17 18:51:11 +00:00
Object.h [llvm-objcopy] Add support for -I binary -B <arch>. 2018-08-17 18:51:11 +00:00
StripOpts.td [llvm-strip] Add support for -p/--preserve-dates 2018-08-16 18:29:40 +00:00
llvm-objcopy.cpp [llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place. 2018-08-29 23:21:56 +00:00
llvm-objcopy.h [NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy. 2018-07-18 00:10:51 +00:00