public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: "gprocida at google dot com" <sourceware-bugzilla@sourceware.org>
To: libabigail@sourceware.org
Subject: [Bug default/28060] [libabigail] Invalid offset for bitfields
Date: Thu, 08 Jul 2021 09:34:20 +0000	[thread overview]
Message-ID: <bug-28060-9487-9EvVrXibEt@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28060-9487@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28060

gprocida at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gprocida at google dot com

--- Comment #2 from gprocida at google dot com ---
The problem is in abidw, not abidiff.

I'm guessing that both DW_AT_data_member_location and DW_AT_data_bit_offset
need to be taken into consideration, not just one of them.

The problem exists with -gdwarf-3 and -gdwarf-4, but not -gdwarf-5.

$ head test.{0,1}.c
==> test.0.c <==
#include <inttypes.h>

struct bigstruct {
  char name[128];
  uint8_t bitfield0:1;
};

uint8_t foo(const struct bigstruct * big) { return big->bitfield0; }

==> test.1.c <==
#include <inttypes.h>

struct bigstruct {
  char name[128];
  uint8_t bitfield0:1;
  uint8_t bitfield1:1;
};

uint8_t foo(const struct bigstruct * big) { return big->bitfield0; }
$ for i in 0 1; do gcc -Wall -Wextra -g -c test.$i.c; abidw --no-show-locs
test.$i.o > test.$i.xml; done
$ diff -u test.{0,1}.xml
--- test.0.xml  2021-07-08 10:21:30.460919575 +0100
+++ test.1.xml  2021-07-08 10:21:30.516919874 +0100
@@ -1,8 +1,8 @@
-<abi-corpus version='2.0' path='test.0.o' architecture='elf-amd-x86_64'>
+<abi-corpus version='2.0' path='test.1.o' architecture='elf-amd-x86_64'>
   <elf-function-symbols>
     <elf-symbol name='foo' type='func-type' binding='global-binding'
visibility='default-visibility' is-defined='yes'/>
   </elf-function-symbols>
-  <abi-instr address-size='64' path='test.0.c'
comp-dir-path='/usr/local/google/home/gprocida/dev/libabigail/bitfields2'
language='LANG_C99'>
+  <abi-instr address-size='64' path='test.1.c'
comp-dir-path='/usr/local/google/home/gprocida/dev/libabigail/bitfields2'
language='LANG_C99'>
     <type-decl name='char' size-in-bits='8' id='type-id-1'/>
     <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='1024'
id='type-id-2'>
       <subrange length='128' type-id='type-id-3' id='type-id-4'/>
@@ -18,6 +18,9 @@
       <data-member access='public' layout-offset-in-bits='0'>
         <var-decl name='bitfield0' type-id='type-id-7' visibility='default'/>
       </data-member>
+      <data-member access='public' layout-offset-in-bits='1'>
+        <var-decl name='bitfield1' type-id='type-id-7' visibility='default'/>
+      </data-member>
     </class-decl>
     <qualified-type-def type-id='type-id-8' const='yes' id='type-id-9'/>
     <pointer-type-def type-id='type-id-9' size-in-bits='64' id='type-id-10'/>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-07-08  9:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07  9:27 [Bug default/28060] New: " david.marchand at redhat dot com
2021-07-07  9:31 ` [Bug default/28060] " david.marchand at redhat dot com
2021-07-08  9:34 ` gprocida at google dot com [this message]
2021-07-08  9:42 ` david.marchand at redhat dot com
2021-07-08 13:41 ` gprocida at google dot com
2021-07-19 12:01 ` dodji at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28060-9487-9EvVrXibEt@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).