[PATCH] D57045: [llvm-objcopy] [COFF] Error out on use of unhandled options

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 22 23:45:38 PST 2019


mstorsjo added a comment.

In D57045#1367024 <https://reviews.llvm.org/D57045#1367024>, @rupprecht wrote:

> This doesn't seem like the best solution long-term, but probably makes testing llvm-objcopy on COFF much easier (expose missing functionality more loudly).
>
> Maybe we could add something to the tablegen saying which object type each flag is supported for, and if that flag is set & we detect the input is not that object type, error?


That's probably a better long term solution, but also not quite trivial to do. The detection of which format is being handled happens long after the options are parsed:

  static void executeObjcopyOnBinary(const CopyConfig &Config, object::Binary &In,
                                     Buffer &Out) {
    if (auto *ELFBinary = dyn_cast<object::ELFObjectFileBase>(&In))
      return elf::executeObjcopyOnBinary(Config, *ELFBinary, Out);
    else if (auto *COFFBinary = dyn_cast<object::COFFObjectFile>(&In))
      return coff::executeObjcopyOnBinary(Config, *COFFBinary, Out);
    else
      error("Unsupported object file format");
  }     

At this point, the options have already been parsed out from the arguments and set in `CopyConfig`.

Also in a pathological case, with an archive file you could have different archive members of different formats...


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57045/new/

https://reviews.llvm.org/D57045





More information about the llvm-commits mailing list