public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/28060] New: [libabigail] Invalid offset for bitfields
@ 2021-07-07  9:27 david.marchand at redhat dot com
  2021-07-07  9:31 ` [Bug default/28060] " david.marchand at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: david.marchand at redhat dot com @ 2021-07-07  9:27 UTC (permalink / raw)
  To: libabigail

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

            Bug ID: 28060
           Summary: [libabigail] Invalid offset for bitfields
           Product: libabigail
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: default
          Assignee: dodji at redhat dot com
          Reporter: david.marchand at redhat dot com
                CC: libabigail at sourceware dot org
  Target Milestone: ---

This had been caught by a patchset submitted in the dpdk project.
Here is a reproducer with libabigail 1.8.2:

$ cat plop.c
#include <inttypes.h>

struct bigstruct {
        char name[128];
#ifdef BEFORE
        uint8_t bitfield0:1;
#else
        uint8_t bitfield0:1,
                bitfield1:1;
#endif
};

void access_bigstruct(struct bigstruct *st)
{
#ifndef BEFORE
        st->bitfield1 = 1;
#endif
}

$ cat Makefile
CC ?= gcc
CFLAGS ?= -Wall -Werror -g
ABIDIFF = abidiff

before_%.o: %.c
        $(CC) $(CFLAGS) -DBEFORE -o $@ -c $<
        pahole $@

after_%.o: %.c
        $(CC) $(CFLAGS) -o $@ -c $<
        pahole $@

dump: before_plop.o after_plop.o
        $(ABIDIFF) $^
abidiff before_plop.o after_plop.o

$ make
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'function void access_bigstruct(bigstruct*)' at plop.c:13:1 has some
indirect sub-type changes:
    parameter 1 of type 'bigstruct*' has sub-type changes:
      in pointed to type 'struct bigstruct' at plop.c:3:1:
        type size hasn't changed
        1 data member insertion:
          'uint8_t bigstruct::bitfield1', at offset 6 (in bits) at plop.c:9:1

make: *** [dump] Error 4


Afaiu, this offset 6 should instead be 1026.

Looking into debug info:

$ readelf --debug-dump=info after_plop.o |grep -C 10 bitfield1
 <2><88>: Abbrev Number: 7 (DW_TAG_member)
    <89>   DW_AT_name        : (indirect string, offset: 0x0): bitfield0
    <8d>   DW_AT_decl_file   : 1
    <8e>   DW_AT_decl_line   : 8
    <8f>   DW_AT_type        : <0x49>
    <93>   DW_AT_byte_size   : 1
    <94>   DW_AT_bit_size    : 1
    <95>   DW_AT_bit_offset  : 7
    <96>   DW_AT_data_member_location: 128
 <2><97>: Abbrev Number: 7 (DW_TAG_member)
    <98>   DW_AT_name        : (indirect string, offset: 0xa): bitfield1
    <9c>   DW_AT_decl_file   : 1
    <9d>   DW_AT_decl_line   : 9
    <9e>   DW_AT_type        : <0x49>
    <a2>   DW_AT_byte_size   : 1
    <a3>   DW_AT_bit_size    : 1
    <a4>   DW_AT_bit_offset  : 6
    <a5>   DW_AT_data_member_location: 128
 <2><a6>: Abbrev Number: 0
 <1><a7>: Abbrev Number: 8 (DW_TAG_array_type)
    <a8>   DW_AT_type        : <0xbe>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-19 12:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07  9:27 [Bug default/28060] New: [libabigail] Invalid offset for bitfields 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
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

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).