]> Cypherpunks repositories - gostls13.git/commit
ld: weak symbols
authorRuss Cox <rsc@golang.org>
Thu, 24 Feb 2011 21:45:45 +0000 (16:45 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 24 Feb 2011 21:45:45 +0000 (16:45 -0500)
commitd94bf76239441a5a819043db37bde28f22e20621
treec3ac8b5c6332e97a9c6a457d669377aab8247881
parent4185a9e2b28f7ae29743f702d3b35fbc7edaebc6
ld: weak symbols

A reference to the address of weak.foo resolves at link time
to the address of the symbol foo if foo would end up in the
binary anyway, or to zero if foo would not be in the binary.

For example:

        int xxx = 1;
        int yyy = 2;
        int weak·xxx;
        int weak·yyy;

        void main·main(void) {
                runtime·printf("%p %p %p\n", &xxx, &weak·xxx, &weak·yyy);
        }

prints the same non-nil address twice, then 0 (because yyy is not
referenced so it was dropped from the binary).

This will be used by the reflection tables.

R=iant
CC=golang-dev
https://golang.org/cl/4223044
src/cmd/5l/obj.c
src/cmd/5l/pass.c
src/cmd/6l/obj.c
src/cmd/6l/pass.c
src/cmd/8l/obj.c
src/cmd/8l/pass.c
src/cmd/ld/go.c
src/cmd/ld/lib.c
src/cmd/ld/lib.h