[Bug lto/93609] New: gcc -flto -fno-comon places symbols into ".text" section

slyfox at inbox dot ru gcc-bugzilla@gcc.gnu.org
Wed Feb 5 23:23:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93609

            Bug ID: 93609
           Summary: gcc -flto -fno-comon places symbols into ".text"
                    section
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at inbox dot ru
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

It's an upstream version of https://bugs.gentoo.org/708340 where libtool was
not able to detect symbol type based on gcc-nm output.

Here is the small reproducer:

// cat a.c
char nm_test_var;
void nm_test_func(void){}

$ gcc -c a.c -o a.o -fcommon -flto && gcc-nm a.o
00000000 T nm_test_func
00000000 C nm_test_var

T/C - good

$ gcc -c a.c -o a.o -fno-common -flto && gcc-nm a.o
00000000 T nm_test_func
00000000 T nm_test_var

T/C - bad

For comparison here is non-lto version:

$ gcc -c a.c -o a.o -fcommon && gcc-nm a.o
0000000000000000 T nm_test_func
0000000000000001 C nm_test_var

T/C - good

$ gcc -c a.c -o a.o -fno-common && gcc-nm a.o
0000000000000000 T nm_test_func
0000000000000000 B nm_test_var

T/B - good

libtool only cares if a symbol is reportes as T or not:
http://git.savannah.gnu.org/cgit/libtool.git/tree/m4/libtool.m4#n3999

  lt_cv_sys_global_symbol_to_cdecl="sed -n"\
  $lt_cdecl_hook\
  " -e 's/^T .* \(.*\)$/extern int \1();/p'"\
  " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"

Is it fair to say that it's a gcc (or binutils?) bug?

Reproducing on gcc-9.2.0 and gcc-master.

$ LANG=C gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/dev/shm/portage/sys-devel/gcc-9.2.0-r3/work/gcc-9.2.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/9.2.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 9.2.0-r3 p4' --disable-esp --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64
--disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp
--disable-libmudflap --disable-libssp --disable-systemtap
--enable-vtable-verify --enable-lto --without-isl --enable-default-pie
--enable-default-ssp
Thread model: posix
gcc version 9.2.0 (Gentoo 9.2.0-r3 p4)


More information about the Gcc-bugs mailing list