[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
Thu Mar 1 13:54:01 PST 2018
Scott Linder via Phabricator <reviews at reviews.llvm.org> writes:
> +/// Note header
> +template <class ELFT>
> +struct Elf_Nhdr_Impl {
> + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
> + Elf_Word n_namesz;
> + Elf_Word n_descsz;
> + Elf_Word n_type;
> +
> + /// The alignment of the name and descriptor.
> + ///
> + /// Implementations differ from the specification here: in practice all
> + /// variants align both the name and descriptor to 4-bytes.
> + static const unsigned int Align = 4;
> +
> + /// Get the note's name, excluding the terminating null byte.
> + const StringRef getName() const {
> + if (!n_namesz)
> + return StringRef();
> + return StringRef(reinterpret_cast<const char *>(this) +
> + sizeof(Elf_Nhdr_Impl<ELFT>),
> + n_namesz - 1);
Should we perform bounds checking in here?
Cheers,
Rafael
More information about the llvm-commits
mailing list