mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: handle multiple levels of overwrite
Revamp the way that symbol overwrites are handled to deal with symbols that are overwritten more than once (such as "_cgo_mmap"). The scenario here is that a symbol can be overwritten twice, once during preload, and then again when host objects are read during internal linking. This can result in a situation where we have two entries in the overwrite map, from X -> Y and then from Y -> Z. Rather than search the overwrite map when adding new entries, add a helper routine for querying the map that catches this situation and fixes it up. Also with this patch is a couple of tweaks to the loader.Dump method to insure that it can dump the entire global index space without crashing due to odd overwrites (as in the scenario above). Change-Id: Ib6c8a0e03e92fc2b57318001711b501eeaf12249 Reviewed-on: https://go-review.googlesource.com/c/go/+/212098 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
parent
49e94f19f0
commit
db48d45838
2 changed files with 81 additions and 17 deletions
|
|
@ -41,9 +41,7 @@ func (l *Loader) MakeSymbolUpdater(symIdx Sym) (*SymbolBuilder, Sym) {
|
|||
if symIdx == 0 {
|
||||
panic("can't update the null symbol")
|
||||
}
|
||||
if ov, ok := l.overwrite[symIdx]; ok {
|
||||
symIdx = ov
|
||||
}
|
||||
symIdx = l.getOverwrite(symIdx)
|
||||
if !l.IsExternal(symIdx) {
|
||||
// Create a clone with the same name/version/kind etc.
|
||||
symIdx = l.cloneToExternal(symIdx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue