public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/25661] New: [libabigail] incorrect handling of anonymous struct/union fields
@ 2020-03-12 12:15 david.marchand at redhat dot com
  2020-04-29 13:30 ` [Bug default/25661] " dodji at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: david.marchand at redhat dot com @ 2020-03-12 12:15 UTC (permalink / raw)
  To: libabigail

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

            Bug ID: 25661
           Summary: [libabigail] incorrect handling of anonymous
                    struct/union fields
           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:

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

struct _export {
#ifdef BEFORE
        uint64_t marker[0];
        uint64_t a;
        uint64_t b;
#else
        union {
                uint64_t marker[0];
                struct {
                        uint64_t a;
                        uint64_t b;
                };
        };
#endif
        uint64_t c;
};

extern void set_a(struct _export *sym);
void set_a(struct _export *sym)
{
        sym->a = 1;
}

$ 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) $^

[dmarchan@wsfd-netdev66 struct_anon_field]$ rm *.o; make
cc -Wall -Werror -g -DBEFORE -o before_plop.o -c plop.c
pahole before_plop.o
struct _export {
        uint64_t                   marker[0];            /*     0     0 */
        uint64_t                   a;                    /*     0     8 */
        uint64_t                   b;                    /*     8     8 */
        uint64_t                   c;                    /*    16     8 */

        /* size: 24, cachelines: 1, members: 4 */
        /* last cacheline: 24 bytes */
};
cc -Wall -Werror -g -o after_plop.o -c plop.c
pahole after_plop.o
struct _export {
        union {
                uint64_t           marker[0];            /*     0     0 */
                struct {
                        uint64_t   a;                    /*     0     8 */
                        uint64_t   b;                    /*     8     8 */
                };                                       /*     0    16 */
        };                                               /*     0    16 */
        uint64_t                   c;                    /*    16     8 */

        /* size: 24, cachelines: 1, members: 2 */
        /* last cacheline: 24 bytes */
};
abidiff before_plop.o after_plop.o
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 set_a(_export*)' at plop.c:21:1 has some indirect sub-type
changes:
    parameter 1 of type '_export*' has sub-type changes:
      in pointed to type 'struct _export' at plop.c:3:1:
        type size hasn't changed
        2 data member deletions:
          'uint64_t _export::marker[]', at offset 0 (in bits) at plop.c:5:1

          'uint64_t _export::b', at offset 64 (in bits) at plop.c:7:1

        1 data member change:
         data member uint64_t _export::a at offset 0 (in bits) became anonymous
data member 'union {uint64_t marker[]; struct {uint64_t a; uint64_t b; };}'


make: *** [Makefile:14: dump] Error 4

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

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

end of thread, other threads:[~2020-05-18 12:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 12:15 [Bug default/25661] New: [libabigail] incorrect handling of anonymous struct/union fields david.marchand at redhat dot com
2020-04-29 13:30 ` [Bug default/25661] " dodji at redhat dot com
2020-04-29 13:31 ` dodji at redhat dot com
2020-04-29 13:32 ` dodji at redhat dot com
2020-04-29 16:37 ` david.marchand at redhat dot com
2020-05-18  9:38 ` [Bug default/25661] [libabigail] Handle data member replacement by anonymous data members dodji at redhat dot com
2020-05-18 12:28 ` 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).