[PATCH] D39021: [llvm-objcopy] Add support for --only-keep and the special way it interacts with -O binary

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 02:44:30 PDT 2017


jhenderson added a comment.

Diff context is missing.

I noticed that gnu objcopy also keeps the symbol table when using -j, along with all the symbols in the kept section(s). Do you think we should match this behaviour as well?

Reading the documentation, gnu objcopy also allows -j to match using wildcards. Is this a use case you intend to support? (I'm happy for it to be a separate change, if you plan on doing it later).

Why can't we just use the standard BinaryObject class for the -O binary/-j use case?

As discussed in person at the LLVM conference last week, I'd support an alias for -O binary/-j to dump a single section raw to a file, e.g. something like "--copy-section". This can be done later though.



================
Comment at: tools/llvm-objcopy/llvm-objcopy.cpp:78-79
+  if (!OutputFormat.empty() && OutputFormat == "binary") {
+    // Strange exception to support this unique use case in a way that's
+    // compatible with what GNU objcopy does
+    if (!OnlySection.empty()) {
----------------
Rather than call this "Strange exception", I think it might be more helpful to explain what this behaviour actually is (i.e. copies just the one section). Also missing a full stop!


================
Comment at: tools/llvm-objcopy/llvm-objcopy.cpp:82
+      if (OnlySection.size() != 1)
+        error("-O binary and -j can only be used togethor with a single -j");
+      Obj = llvm::make_unique<SectionDump<ELF64LE>>(ObjFile, OnlySection[0]);
----------------
togethor -> together


Repository:
  rL LLVM

https://reviews.llvm.org/D39021





More information about the llvm-commits mailing list