[PATCH] D43958: [llvm-readobj][ELF] Move ELF note parsing into lib/Object

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 14:45:29 PST 2018

scott.linder updated this revision to Diff 137080.
scott.linder added a comment.

This patch should make the interfaces safe in any context. Bounds checks are done using sizes, and are completed before pointers are created. The checks are done only as necessary: the size of the container (section or program header) is checked before creating the iterator, the size of each `Nhdr` is checked before a pointer to it is created, and the sizes of the name/descriptor are checked before the StringRef/ArrayRef are created.

Programmer errors, like continuing to iterate after reaching the end iterator or providing a non-success Error when creating the start iterator, are caught with asserts.

The constructors of of the `Elf_Note_Impl` and `Elf_Note_Iterator_Impl` are still private with `friend` declarations. Would we prefer to make these public? I cannot think of a use-case, as all calling code should be using the functions in `ELFFile` to access notes, and this makes it harder for a caller to get an iterator or note in a bad state.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43958.137080.patch
Type: text/x-patch
Size: 14122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/5150afb0/attachment.bin>

More information about the llvm-commits mailing list