This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug lto/61526] New: relocation R_X86_64_PC32 in shared object with static and extern


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]