From: Cherry Zhang Date: Sat, 2 Nov 2019 21:25:39 +0000 (-0400) Subject: [dev.link] cmd/link: use the start of compilation unit for R_ADDRCUOFF X-Git-Tag: go1.14beta1~292^2^2~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ab4a71fca7de1db1fd30e9a6c6d96fc84f8fffa4;p=gostls13.git [dev.link] cmd/link: use the start of compilation unit for R_ADDRCUOFF R_ADDRCUOFF refers to the offset from the start of the compilation unit. Now that we could have multiple compilation units per package, we should use the start of the compilation unit, instead of the start of the package. Change-Id: I3d6a3c5a5c47c9ccf88091ed05413ced826f9934 Reviewed-on: https://go-review.googlesource.com/c/go/+/204828 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index ea238f7916..2cf4c726da 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -402,7 +402,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) { case objabi.R_ADDRCUOFF: // debug_range and debug_loc elements use this relocation type to get an // offset from the start of the compile unit. - o = Symaddr(r.Sym) + r.Add - Symaddr(r.Sym.Unit.Lib.Textp[0]) + o = Symaddr(r.Sym) + r.Add - Symaddr(r.Sym.Unit.Textp[0]) // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call. case objabi.R_GOTPCREL: