summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
diff options
context:
space:
mode:
authorJake Ehrlich <jakehehrlich@google.com>2017-10-10 18:28:15 +0000
committerJake Ehrlich <jakehehrlich@google.com>2017-10-10 18:28:15 +0000
commit77ec1ffe5c8046e24e3cd2a5d27f7497badea741 (patch)
tree7db2f372fb59d4931aa9a80edf6d123bdf679f7d /llvm/tools/llvm-objcopy/llvm-objcopy.cpp
parent577c52b9c7c8ab04efeeccbf81559f1aaa32f1bd (diff)
downloadbcm5719-llvm-77ec1ffe5c8046e24e3cd2a5d27f7497badea741.tar.gz
bcm5719-llvm-77ec1ffe5c8046e24e3cd2a5d27f7497badea741.zip
temporary
llvm-svn: 315344
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/llvm-objcopy.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 9b233951b8d..775c5ae42b6 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -56,17 +56,24 @@ 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"));
+// TODO: make this a cl::list to support removing multiple sections
+cl::opt<std::string> ToRemove("remove-section",
+ cl::desc("Remove a specific section"));
+cl::alias ToRemoveA("R", cl::desc("Alias for remove-section"), cl::aliasopt(ToRemove));
void CopyBinary(const ELFObjectFile<ELF64LE> &ObjFile) {
std::unique_ptr<FileOutputBuffer> Buffer;
std::unique_ptr<Object<ELF64LE>> Obj;
if (!OutputFormat.empty() && OutputFormat != "binary")
error("invalid output format '" + OutputFormat + "'");
-
if (!OutputFormat.empty() && OutputFormat == "binary")
Obj = llvm::make_unique<BinaryObject<ELF64LE>>(ObjFile);
else
Obj = llvm::make_unique<ELFObject<ELF64LE>>(ObjFile);
+ if (!ToRemove.empty()) {
+ Obj->removeSections(
+ [&](const SectionBase &Sec) { return ToRemove == Sec.Name; });
+ }
Obj->finalize();
ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
FileOutputBuffer::create(OutputFilename, Obj->totalSize(),
OpenPOWER on IntegriCloud