public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "khimov at altell dot ru" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-61526-4@http.gcc.gnu.org/bugzilla/> (raw)

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).


             reply	other threads:[~2014-06-16 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 14:48 khimov at altell dot ru [this message]
2014-06-17  9:00 ` [Bug lto/61526] " rguenth at gcc dot gnu.org
2014-06-17  9:28 ` khimov at altell dot ru
2014-07-21 16:00 ` sandra at codesourcery dot com
2014-07-21 16:17 ` ubizjak at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61526-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).