[Bug libelf/23884] New: error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
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.
[PATCH] libebl: Don't update w, t and len unnecessarily in ebl_object_note_type_name.
Harmless, but useless. Signed-off-by: Mark Wielaard --- libebl/ChangeLog| 5 + libebl/eblobjnotetypename.c | 8 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libebl/ChangeLog b/libebl/ChangeLog index 79a2ff4..a2f8956 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,8 @@ +2018-11-15 Mark Wielaard + + * eblobjnotetypename.c (ebl_object_note_type_name): Don't update + w, t and len unnecessarily. + 2018-11-12 Mark Wielaard * libebl.h (ebl_object_note): Add new argument namesz. diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c index 29a5391..6b803ce 100644 --- a/libebl/eblobjnotetypename.c +++ b/libebl/eblobjnotetypename.c @@ -91,13 +91,11 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type, t += w; len -= w; if (type == NT_GNU_BUILD_ATTRIBUTE_OPEN) - w = snprintf (t, len, "OPEN"); + snprintf (t, len, "OPEN"); else if (type == NT_GNU_BUILD_ATTRIBUTE_FUNC) - w = snprintf (t, len, "FUNC"); + snprintf (t, len, "FUNC"); else - w = snprintf (t, len, "%x", type); - t += w; - len -= w; + snprintf (t, len, "%x", type); return buf; } -- 1.8.3.1
[Bug libelf/23884] error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
https://sourceware.org/bugzilla/show_bug.cgi?id=23884 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org --- Comment #1 from Mark Wielaard --- 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.
[Bug libelf/23884] error: ‘__elf32_msize’ specifies less restrictive attribute than its target ‘elf32_fsize’: ‘const’ [-Werror=missing-attributes]
https://sourceware.org/bugzilla/show_bug.cgi?id=23884 Mark Wielaard changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2018-11-15 Ever confirmed|0 |1 --- Comment #2 from Mark Wielaard --- 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.