diff options
| author | Than McIntosh <thanm@google.com> | 2020-04-23 08:43:29 -0400 |
|---|---|---|
| committer | Than McIntosh <thanm@google.com> | 2020-04-24 13:41:20 +0000 |
| commit | adea6a90e361629d20a68400c0c5cdcdfcdf087e (patch) | |
| tree | 3bb047463ea68862153175c3b8cb6c05bccd39e3 /src/cmd/link/internal/loader/loader.go | |
| parent | 67bf856b962731965f7e9a75e6bede62fee1a4da (diff) | |
| download | go-adea6a90e361629d20a68400c0c5cdcdfcdf087e.tar.xz | |
[dev.link] cmd/link/internal/loader: fix buglet in section handling
Allow for the possibility that a client could call newExtSym(), then
ask for the section of the new sym before SetSectSym is called on it
(check in SymSect for this case).
Change-Id: I7bd78e7b3b7618943705b616f62ea78c4a1b68d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229603
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/cmd/link/internal/loader/loader.go')
| -rw-r--r-- | src/cmd/link/internal/loader/loader.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 987feeb284..ba0cff3ff6 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -1075,6 +1075,12 @@ func (l *Loader) SetSymAlign(i Sym, align int32) { // SymValue returns the section of the i-th symbol. i is global index. func (l *Loader) SymSect(i Sym) *sym.Section { + if int(i) >= len(l.symSects) { + // symSects is extended lazily -- it the sym in question is + // outside the range of the existing slice, then we assume its + // section has not yet been set. + return nil + } return l.sects[l.symSects[i]] } |
