[PATCH] D43958: [llvm-readobj][ELF] Move ELF note parsing into lib/Object
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 10:47:30 PST 2018
scott at scottlinder.com writes:
> Right, I mis-phrased that. What I should say is there are no bounds in
> scope, because the struct does not contain a reference to its container.
>
> The new methods in ELFFile do have the bound in scope, and they pass it
> along to the iterator to do the checking. The getName and getDesc
> methods on the Nhdr struct could also accept a bound and do a check, but
> the intent of the patch is to not require the user of the library to
> know those details. That is why the constructors on the iterator are
> private, to encourage using the ELFFile interface to ensure proper
> bounds checks. I would also make the Nhdr struct hide more information,
> but that is not the approach taken by any of the surrounding header
> types.
That is the reason why we have
Expected<StringRef> getSectionName(const Elf_Shdr *Section) const;
instead of a getName in Elf_Shdr.
I think this patch should do something like that. Code in
include/llvm/Object should not make assumptions about the caller dealing
only with valid object files or what it wants to do with the error.
Cheers,
Rafael
More information about the llvm-commits
mailing list