Bug 18313 - binutils: LTO error due possibly uninitialized values
Summary: binutils: LTO error due possibly uninitialized values
Status: RESOLVED OBSOLETE
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-23 21:03 UTC by dilyan.palauzov@aegee.org
Modified: 2015-07-07 09:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dilyan.palauzov@aegee.org 2015-04-23 21:03:14 UTC
When compiling binutils-master (commit 8900d71e38) I get these warnings and -Werror is active:

make[2]: Entering directory '/mnt/new/src/gcc/binutils-git-build/binutils'
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o ieee.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o  ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a  -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o .libs/objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o ieee.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o  ../opcodes/.libs/libopcodes.so -L/src/gcc/binutils-git-build/opcodes/../libiberty/pic ../bfd/.libs/libbfd.so -L/src/gcc/binutils-git-build/bfd/../libiberty/pic -L/src/gcc/binutils-git-build/zlib -liberty -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/binutils/ieee.c: In function 'ieee_read_cxx_misc':
/home/git/binutils-gdb/binutils/ieee.c:2977:8: error: 'varargs' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   type = debug_make_method_type (dhandle, return_type, it->type,
        ^
/home/git/binutils-gdb/binutils/ieee.c:2957:15: note: 'varargs' was declared here
   bfd_boolean varargs;
               ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:793: recipe for target 'objdump' failed
make[2]: *** [objdump] Error 1
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o objcopy objcopy.o not-strip.o rename.o rddbg.o debug.o stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a  -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o .libs/objcopy objcopy.o not-strip.o rename.o rddbg.o debug.o stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o  ../bfd/.libs/libbfd.so -L/src/gcc/binutils-git-build/bfd/../libiberty/pic -L/src/gcc/binutils-git-build/zlib -liberty -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/binutils/ieee.c: In function 'ieee_read_cxx_misc':
/home/git/binutils-gdb/binutils/ieee.c:2977:8: error: 'varargs' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   type = debug_make_method_type (dhandle, return_type, it->type,
        ^
/home/git/binutils-gdb/binutils/ieee.c:2957:15: note: 'varargs' was declared here
   bfd_boolean varargs;
               ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:790: recipe for target 'objcopy' failed
make[2]: *** [objcopy] Error 1
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o readelf readelf.o version.o unwind-ia64.o dwarf.o elfcomm.o  ../libiberty/libiberty.a -L./../zlib -lz -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o readelf readelf.o version.o unwind-ia64.o dwarf.o elfcomm.o  ../libiberty/libiberty.a -L/src/gcc/binutils-git-build/zlib -lz -ldl
/home/git/binutils-gdb/binutils/readelf.c: In function 'load_specific_debug_section.part.13':
/home/git/binutils-gdb/zlib/inflate.c:121:20: error: 'strm.state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     state->lencode = state->distcode = state->next = state->codes;
                    ^
/home/git/binutils-gdb/binutils/readelf.c:12049:12: note: 'strm.state' was declared here
   z_stream strm;
            ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:799: recipe for target 'readelf' failed
make[2]: *** [readelf] Error 1
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o strip-new objcopy.o is-strip.o rename.o rddbg.o debug.o stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a  -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o .libs/strip-new objcopy.o is-strip.o rename.o rddbg.o debug.o stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o  ../bfd/.libs/libbfd.so -L/src/gcc/binutils-git-build/bfd/../libiberty/pic -L/src/gcc/binutils-git-build/zlib -liberty -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/binutils/ieee.c: In function 'ieee_read_cxx_misc':
/home/git/binutils-gdb/binutils/ieee.c:2977:8: error: 'varargs' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   type = debug_make_method_type (dhandle, return_type, it->type,
        ^
/home/git/binutils-gdb/binutils/ieee.c:2957:15: note: 'varargs' was declared here
   bfd_boolean varargs;
               ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:811: recipe for target 'strip-new' failed
make[2]: *** [strip-new] Error 1
make[2]: Target 'all-am' not remade because of errors.
make[2]: Leaving directory '/mnt/new/src/gcc/binutils-git-build/binutils'
Comment 1 dilyan.palauzov@aegee.org 2015-04-23 22:34:56 UTC
Compiling ld also fails:

make[2]: Entering directory '/mnt/new/src/gcc/binutils-git-build/ld'
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -DELF_LIST_OPTIONS=TRUE -DELF_SHLIB_LIST_OPTIONS=TRUE -DELF_PLT_UNWIND_LIST_OPTIONS=TRUE -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o ld-new ldgram.o ldlex-wrapper.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o plugin.o ldbuildid.o eelf_x86_64.o eelf32_x86_64.o eelf_i386.o ei386linux.o eelf_l1om.o eelf_k1om.o  ../bfd/libbfd.la ../libiberty/libiberty.a  -ldl -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -DELF_LIST_OPTIONS=TRUE -DELF_SHLIB_LIST_OPTIONS=TRUE -DELF_PLT_UNWIND_LIST_OPTIONS=TRUE -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o ld-new ldgram.o ldlex-wrapper.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o plugin.o ldbuildid.o eelf_x86_64.o eelf32_x86_64.o eelf_i386.o ei386linux.o eelf_l1om.o eelf_k1om.o  ../bfd/.libs/libbfd.a -L/src/gcc/binutils-git-build/zlib -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/bfd/compress.c: In function 'decompress_contents':
/home/git/binutils-gdb/zlib/inflate.c:121:20: error: 'strm.state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     state->lencode = state->distcode = state->next = state->codes;
                    ^
/home/git/binutils-gdb/bfd/compress.c:35:12: note: 'strm.state' was declared here
   z_stream strm;
            ^
/home/git/binutils-gdb/bfd/compress.c: In function 'bfd_compress_section_contents':
/home/git/binutils-gdb/bfd/compress.c:159:4: error: 'zlib_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    memmove (buffer + compression_header_size,
    ^
/home/git/binutils-gdb/bfd/compress.c:86:7: note: 'zlib_size' was declared here
   int zlib_size;
       ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/x86_64-unknown-linux-gnu/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:1079: recipe for target 'ld-new' failed
make[2]: *** [ld-new] Error 1
Comment 2 cvs-commit@gcc.gnu.org 2015-04-24 16:14:53 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=de13ef81f041f7f51687ef1873c74e853b97e73a

commit de13ef81f041f7f51687ef1873c74e853b97e73a
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Apr 24 17:13:22 2015 +0100

    Fix compile time warning messages about variables being used before they are initialised.
    
    	PR 18313
    bin	* ieee.c (ieee_read_cxx_class): Initialise the varargs variable.
    	* readelf.c (uncompress_section_contents): Zero initialise the
    	zstream structure.
    
    bfd	* compress.c (decompress_contents): Zero initialse the z_stream
    	structure.
Comment 3 Nick Clifton 2015-04-24 16:15:30 UTC
Hi Dilyan,

  Thanks for reporting these problems.  I have checked in a patch which should resolve these issues.

Cheers
  Nick
Comment 4 dilyan.palauzov@aegee.org 2015-04-24 20:59:06 UTC
As of tree faade85139b04 there are still warnings/errors in binutils/, which were addressed in my first comment:

/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -Wl,-O1 -Wl,-z,relro -Wl,-s -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o ieee.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o  ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a  -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/binutils/../zlib -pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o ieee.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o  ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a -L/src/gcc/binutil-git/zlib -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/bfd/compress.c: In function 'bfd_compress_section_contents':
/home/git/binutils-gdb/bfd/compress.c:161:4: error: 'zlib_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    memmove (buffer + compression_header_size,
    ^
/home/git/binutils-gdb/bfd/compress.c:88:7: note: 'zlib_size' was declared here
   int zlib_size;
       ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:793: recipe for target 'objdump' failed
make[2]: *** [objdump] Error 1

and this is repeated for several binaries.  Gas also does not compile:

make[4]: Entering directory '/mnt/new/src/gcc/binutil-git/gas'
/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/gas/../zlib -pipe -O3 -fno-fat-lto-objects -flto  -static-libstdc++ -static-libgcc -Wl,-O1 -Wl,-z,relro -Wl,-s -o as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o  ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl 
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/home/git/binutils-gdb/gas/../zlib -pipe -O3 -fno-fat-lto-objects -flto -static-libstdc++ -static-libgcc -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -o as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o  ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a -L/src/gcc/binutil-git/zlib -lz ../libiberty/libiberty.a -ldl
/home/git/binutils-gdb/gas/cond.c: In function 's_if':
/home/git/binutils-gdb/gas/read.c:1378:9: error: 'stopc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *stop = stopc;
         ^
/home/git/binutils-gdb/gas/cond.c:131:8: note: 'stopc' was declared here
   char stopc;
        ^
/home/git/binutils-gdb/gas/cond.c: In function 's_ifc':
/home/git/binutils-gdb/gas/read.c:1378:9: error: 'stopc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *stop = stopc;
         ^
/home/git/binutils-gdb/gas/cond.c:264:8: note: 'stopc' was declared here
   char stopc;
        ^
lto1: all warnings being treated as errors
lto-wrapper: gcc returned 1 exit status
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:769: recipe for target 'as-new' failed
make[4]: *** [as-new] Error 1
Comment 5 cvs-commit@gcc.gnu.org 2015-04-28 10:24:11 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=da7119c99c41f60cb178b0b9729d9f7880f33c86

commit da7119c99c41f60cb178b0b9729d9f7880f33c86
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Apr 28 11:22:57 2015 +0100

    Fix compile time warnings about a local variable being used before it is set.
    
    	PR 18313
    	* cond.c (s_if): Stop compile time warning about stopc being used
    	before it is set.
    	(s_ifc): Likewise.
Comment 6 Nick Clifton 2015-04-28 10:26:47 UTC
Hi Dilyan,

> /home/git/binutils-gdb/gas/cond.c:131:8: note: 'stopc' was declared here
>    char stopc;

> /home/git/binutils-gdb/gas/cond.c:264:8: note: 'stopc' was declared here
>    char stopc;

I have checked in a patch to fix this two warnings.

Please check with H.J. about the warning in bfd/compress.c as he may wish to use a different solution there.

Cheers
  Nick
Comment 7 H.J. Lu 2015-04-28 13:14:04 UTC
Unless it is a real bug, please pass --disable-werror to configure
when you build binutils with -flto.
Comment 8 dilyan.palauzov@aegee.org 2015-05-03 13:25:03 UTC
I filled a report towards gcc/LTO: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65991 .
Comment 9 dilyan.palauzov@aegee.org 2015-07-07 09:18:57 UTC
The problem does not appear anymore, since I upgraded gcc 4.9.2 -> 4.9.3 .