[Bug c/61144] Invalid optimizations for extern vars with local weak definitions

jody at jodybruchon dot com gcc-bugzilla@gcc.gnu.org
Mon May 12 13:23:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144

--- Comment #9 from Jody Lee Bruchon <jody at jodybruchon dot com> ---
For my gcc versions (x86_64) compiled from release sources, I have the
following for this testcase, with and without static, using -O2:

=== gcc 4.8.2, with and without static ===

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure --prefix=/usr --mandir=/usr/man
--libexecdir=/usr/lib --enable-languages=c,c++,objc --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-shared --disable-nls
--with-x=no --with-system-zlib --disable-multilib --disable-bootstrap
--disable-debug
Thread model: posix
gcc version 4.8.2 (GCC)

$ objdump -dr test.o

test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:   8b 15 00 00 00 00       mov    0x0(%rip),%edx        # 6 <bar+0x6>
                        2: R_X86_64_PC32        foo-0x4
   6:   31 c0                   xor    %eax,%eax
   8:   85 d2                   test   %edx,%edx
   a:   0f 95 c0                setne  %al
   d:   c3                      retq

=== gcc 4.9.0 ===

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.9.0/configure --prefix=/usr --mandir=/usr/man
--libexecdir=/usr/lib --enable-languages=c,c++,objc --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-shared --disable-nls
--with-x=no --with-system-zlib --disable-multilib --disable-debug
Thread model: posix
gcc version 4.9.0 (GCC)

=== With static (4.9.0) ===

$ objdump -dr test.o

test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:   31 c0                   xor    %eax,%eax
   2:   c3                      retq

=== Without static (4.9.0) ===

$ objdump -dr test.o

test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:   8b 15 00 00 00 00       mov    0x0(%rip),%edx        # 6 <bar+0x6>
                        2: R_X86_64_PC32        foo-0x4
   6:   31 c0                   xor    %eax,%eax
   8:   85 d2                   test   %edx,%edx
   a:   0f 95 c0                setne  %al
   d:   c3                      retq



More information about the Gcc-bugs mailing list