[PATCH v2] elf: Silence GCC 12 false positive warning

Noah Goldstein goldstein.w.n@gmail.com
Fri Jun 17 02:39:04 GMT 2022


On Thu, Jun 16, 2022 at 7:31 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Thu, Jun 16, 2022 at 6:57 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > Silence GCC 12 false positive warning with -mavx512f on dl-load.c:
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106008
> >
> > $ gcc -O2 -fPIC -march=x86-64 -mavx512f -S -Wall ...
> > dl-load.c: In function ‘_dl_map_object_from_fd.constprop’:
> > dl-load.c:1158:30: warning: ‘(((char *)loadcmds.113_68 + _933 + 16))[329406144173384849].mapend’ may be used uninitialized [-Wmaybe-uninitialized]
> > ---
> >  elf/dl-load.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/elf/dl-load.c b/elf/dl-load.c
> > index 2e4a010fc5..806d7a9a62 100644
> > --- a/elf/dl-load.c
> > +++ b/elf/dl-load.c
> > @@ -1152,11 +1152,21 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
> >             p_align_max = ph->p_align;
> >           c->mapoff = ALIGN_DOWN (ph->p_offset, GLRO(dl_pagesize));
> >
> > +         DIAG_PUSH_NEEDS_COMMENT;
> > +
> > +#if __GNUC_PREREQ (12, 0)
> > +         /* Suppress valid GCC warning:
> > +            ‘(((char *)loadcmds.113_68 + _933 + 16))[329406144173384849].mapend’ may be used uninitialized [-Wmaybe-uninitialized]
> > +          */
> > +         DIAG_IGNORE_NEEDS_COMMENT (12, "-Wmaybe-uninitialized");
> > +#endif
>
> I get this issue with CC="gcc-11 x86-64-v4" aswell.

No issue with gcc-10.

What about:

#if __GNUC_PREREQ (11, 0) && defined __AVX512F__?
> >           /* Determine whether there is a gap between the last segment
> >              and this one.  */
> >           if (nloadcmds > 1 && c[-1].mapend != c->mapstart)
> >             has_holes = true;
> >
> > +         DIAG_POP_NEEDS_COMMENT;
> > +
> >           /* Optimize a common case.  */
> >  #if (PF_R | PF_W | PF_X) == 7 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7
> >           c->prot = (PF_TO_PROT
> > --
> > 2.36.1
> >


More information about the Libc-alpha mailing list