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



             Bug #: 56431

           Summary: -lpthread should be added to -lgo

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: go

        AssignedTo: i...@airs.com

        ReportedBy: hjl.to...@gmail.com

        Depends on: 56353





+++ This bug was initially created as a clone of Bug #56353 +++



libjava.jni/invocation/PR16923.c behaves differently, depending

on linking with gold or ld. _Jv_RegisterClasses is weak reference

and libgcj.so isn't on the linker command line. Since libgcj.so isn't

on the linker command line, gold resolves _Jv_RegisterClasses to 0 and

ld silently resolves it to _Jv_RegisterClasses in libgcj.so:



[hjl@gnu-13 testsuite]$ readelf -sWr /tmp/PR16923.gold | grep

_Jv_RegisterClasses 

     8: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses

    37: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses

[hjl@gnu-13 testsuite]$ readelf -sWr /tmp/PR16923.bfd | grep

_Jv_RegisterClasses 

0000000000600cd0  0000000900000007 R_X86_64_JUMP_SLOT     00000000004005e0

_Jv_RegisterClasses + 0

     9: 00000000004005e0     0 FUNC    WEAK   DEFAULT  UND _Jv_RegisterClasses

    59: 00000000004005e0     0 FUNC    WEAK   DEFAULT  UND _Jv_RegisterClasses

[hjl@gnu-13 testsuite]$]



-lgo has the same issue.  With the bfd linker, I got



[hjl@gnu-mic-2 go]$ ld --eh-frame-hdr -m elf_i386 -dynamic-linker

/lib/ld-linux.so.2 /lib/../lib/crt1.o /lib/../lib/crti.o

/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/go/../../32/crtbegin.o

-L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libgo

-L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libgo/.libs

-L/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/go/../../32

-L/lib/../lib -L/usr/lib/../lib

-L/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/go/../..

array-1.o -lgobegin -lgo -lm --wrap=pthread_create -lgcc_s -lgcc -lc -lgcc_s

-lgcc

/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/go/../../32/crtend.o

/lib/../lib/crtn.o

ld:

/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/go/../../32/libgcc.a(generic-morestack.o):

undefined reference to symbol 'pthread_sigmask@@GLIBC_2.0'

ld: note: 'pthread_sigmask@@GLIBC_2.0' is defined in DSO /lib/libpthread.so.0

so try adding it to the linker command line

/lib/libpthread.so.0: could not read symbols: Invalid operation

[hjl@gnu-mic-2 go]$ 



gold links, but it generates



    51: 00000000     0 NOTYPE  WEAK   DEFAULT  UND pthread_sigmask



It means that go executables generated by bfd ld and gold may behave

differently.  Go driver should add -lpthread to -lgo if libgo.so is

linked against libpthread.so.

Reply via email to