Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(483)

Issue 4223044: code review 4223044: ld: weak symbols (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years ago by rsc
Modified:
14 years ago
Reviewers:
CC:
iant, golang-dev
Visibility:
Public.

Description

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.

Patch Set 1 #

Patch Set 2 : diff -r 5f0839c8649e https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r ef61c195edc3 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 4 : diff -r a73bab5de08d https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -36 lines) Patch
M src/cmd/5l/obj.c View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/5l/pass.c View 1 1 chunk +0 lines, -12 lines 0 comments Download
M src/cmd/6l/obj.c View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/6l/pass.c View 1 1 chunk +0 lines, -12 lines 0 comments Download
M src/cmd/8l/obj.c View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/8l/pass.c View 1 1 chunk +0 lines, -12 lines 0 comments Download
M src/cmd/ld/go.c View 1 2 chunks +31 lines, -0 lines 0 comments Download
M src/cmd/ld/lib.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M src/cmd/ld/lib.c View 1 2 1 chunk +12 lines, -0 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello iant (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
14 years ago (2011-02-24 05:49:47 UTC) #1
iant
LGTM http://codereview.appspot.com/4223044/diff/4001/src/cmd/ld/lib.h File src/cmd/ld/lib.h (right): http://codereview.appspot.com/4223044/diff/4001/src/cmd/ld/lib.h#newcode170 src/cmd/ld/lib.h:170: void undef(void); Should doweak be declared here as ...
14 years ago (2011-02-24 12:40:51 UTC) #2
rsc
On Thu, Feb 24, 2011 at 07:40, <iant@golang.org> wrote: > Should doweak be declared here ...
14 years ago (2011-02-24 21:43:36 UTC) #3
rsc
14 years ago (2011-02-24 21:45:51 UTC) #4
*** Submitted as http://code.google.com/p/go/source/detail?r=b0e4832734b3 ***

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
http://codereview.appspot.com/4223044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b