diff options
| author | Cherry Mui <cherryyz@google.com> | 2024-12-12 14:31:45 -0500 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2024-12-12 12:58:47 -0800 |
| commit | 14e5093ee56c7e3a807c8924fd2d425cd2b0f376 (patch) | |
| tree | cc8a7f0bb8a752b17d85b63217708d8179d1e53c /src/cmd/internal/obj | |
| parent | fb764cdad03ae2e500100b691f77cbd0d22b7d9c (diff) | |
| download | go-14e5093ee56c7e3a807c8924fd2d425cd2b0f376.tar.xz | |
cmd/internal/obj: disallow linknamed access to builtin symbols
Currently, a symbol reference is counted as a reference to a
builtin symbol if the name matches a builtin. Usually builtin
references are generated by the compiler. But one could manually
write one with linkname. Since the list of builtin functions are
subject to change from time to time, we don't want users to depend
on their names. So we don't count a linknamed reference as a
builtin reference, and instead, count it as a named reference, so
it is checked by the linker.
Change-Id: Id3543295185c6bbd73a8cff82afb8f9cb4fd6f71
Reviewed-on: https://go-review.googlesource.com/c/go/+/635755
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/internal/obj')
| -rw-r--r-- | src/cmd/internal/obj/sym.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go index 4feccf54f6..8872579050 100644 --- a/src/cmd/internal/obj/sym.go +++ b/src/cmd/internal/obj/sym.go @@ -320,7 +320,7 @@ func (ctxt *Link) NumberSyms() { // Assign special index for builtin symbols. // Don't do it when linking against shared libraries, as the runtime // may be in a different library. - if i := goobj.BuiltinIdx(rs.Name, int(rs.ABI())); i != -1 { + if i := goobj.BuiltinIdx(rs.Name, int(rs.ABI())); i != -1 && !rs.IsLinkname() { rs.PkgIdx = goobj.PkgIdxBuiltin rs.SymIdx = int32(i) rs.Set(AttrIndexed, true) |
