Bug 43727 - undefined reference to `_restgpr_30_x'
Summary: undefined reference to `_restgpr_30_x'
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-12 15:03 UTC by marcus
Modified: 2010-04-13 14:30 UTC (History)
3 users (show)

See Also:
Host: powerpc-unknown-linux
Target: powerpc-unknown-linux
Build: powerpc-unknown-linux
Known to work:
Known to fail:
Last reconfirmed: 2010-04-13 12:34:10


Attachments
hello.c (81 bytes, text/plain)
2010-04-12 15:04 UTC, marcus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marcus 2010-04-12 15:03:43 UTC
In -Os mode I see undefined references to _restgpr_* _savefpr_* and similar functions.

Michael Matz sees libgcc.a not added to the linkline in this mode.

testcase:

g++ -Os -shared -o libhello.so -Wl,-z,defs -fPIC hello.c
/tmp/cc8oo25Z.o: In function `hello()':
hello.c:(.text+0x30): undefined reference to `_restgpr_30_x'
collect2: ld returned 1 exit status
Comment 1 marcus 2010-04-12 15:04:26 UTC
Created attachment 20366 [details]
hello.c

g++ -Os -shared -o libhello.so -Wl,-z,defs -fPIC hello.c
Comment 2 Richard Biener 2010-04-12 15:16:47 UTC
Nathan, you touched the relevant code last.
Comment 3 Nathan Froyd 2010-04-12 15:27:21 UTC
This should have been taken care of by:

2009-09-09  Jakub Jelinek  <jakub@redhat.com>

        * config/t-slibgcc-elf-ver (SHLIB_MAKE_SOLINK, SHLIB_INSTALL_SOLINK):
        New variables.
        (SHLIB_LINK, SHLIB_INSTALL): Use them.
        * config/t-slibgcc-libgcc: New file.
        * config.gcc (powerpc*-*-linux*, powerpc*-*-gnu*): Use it.

What does g++ -v say?
Comment 4 Nathan Froyd 2010-04-12 15:41:26 UTC
FWIW, I cannot reproduce with 'gcc version 4.5.0 20100205'.
Comment 5 marcus 2010-04-12 20:25:05 UTC
gcc version 4.5.0 20100331 (experimental) [trunk revision 157870] (SUSE Linux) 
Comment 6 Richard Biener 2010-04-13 12:34:10 UTC
I can reproduce it.

/tmp> g++ -Os -shared -o libhello.so -Wl,-z,defs -fPIC hello.c -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/powerpc64-suse-linux/4.5/lto-wrapper
Target: powerpc64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system-libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with-cpu=default32 --enable-secureplt --with-long-double-128 --build=powerpc64-suse-linux
Thread model: posix
gcc version 4.5.0 20100331 (experimental) [trunk revision 157870] (SUSE Linux) 
COLLECT_GCC_OPTIONS='-Os' '-shared' '-o' 'libhello.so' '-fPIC' '-v' '-shared-libgcc'
 /usr/lib/gcc/powerpc64-suse-linux/4.5/cc1plus -quiet -v -D_GNU_SOURCE -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix hello.c -msecure-plt -quiet -dumpbase hello.c -auxbase hello -Os -version -fPIC -o /tmp/ccwdek6v.s
GNU C++ (SUSE Linux) version 4.5.0 20100331 (experimental) [trunk revision 157870] (powerpc64-suse-linux)
        compiled by GNU C version 4.5.0 20100331 (experimental) [trunk revision 157870], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../powerpc64-suse-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.5
 /usr/include/c++/4.5/powerpc64-suse-linux
 /usr/include/c++/4.5/backward
 /usr/local/include
 /usr/lib/gcc/powerpc64-suse-linux/4.5/include
 /usr/lib/gcc/powerpc64-suse-linux/4.5/include-fixed
 /usr/include
End of search list.
GNU C++ (SUSE Linux) version 4.5.0 20100331 (experimental) [trunk revision 157870] (powerpc64-suse-linux)
        compiled by GNU C version 4.5.0 20100331 (experimental) [trunk revision 157870], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: bb776fa20ad0aa28b65c57db982d18c1
COLLECT_GCC_OPTIONS='-Os' '-shared' '-o' 'libhello.so' '-fPIC' '-v' '-shared-libgcc'
 as -a32 -K PIC -mppc -many -V -Qy -o /tmp/ccE5Vz4Y.o /tmp/ccwdek6v.s
GNU assembler version 2.20.0 (powerpc-suse-linux) using BFD version (GNU Binutils; openSUSE Factory) 2.20.0.20100122-4.7
COMPILER_PATH=/usr/lib/gcc/powerpc64-suse-linux/4.5/:/usr/lib/gcc/powerpc64-suse-linux/4.5/:/usr/lib/gcc/powerpc64-suse-linux/:/usr/lib/gcc/powerpc64-suse-linux/4.5/:/usr/lib/gcc/powerpc64-suse-linux/
LIBRARY_PATH=/usr/lib/gcc/powerpc64-suse-linux/4.5/:/usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/powerpc64-suse-linux/4.5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-Os' '-shared' '-o' 'libhello.so' '-fPIC' '-v' '-shared-libgcc'
 /usr/lib/gcc/powerpc64-suse-linux/4.5/collect2 --build-id --eh-frame-hdr -V -Qy -shared -m elf32ppclinux -o libhello.so /usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../lib/crti.o /usr/lib/gcc/powerpc64-suse-linux/4.5/crtbeginS.o -L/usr/lib/gcc/powerpc64-suse-linux/4.5 -L/usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/powerpc64-suse-linux/4.5/../../.. -z defs /tmp/ccE5Vz4Y.o -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/lib/gcc/powerpc64-suse-linux/4.5/crtendS.o /usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../lib/crtn.o
GNU ld (GNU Binutils; openSUSE Factory) 2.20.0.20100122-4.7
  Supported emulations:
   elf32ppclinux
   elf32ppc
   elf32ppcsim
   elf64ppc
   elf32_spu
/tmp/ccE5Vz4Y.o: In function `hello()':
hello.c:(.text+0x30): undefined reference to `_restgpr_30_x'
collect2: ld returned 1 exit status
Comment 7 Jakub Jelinek 2010-04-13 12:43:57 UTC
Is the libgcc_s.so the link finds a linker script?
You can use -Wl,-M,--verbose to see what is going on.
Comment 8 marcus 2010-04-13 14:08:43 UTC
$ file /usr/lib/gcc/powerpc64-suse-linux/4.5/libgcc_s.so
/usr/lib/gcc/powerpc64-suse-linux/4.5/libgcc_s.so: symbolic link to `/lib/libgcc_s.so.1'
$ file /lib/libgcc_s.so.1
/lib/libgcc_s.so.1: ELF 32-bit MSB shared object, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, with unknown capability 0x41000000 = 0x13676e75, with unknown capability 0x10000 = 0xb0401, stripped
$

(its from the gcc45 system compiler in opensuse Factory on ppc32 bit)
Comment 9 Richard Biener 2010-04-13 14:10:13 UTC
(In reply to comment #7)
> Is the libgcc_s.so the link finds a linker script?
> You can use -Wl,-M,--verbose to see what is going on.

No, it doesn't seem to.

START GROUP
LOAD /lib/libc.so.6
LOAD /usr/lib/libc_nonshared.a
LOAD /lib/ld.so.1
END GROUP
LOAD /usr/lib/gcc/powerpc64-suse-linux/4.5/libgcc_s.so
LOAD /usr/lib/gcc/powerpc64-suse-linux/4.5/crtendS.o
LOAD /usr/lib/gcc/powerpc64-suse-linux/4.5/../../../../lib/crtn.o

/tmp> ls -l /usr/lib/gcc/powerpc64-suse-linux/4.5/libgcc_s.so
lrwxrwxrwx 1 root root 18 2010-04-07 18:18 /usr/lib/gcc/powerpc64-suse-linux/4.5/libgcc_s.so -> /lib/libgcc_s.so.1

do we now install linker-scripts for libgcc_s.so?  If so I have to fixup our
install procedure as I am simply doing

# Move libgcc_s around
rm -f $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so
ln -sf /%{_lib}/libgcc_s.so.%{libgcc_s}$RPM_BUILD_ROOT{versmainlibdir}/libgcc_s.so

Comment 10 Jakub Jelinek 2010-04-13 14:18:40 UTC
Yes, we sometimes install linker scripts, sometimes symbolic links.
E.g. on powerpc64-linux, 32-bit libgcc_s.so is a linker script, while 64-bit libgcc_s.so is a symlink.
If you after install overwrite it with a symlink, it won't work properly.
Comment 11 Richard Biener 2010-04-13 14:30:56 UTC
So, my fault.