public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Giuliano Procida <gprocida@google.com>
Cc: libabigail@sourceware.org, Dodji Seketeli <dodji@seketeli.org>,
	kernel-team@android.com, maennich@google.com
Subject: Re: [PATCH 1/1] DWARF reader: fix bitfield offset calculations
Date: Sat, 10 Jul 2021 21:15:53 +0200	[thread overview]
Message-ID: <CAJFAV8x+hc2iNoVyv6K+jXk5Uvt03tKkDLO1KAg5T27zfp_Bqw@mail.gmail.com> (raw)
In-Reply-To: <CAGvU0H=X9DP44JF-atNVYQw552Zqfvi_PRn1AoE6VHr3dKGDxQ@mail.gmail.com>

On Sat, Jul 10, 2021 at 6:52 PM Giuliano Procida <gprocida@google.com> wrote:
> >
> > But now, I face an issue trying to waive this.
> > The addition of the "dev_configured" field in this bitfield is right
> > after a 1 bit wide "lro" field and before a "rx_queue_state" field.
> > https://git.dpdk.org/dpdk/tree/lib/ethdev/rte_ethdev_core.h?id=f0b97fc4fe4cd16dd492cf30ece4296451e10e10#n165
> >
> > The rule below does not work:
> > [suppress_type]
> >         name = rte_eth_dev_data
> >         has_data_member_inserted_between = {offset_after(lro),
> > offset_of(rx_queue_state)}
> >
> > While on the other hand, this one works:
> > [suppress_type]
> >         name = rte_eth_dev_data
> >         has_data_member_inserted_between = {34005, offset_of(rx_queue_state)}
> >
> > Not sure what the issue is, but supposing the offsets are now correct,
> > then my bet is on the "lro" field size (here, 1 bit).
> >
>
> I'd open a separate bug for that.

Yep, I hesitated at first, but now I think we need one, see below.


>
> >
> > Back to my reproducer, that I updated:
> >
> > struct bigstruct {
> >     char name[128];
> >     uint8_t bitfield0:1
> > #ifndef BEFORE
> >             ,bitfield1:1
> > #endif
> >     ;
> >     uint8_t other;
> > };
> >
> > I wrote a suppression rule:
> > [suppress_type]
> >     name = bigstruct
> >     has_data_member_inserted_between = {offset_after(bitfield0),
> > offset_of(other)}
> >
> > And then I tried to debug, but I am lost in libabigail internals.
> > I attached a gdb to catch all get_size_in_bits() calls, I see either
> > 1024 (sizeof name), 8 (sizeof other?), 0 (this is suspicious) or 64
> > (?).
> >
>
> I would advise the following: separate ABI extraction (abidw) from ABI
> comparison (abidiff), if you haven't already.

That's what we do in dpdk.
Just, for testing here, I only used abidiff with object files.


>
> You can at least carefully check the XML before comparing XML files.

Yeah, good idea, and so, looking at xml:

<abi-corpus version='2.0' path='after_plop.o' architecture='elf-amd-x86_64'>
  <elf-function-symbols>
    <elf-symbol name='access_bigstruct' type='func-type'
binding='global-binding' visibility='default-visibility'
is-defined='yes'/>
  </elf-function-symbols>
  <abi-instr address-size='64' path='plop.c'
comp-dir-path='/home/dmarchan/libabigail_bitfields'
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'/>
    </array-type-def>
    <type-decl name='unsigned char' size-in-bits='8' id='type-id-5'/>
    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
    <type-decl name='void' id='type-id-6'/>
    <class-decl name='bigstruct' size-in-bits='1040' is-struct='yes'
visibility='default'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='3'
column='1' id='type-id-7'>
      <data-member access='public' layout-offset-in-bits='0'>
        <var-decl name='name' type-id='type-id-2' visibility='default'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='4'
column='1'/>
      </data-member>
      <data-member access='public' layout-offset-in-bits='1024'>
        <var-decl name='bitfield0' type-id='type-id-8'
visibility='default'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='5'
column='1'/>
                                            ^^^^^^^^^
      </data-member>
      <data-member access='public' layout-offset-in-bits='1025'>
        <var-decl name='bitfield1' type-id='type-id-8'
visibility='default'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='7'
column='1'/>
      </data-member>
      <data-member access='public' layout-offset-in-bits='1032'>
        <var-decl name='other' type-id='type-id-8'
visibility='default'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='10'
column='1'/>
      </data-member>
    </class-decl>
    <typedef-decl name='uint8_t' type-id='type-id-9'
filepath='/usr/include/bits/stdint-uintn.h' line='24' column='1'
id='type-id-8'/>
    <typedef-decl name='__uint8_t' type-id='type-id-5'
filepath='/usr/include/bits/types.h' line='38' column='1'
id='type-id-9'/>
    <pointer-type-def type-id='type-id-7' size-in-bits='64' id='type-id-10'/>
    <function-decl name='access_bigstruct'
mangled-name='access_bigstruct'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='13'
column='1' visibility='default' binding='global' size-in-bits='64'
elf-symbol-id='access_bigstruct'>
      <parameter type-id='type-id-10' name='st'
filepath='/home/dmarchan/libabigail_bitfields/plop.c' line='13'
column='1'/>
      <return type-id='type-id-6'/>
    </function-decl>
  </abi-instr>
</abi-corpus>


My two 1bit fields are marked with type-id-8 which I understand points
at uint8_t.
I'll open a bz.


-- 
David Marchand


  reply	other threads:[~2021-07-10 19:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 23:16 [PATCH 0/1] Fix Bug 28060 - Invalid offset for bitfields Giuliano Procida
2021-07-09 23:16 ` [PATCH 1/1] DWARF reader: fix bitfield offset calculations Giuliano Procida
2021-07-10  9:18   ` David Marchand
2021-07-10 16:51     ` Giuliano Procida
2021-07-10 19:15       ` David Marchand [this message]
2021-07-10 16:52   ` [PATCH v2] " Giuliano Procida
2021-07-15 16:21     ` David Marchand
2021-07-19 11:59     ` [PATCH v2, applied] " Dodji Seketeli

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=CAJFAV8x+hc2iNoVyv6K+jXk5Uvt03tKkDLO1KAg5T27zfp_Bqw@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=dodji@seketeli.org \
    --cc=gprocida@google.com \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.com \
    /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).