Prefer erroring out than silently not doing what was requested.
The current set of implemented options are the only ones used in my test corpus.
Differential D57045
[llvm-objcopy] [COFF] Error out on use of unhandled options mstorsjo on Jan 22 2019, 3:49 AM. Authored by
Details Prefer erroring out than silently not doing what was requested. The current set of implemented options are the only ones used in my test corpus.
Diff Detail
Event TimelineComment Actions 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? Comment Actions 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... |