[PATCH] D27182: [MachO] Add UnknownValueErrors and ability to ignore them.

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 18:06:36 PST 2016


beanz created this revision.
beanz added reviewers: lhames, enderby.
beanz added a subscriber: llvm-commits.

This patch is a first step toward using the llvm::Error mechanism to surface non-fatal errors in object file handling. This patch adds a new error for unrecognized load command IDs, as an UnknownValueError.

It also adds the ability to ignore UnknownValueErrors since an object file with unknown values may still be structurally valid. This is particularly important for tools that need to operate correctly on binary files produced with newer compilers than the tool itself came from. For example, running an old LLDB on a binary compiled with a newer Clang would need to be able to ignore unknown load commands because we might have added new commands.

We will want to take this one step further by surfacing the object and errors through an "ErrorAnd" construct and allowing the recipient to determine how to handle each error. Since this patch is sufficiently large as-is, and feeding that through all the libObject common APIs is also a large change I'd like to do that in a separate patch.

Doing the larger cleanup will remove the "IgnoreValueErrors" parameter from the common APIs, but will require touching ELF and COFF as well as MachO.


https://reviews.llvm.org/D27182

Files:
  include/llvm/Object/Binary.h
  include/llvm/Object/Error.h
  include/llvm/Object/MachO.h
  include/llvm/Object/ObjectFile.h
  include/llvm/Object/SymbolicFile.h
  lib/Object/Binary.cpp
  lib/Object/Error.cpp
  lib/Object/MachOObjectFile.cpp
  lib/Object/MachOUniversal.cpp
  lib/Object/ObjectFile.cpp
  lib/Object/SymbolicFile.cpp
  test/Object/Inputs/macho-unknown-lc-id
  test/Object/macho-unknown-lc-id.test
  tools/obj2yaml/obj2yaml.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27182.79490.patch
Type: text/x-patch
Size: 44760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/00965f65/attachment.bin>


More information about the llvm-commits mailing list