diff options
| author | Cherry Zhang <cherryyz@google.com> | 2019-10-31 19:35:55 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2019-11-01 03:40:20 +0000 |
| commit | 4a43a5079184f9a4cff355fbf8c6d3145e253bb2 (patch) | |
| tree | 3d014f2da068b9fe6230d676f739bfc330b74d9c /src/cmd | |
| parent | 396a9b98bac38dce31085146f8c713fbe3c0c664 (diff) | |
| download | go-4a43a5079184f9a4cff355fbf8c6d3145e253bb2.tar.xz | |
[dev.link] cmd/link: process cgo_import_static before host object loading
In internal linking mode, we need to process cgo_import_static
directives before loading host objects, because the directive is
to tell the host object loader how to deal with imported symbols.
This should fix linking with old object files. I think there
needs some similar logic for new object files, but I'll leave
that for later.
Change-Id: Icaa286de626ea1876086dbdd015047084c92caf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/204697
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/link/internal/ld/lib.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 679d44e8dd..b882df29a1 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -443,20 +443,6 @@ func (ctxt *Link) loadlib() { } } - // Conditionally load host objects, or setup for external linking. - hostobjs(ctxt) - hostlinksetup(ctxt) - - if *flagNewobj { - // Add references of externally defined symbols. - ctxt.loader.LoadRefs(ctxt.Arch, ctxt.Syms) - } - - // Now that we know the link mode, set the dynexp list. - if !*flagNewobj { // set this later in newobj mode - setupdynexp(ctxt) - } - if ctxt.LinkMode == LinkInternal && len(hostobj) != 0 { // Drop all the cgo_import_static declarations. // Turns out we won't be needing them. @@ -473,7 +459,23 @@ func (ctxt *Link) loadlib() { } } } + } + // Conditionally load host objects, or setup for external linking. + hostobjs(ctxt) + hostlinksetup(ctxt) + + if *flagNewobj { + // Add references of externally defined symbols. + ctxt.loader.LoadRefs(ctxt.Arch, ctxt.Syms) + } + + // Now that we know the link mode, set the dynexp list. + if !*flagNewobj { // set this later in newobj mode + setupdynexp(ctxt) + } + + if ctxt.LinkMode == LinkInternal && len(hostobj) != 0 { // If we have any undefined symbols in external // objects, try to read them from the libgcc file. any := false |
