llvm-project/llvm/tools/llvm-objcopy
Jordan Rupprecht b2702d6a45 [llvm-objcopy] Fix crash when writing empty binary output
Summary: When using llvm-objcopy -O binary and the resulting file will be empty (e.g. removing the only section that would be written, or using --only-keep with a section that doesn't exist/isn't SHF_ALLOC), we crash because FileOutputBuffer expects Size > 0. Add a regression test, and change Buffer to open/truncate the output file in this case.

Reviewers: alexshap, jhenderson, jakehehrlich, espindola

Reviewed By: alexshap, jhenderson

Subscribers: jfb, llvm-commits, emaste, arichardson

Differential Revision: https://reviews.llvm.org/D56806

llvm-svn: 352371
2019-01-28 15:02:40 +00:00
..
COFF [llvm-objcopy] [COFF] Error out on use of unhandled options 2019-01-23 11:54:55 +00:00
ELF [llvm-objcopy] Return Error from Buffer::allocate(), [ELF]Writer::finalize(), and [ELF]Writer::commit() 2019-01-22 23:49:16 +00:00
Buffer.cpp [llvm-objcopy] Fix crash when writing empty binary output 2019-01-28 15:02:40 +00:00
Buffer.h [llvm-objcopy] Fix crash when writing empty binary output 2019-01-28 15:02:40 +00:00
CMakeLists.txt [llvm-objcopy] [COFF] Add support for removing symbols 2019-01-10 21:28:24 +00:00
CopyConfig.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CopyConfig.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ObjcopyOpts.td [llvm-objcopy] Add support for -g as an alias for --strip-debug 2019-01-25 09:57:20 +00:00
StripOpts.td [llvm-objcopy] Hook up the -V alias to --version, output "GNU strip" 2018-11-28 06:51:50 +00:00
llvm-objcopy.cpp [llvm-objcopy] Return Error from Buffer::allocate(), [ELF]Writer::finalize(), and [ELF]Writer::commit() 2019-01-22 23:49:16 +00:00
llvm-objcopy.h [llvm-objcopy] Return Error from Buffer::allocate(), [ELF]Writer::finalize(), and [ELF]Writer::commit() 2019-01-22 23:49:16 +00:00