[gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain
Ian Lance Taylor
iant@golang.org
Fri Dec 12 19:52:00 GMT 2014
On Fri, Dec 12, 2014 at 10:49 AM, Richard Henderson <rth@redhat.com> wrote:
>
> Oh, that's interesting. You've found a bug in the x86_64 linking:
>
> gccgo -g3 -O3 -Wall -Werror -c -fPIC q.go -o q.o
> gccgo -shared -Wl,-soname,libq.so -o libq.so q.o
> gccgo -g3 -O3 -Wall -Werror -c -fPIC p.go -o p.o
> gccgo -shared -Wl,-soname,libp.so -o libp.so p.o
> gccgo -g3 -O3 -Wall -Werror -o main main.go libq.so libp.so
> /usr/bin/ld: main: hidden symbol `__morestack' in
> /usr/lib/gcc/x86_64-redhat-linux/4.8.3/libgcc.a(morestack.o) is referenced by DSO
> /usr/bin/ld: final link failed: Bad value
> collect2: error: ld returned 1 exit status
> make: *** [main] Error 1
>
> Sure enough, both shared libraries failed to pull __morestack
> from the static libgcc.
>
> $ nm libq.so | grep more
> U __morestack
>
> I guess __morestack is included in the wrong portion of libgcc?
My intent was that __morestack would be included in each shared
library that needs it, because going through a PLT stub to call
__morestack would blow out the stack. That is why the symbol is
hidden.
So we need to link against -lgcc. It looks like when I link with gcc
-shared it does link against -lgcc. When I link with gccgo -shared it
does not. I could not figure out why that it was in 30 seconds of
looking at the code.
Ian
More information about the Gcc-patches
mailing list