public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
@ 2018-11-15  8:48 mliska at suse dot cz
  2018-11-15 16:03 ` [Bug libelf/23884] " mark at klomp dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mliska at suse dot cz @ 2018-11-15  8:48 UTC (permalink / raw)
  To: elfutils-devel

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

            Bug ID: 23884
           Summary: error: ‘__elf32_msize’ specifies less restrictive
                    attribute than its target ‘elf32_fsize’: ‘const’
                    [-Werror=missing-attributes]
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libelf
          Assignee: unassigned at sourceware dot org
          Reporter: mliska at suse dot cz
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

It's a new warning that comes with recent GCC 9:

$ make V=1
make --no-print-directory all-recursive
Making all in config
make[2]: Nothing to be done for 'all'.
Making all in m4
make[2]: Nothing to be done for 'all'.
Making all in lib
make[2]: Nothing to be done for 'all'.
Making all in libelf
gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/usr/local/share/locale"' -I.
-I..  -I. -I. -I../lib -I..  -std=gnu99 -Wall -Wshadow -Wformat=2
-Wold-style-definition -Wstrict-prototypes -Wlogical-op -Wduplicated-cond
-Wnull-dereference -Wimplicit-fallthrough=5 -Werror -Wunused -Wextra
-Wstack-usage=262144    -D_FORTIFY_SOURCE=2 -g -O2 -MT elf32_fsize.o -MD -MP
-MF .deps/elf32_fsize.Tpo -c -o elf32_fsize.o elf32_fsize.c
In file included from ../config.h:134,
                 from elf32_fsize.c:31:
libelfP.h:47:30: error: ‘__elf32_msize’ specifies less restrictive attribute
than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
   47 | #define __elfw2_(Bits, Name) __elf##Bits##_##Name
      |                              ^~~~~
../lib/eu-config.h:60:26: note: in definition of macro ‘strong_alias’
   60 |   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
      |                          ^~~~~~~~~
elf32_fsize.c:68:1: note: in expansion of macro ‘local_strong_alias’
   68 | local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS,
msize))
      | ^~~~~~~~~~~~~~~~~~
libelfP.h:52:29: note: in expansion of macro ‘__elfw2_’
   52 | #define __elfw2(Bits, Name) __elfw2_(Bits, Name)
      |                             ^~~~~~~~
elf32_fsize.c:68:47: note: in expansion of macro ‘__elfw2’
   68 | local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS,
msize))
      |                                               ^~~~~~~
In file included from elf32_fsize.c:35:
libelfP.h:48:28: note: ‘__elf32_msize’ target declared here
   48 | #define elfw2_(Bits, Name) elf##Bits##_##Name
      |                            ^~~
libelfP.h:53:27: note: in expansion of macro ‘elfw2_’
   53 | #define elfw2(Bits, Name) elfw2_(Bits, Name)
      |                           ^~~~~~
elf32_fsize.c:43:1: note: in expansion of macro ‘elfw2’
   43 | elfw2(LIBELFBITS, fsize) (Elf_Type type, size_t count, unsigned int
version)
      | ^~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:786: elf32_fsize.o] Error 1
make[1]: *** [Makefile:485: all-recursive] Error 1
make: *** [Makefile:401: all] Error 2

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

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

* [Bug libelf/23884] error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
  2018-11-15  8:48 [Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes] mliska at suse dot cz
@ 2018-11-15 16:03 ` mark at klomp dot org
  2018-11-15 16:17 ` mark at klomp dot org
  2018-11-16  8:31 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2018-11-15 16:03 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
This is weird. Where does the const come from?
Neither the declaration of fsize nor msize have a const.

It is as if gcc has determined that fsize could be const (maybe because it
looks up the return value in a static table?) and then because we use
__typeof__ to specify the type think the __typeof__ should include the const?

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

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

* [Bug libelf/23884] error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
  2018-11-15  8:48 [Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes] mliska at suse dot cz
  2018-11-15 16:03 ` [Bug libelf/23884] " mark at klomp dot org
@ 2018-11-15 16:17 ` mark at klomp dot org
  2018-11-16  8:31 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2018-11-15 16:17 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-11-15
     Ever confirmed|0                           |1

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
No, of course gcc is right.

fsize is declared in libelf.h as:

/* Return size of array of COUNT elements of the type denoted by TYPE
   in the external representation.  The binary class is taken from ELF.
   The result is based on version VERSION of the ELF standard.  */
extern size_t elf32_fsize (Elf_Type __type, size_t __count,
                           unsigned int __version)
       __const_attribute__;
/* Similar but this time the binary calls is ELFCLASS64.  */
extern size_t elf64_fsize (Elf_Type __type, size_t __count,
                           unsigned int __version)
       __const_attribute__;

But msize is declared in libelfP.h as:

/* The libelf API does not have such a function but it is still useful.
   Get the memory size for the given type.

   These functions cannot be marked internal since they are aliases
   of the export elfXX_fsize functions.*/
extern size_t __elf32_msize (Elf_Type __type, size_t __count,
                             unsigned int __version);
extern size_t __elf64_msize (Elf_Type __type, size_t __count,
                             unsigned int __version);

So the obvious fix is:

diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index fa6d55d..9f3e8e9 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -461,9 +461,9 @@ extern Elf_Type __libelf_data_type (Elf *elf, int sh_type,
G
    These functions cannot be marked internal since they are aliases
    of the export elfXX_fsize functions.*/
 extern size_t __elf32_msize (Elf_Type __type, size_t __count,
-                            unsigned int __version);
+                            unsigned int __version) __const_attribute__;
 extern size_t __elf64_msize (Elf_Type __type, size_t __count,
-                            unsigned int __version);
+                            unsigned int __version) __const_attribute__;


 /* Create Elf descriptor from memory image.  */

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

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

* [Bug libelf/23884] error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
  2018-11-15  8:48 [Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes] mliska at suse dot cz
  2018-11-15 16:03 ` [Bug libelf/23884] " mark at klomp dot org
  2018-11-15 16:17 ` mark at klomp dot org
@ 2018-11-16  8:31 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2018-11-16  8:31 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
commit a01938d584b91e747167bb4b3f30ec300c4d6e43
Author: Mark Wielaard <mark@klomp.org>
Date:   Fri Nov 16 09:27:00 2018 +0100

    libelf: Mark both fsize and msize with const attribute.

    GCC9 -Wmissing-attributes pointed out that although we alias the fsize
    and msize functions only fsize was marked as const. Fix by also marking
    the msize definition as const.

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

    Signed-off-by: Mark Wielaard <mark@klomp.org>

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

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

end of thread, other threads:[~2018-11-16  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15  8:48 [Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes] mliska at suse dot cz
2018-11-15 16:03 ` [Bug libelf/23884] " mark at klomp dot org
2018-11-15 16:17 ` mark at klomp dot org
2018-11-16  8:31 ` mark at klomp dot org

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