From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3992917055890136575==" MIME-Version: 1.0 From: Josh Stone To: elfutils-devel@lists.fedorahosted.org Subject: Re: dwarf_aggregate_size() seems to fall over on pointer types Date: Wed, 01 Oct 2014 10:46:52 -0700 Message-ID: <542C3E0C.3000503@redhat.com> In-Reply-To: CAG6CVpW-0N9-b+xEax5cuowKTxAKwDntyUB-haaZPmpM3q28FA@mail.gmail.com --===============3992917055890136575== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 10/01/2014 10:15 AM, Conrad Rad wrote: > Hi all, > = > First, I'm not super familiar with DWARF, and perhaps this is a bug in > the DWARF information emitted by Clang (3.4). It's definitely a > difference between GCC and Clang DWARF output. > = > I've been fiddling with a pahole-alike tool[0] that sits directly on > elfutils (as opposed to libdwarves, which hasn't been updated for some > time and doesn't handle some of the tags Clang emits). I've observed > that dwarf_aggregate_size() doesn't seem to like types that are > pointers or arrays of pointers[1]. > = > I've compiled a small example program, repro, and output[2]: > http://pastie.org/9610702 > = > dwarf_aggregate_size() has no trouble with most member types, or even > pointer types on the output from GCC. However, it returns an error on > Clang's output. > = > Perhaps Clang is just eliding pointer size information, assuming > consumers will consult the Elf machine class and infer? Indeed, clang doesn't seem to output DW_AT_byte_size on any DW_TAG_pointer_type, but gcc does. FWIW, the DWARF4 Appendix A does *not* list DW_AT_byte_size as being applicable to DW_TAG_pointer_type, nor DW_TAG_reference_type, nor DW_TAG_rvalue_reference_type. However, that is just "informative", and producers are free to omit some of the suggestions as well as add their own, so it's not an error that gcc produces DW_AT_byte_size. > Am I missing something? Is this a Clang bug or an elfutils bug? I don't think it's strictly a bug in either. Clang is not required to produce byte_size, and elfutils is just reporting what it knows. Still, it might be nice if elfutils made that machine-class inference for you. (But I worry about things like that mips pointer issue reported recently.) --===============3992917055890136575==--