From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17594 invoked by alias); 16 Jun 2014 14:48:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 17573 invoked by uid 48); 16 Jun 2014 14:48:44 -0000 From: "khimov at altell dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/61526] New: relocation R_X86_64_PC32 in shared object with static and extern Date: Mon, 16 Jun 2014 14:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: khimov at altell dot ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg01388.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61526 Bug ID: 61526 Summary: relocation R_X86_64_PC32 in shared object with static and extern Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: khimov at altell dot ru Created attachment 32947 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32947&action=edit two source files and workaround patch Compiling Quagga 0.99.22.4 with GCC 4.9.0 (compiler bootstrapped to cross-compile from x86_64 Debian GNU/Linux to x86_64 uClibc system) with LTO enabled fails: | x86_64-altell-linux-uclibc-libtool: link: ccache x86_64-altell-linux-uclibc-gcc -march=x86-64 -mtune=generic --sysroot=/home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc -shared -fPIC -DPIC .libs/network.o .libs/pid_output.o .libs/getopt.o .libs/getopt1.o .libs/daemon.o .libs/checksum.o .libs/vector.o .libs/linklist.o .libs/vty.o .libs/command.o .libs/sockunion.o .libs/prefix.o .libs/thread.o .libs/if.o .libs/memory.o .libs/buffer.o .libs/table.o .libs/hash.o .libs/filter.o .libs/routemap.o .libs/distribute.o .libs/stream.o .libs/str.o .libs/log.o .libs/plist.o .libs/zclient.o .libs/sockopt.o .libs/smux.o .libs/agentx.o .libs/snmp.o .libs/md5.o .libs/if_rmap.o .libs/keychain.o .libs/privs.o .libs/sigevent.o .libs/pqueue.o .libs/jhash.o .libs/memtypes.o .libs/workqueue.o -lcrypt -L/home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib /home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib/libnetsnmpmibs.so -ldl /home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib/libnetsnmpagent.so /home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib/libnetsnmp.so -lcrypto -lm -lpthread -lrt -march=x86-64 -mtune=generic --sysroot=/home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc -O2 -flto -O2 -flto -Wl,-O1 -Wl,--hash-style=gnu -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,-z -Wl,relro -Wl,-z -Wl,now -flto -Wl,-soname -Wl,libzebra.so.0 -o .libs/libzebra.so.0.0.0 | /home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib/libnetsnmp.so: warning: gethostbyaddr is obsolescent, use getaddrinfo() instead. | /home/rik/neo-1.5/tmp/sysroots/x86_64-altell-linux-uclibc/usr/lib/libnetsnmp.so: warning: gethostbyname is obsolescent, use getnameinfo() instead. | /home/rik/neo-1.5/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-altell-linux-uclibc/gcc/x86_64-altell-linux-uclibc/4.9.0/ld: /tmp/ccYjxIMj.ltrans1.ltrans.o: relocation R_X86_64_PC32 against undefined symbol `master' can not be used when making a shared object; recompile with -fPIC | /home/rik/neo-1.5/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-altell-linux-uclibc/gcc/x86_64-altell-linux-uclibc/4.9.0/ld: final link failed: Bad value Turns out that the problem can be reproduced with just two objects, vty.o and zclient.o, preprocessed sources attached. Compiling with: $ x86_64-altell-linux-uclibc-gcc -fno-strict-aliasing -pipe -O2 -fomit-frame-pointer -frename-registers -flto -c vty.prepr.c -fPIC -DPIC -o vty.o $ x86_64-altell-linux-uclibc-gcc -fno-strict-aliasing -pipe -O2 -fomit-frame-pointer -frename-registers -flto -c zclient.prepr.c -fPIC -DPIC -o zclient.o $ x86_64-altell-linux-uclibc-gcc -shared -fPIC -DPIC vty.o zclient.o -O2 -flto -o lib.so gives the same result: /home/rik/neo-1.5/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-altell-linux-uclibc/gcc/x86_64-altell-linux-uclibc/4.9.0/ld: /tmp/cc3LxvY0.ltrans1.ltrans.o: relocation R_X86_64_PC32 against undefined symbol `master.lto_priv.3' can not be used when making a shared object; recompile with -fPIC /home/rik/neo-1.5/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-altell-linux-uclibc/gcc/x86_64-altell-linux-uclibc/4.9.0/ld: final link failed: Bad value collect2: error: ld returned 1 exit status Compiling with -flto-partition=none solves the problem as does my current workaround patch to rename static variable in vty.o (attached, although the patch is for original Quagga package).