[llvm] r274728 - Define endianness-aware type for Elf_Chdr.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 15:24:51 PDT 2016


On Thu, Jul 7, 2016 at 2:15 PM, Rui Ueyama <ruiu at google.com> wrote:

> All ELF types are duplicated to ELF.h, so what George did was consistent
> with the existing types, although I admit that that is confusing.
>

Oh yeah, oops. I guess I meant just the "move over to using ELFTypes.h"
part of that.

-- Sean Silva


>
> On Thu, Jul 7, 2016 at 2:02 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>> George,
>>
>> I noticed that in r269404 you added Elf{32,64}_Chdr to ELF.h, but it
>> really should have been in ELFTypes.h like Rui has done in this patch. Can
>> you please remove the versions in ELF.h? It is practically guaranteed that
>> there is an endianness bug anywhere that is using those types; they should
>> be using ELFTypes.h.
>>
>> -- Sean Silva
>>
>> On Wed, Jul 6, 2016 at 8:53 PM, Rui Ueyama via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: ruiu
>>> Date: Wed Jul  6 22:53:00 2016
>>> New Revision: 274728
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274728&view=rev
>>> Log:
>>> Define endianness-aware type for Elf_Chdr.
>>>
>>> Modified:
>>>     llvm/trunk/include/llvm/Object/ELFTypes.h
>>>
>>> Modified: llvm/trunk/include/llvm/Object/ELFTypes.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFTypes.h?rev=274728&r1=274727&r2=274728&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/Object/ELFTypes.h (original)
>>> +++ llvm/trunk/include/llvm/Object/ELFTypes.h Wed Jul  6 22:53:00 2016
>>> @@ -34,6 +34,7 @@ template <class ELFT> struct Elf_Vernaux
>>>  template <class ELFT> struct Elf_Versym_Impl;
>>>  template <class ELFT> struct Elf_Hash_Impl;
>>>  template <class ELFT> struct Elf_GnuHash_Impl;
>>> +template <class ELFT> struct Elf_Chdr_Impl;
>>>
>>>  template <endianness E, bool Is64> struct ELFType {
>>>  private:
>>> @@ -59,6 +60,7 @@ public:
>>>    typedef Elf_Versym_Impl<ELFType<E, Is64>> Versym;
>>>    typedef Elf_Hash_Impl<ELFType<E, Is64>> Hash;
>>>    typedef Elf_GnuHash_Impl<ELFType<E, Is64>> GnuHash;
>>> +  typedef Elf_Chdr_Impl<ELFType<E, Is64>> Chdr;
>>>    typedef ArrayRef<Dyn> DynRange;
>>>    typedef ArrayRef<Shdr> ShdrRange;
>>>    typedef ArrayRef<Sym> SymRange;
>>> @@ -558,6 +560,24 @@ struct Elf_GnuHash_Impl {
>>>    }
>>>  };
>>>
>>> +// Compressed section headers.
>>> +template <endianness TargetEndianness>
>>> +struct Elf_Chdr_Impl<ELFType<TargetEndianness, false>> {
>>> +  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
>>> +  Elf_Word ch_type;
>>> +  Elf_Word ch_size;
>>> +  Elf_Word ch_addralign;
>>> +};
>>> +
>>> +template <endianness TargetEndianness>
>>> +struct Elf_Chdr_Impl<ELFType<TargetEndianness, true>> {
>>> +  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
>>> +  Elf_Word ch_type;
>>> +  Elf_Word ch_reserved;
>>> +  Elf_Xword ch_size;
>>> +  Elf_Xword ch_addralign;
>>> +};
>>> +
>>>  // MIPS .reginfo section
>>>  template <class ELFT>
>>>  struct Elf_Mips_RegInfo;
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160707/57ae7427/attachment-0001.html>


More information about the llvm-commits mailing list