mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: revise DLL import symbol handling
This patch reworks the handling of DLL import symbols in the PE host
object loader to ensure that the Go linker can deal with them properly
during internal linking.
Prior to this point the strategy was to immediately treat an import
symbol reference of the form "__imp__XXX" as if it were a reference to
the corresponding DYNIMPORT symbol XXX, except for certain special
cases. This worked for the most part, but ran into problems in
situations where the target ("XXX") wasn't a previously created
DYNIMPORT symbol (and when these problems happened, the root cause was
not always easy to see).
The new strategy is to not do any renaming or forwarding immediately,
but to delay handling until host object loading is complete. At that
point we make a scan through the newly introduced text+data sections
looking at the relocations that target import symbols, forwarding
the references to the corresponding DYNIMPORT sym where appropriate
and where there are direct refs to the DYNIMPORT syms, tagging them
for stub generation later on.
Updates #35006.
Updates #53540.
Change-Id: I2d42b39141ae150a9f82ecc334001749ae8a3b4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/451738
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
771a98d6b1
commit
cf93b25366
4 changed files with 263 additions and 46 deletions
|
|
@ -711,6 +711,13 @@ func loadWindowsHostArchives(ctxt *Link) {
|
|||
ctxt.loader.SetAttrSpecial(sb.Sym(), true)
|
||||
}
|
||||
}
|
||||
|
||||
// Fix up references to DLL import symbols now that we're done
|
||||
// pulling in new objects.
|
||||
if err := loadpe.PostProcessImports(); err != nil {
|
||||
Errorf(nil, "%v", err)
|
||||
}
|
||||
|
||||
// TODO: maybe do something similar to peimporteddlls to collect
|
||||
// all lib names and try link them all to final exe just like
|
||||
// libmingwex.a and libmingw32.a:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue