diff options
author | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-11 02:42:29 +0000 |
---|---|---|
committer | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-11 02:42:29 +0000 |
commit | d9a283463a2a3688d355a7fd0bdb9ae2b13d6baf (patch) | |
tree | 11278d0e196b1ec9491870f4023a77da7653bb4b /llvm/tools/llvm-objcopy/llvm-objcopy.cpp | |
parent | 183aa2731e08ed8c46eb82386d8bcbf33fa88762 (diff) | |
download | bcm5719-llvm-d9a283463a2a3688d355a7fd0bdb9ae2b13d6baf.tar.gz bcm5719-llvm-d9a283463a2a3688d355a7fd0bdb9ae2b13d6baf.zip |
Revert "[llvm-objcopy] Add support for --strip-sections to remove all section headers leaving only program headers and loadable segment data"
This reverts commit rL315412
llvm-svn: 315417
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 7f55a434b33..d76735482d6 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -56,14 +56,11 @@ cl::opt<std::string> OutputFilename(cl::Positional, cl::desc("<output>"), cl::opt<std::string> OutputFormat("O", cl::desc("set output format to one of the following:" "\n\tbinary")); + cl::list<std::string> ToRemove("remove-section", cl::desc("Remove a specific section")); cl::alias ToRemoveA("R", cl::desc("Alias for remove-section"), cl::aliasopt(ToRemove)); -cl::opt<bool> StripSections("strip-sections", - cl::desc("Remove all section headers")); - -typedef std::function<bool(const SectionBase &Sec)> SectionPred; void CopyBinary(const ELFObjectFile<ELF64LE> &ObjFile) { std::unique_ptr<FileOutputBuffer> Buffer; @@ -74,25 +71,12 @@ void CopyBinary(const ELFObjectFile<ELF64LE> &ObjFile) { Obj = llvm::make_unique<BinaryObject<ELF64LE>>(ObjFile); else Obj = llvm::make_unique<ELFObject<ELF64LE>>(ObjFile); - - SectionPred RemovePred = [](const SectionBase &) { return false; }; - if (!ToRemove.empty()) { - RemovePred = [&](const SectionBase &Sec) { + Obj->removeSections([&](const SectionBase &Sec) { return std::find(std::begin(ToRemove), std::end(ToRemove), Sec.Name) != std::end(ToRemove); - }; + }); } - - if (StripSections) { - RemovePred = [RemovePred](const SectionBase &Sec) { - return RemovePred(Sec) || (Sec.Flags & SHF_ALLOC) == 0; - }; - Obj->WriteSectionHeaders = false; - } - - Obj->removeSections(RemovePred); - Obj->finalize(); ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr = FileOutputBuffer::create(OutputFilename, Obj->totalSize(), |