From 508cb32d4be3f71f2975ee978a474eb7d95d868a Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 6 May 2022 16:05:06 -0400 Subject: [PATCH] cmd/link: more cleanups for visibility hidden symbol handling CL 404296 removes the hidden visibility checks, but a few of them were left. Remove them as well. Change-Id: Idbcf37429709c91403803d32684239d398e43543 Reviewed-on: https://go-review.googlesource.com/c/go/+/404303 TryBot-Result: Gopher Robot Run-TryBot: Cherry Mui Reviewed-by: Than McIntosh --- src/cmd/link/internal/ld/data.go | 2 +- src/cmd/link/internal/s390x/asm.go | 4 +--- src/cmd/link/internal/x86/asm.go | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 8d1a81ed1d..0e16fe5495 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -215,7 +215,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) { rst = ldr.SymType(rs) } - if rs != 0 && ((rst == sym.Sxxx && !ldr.AttrVisibilityHidden(rs)) || rst == sym.SXREF) { + if rs != 0 && (rst == sym.Sxxx || rst == sym.SXREF) { // When putting the runtime but not main into a shared library // these symbols are undefined and that's OK. if target.IsShared() || target.IsPlugin() { diff --git a/src/cmd/link/internal/s390x/asm.go b/src/cmd/link/internal/s390x/asm.go index f26b3f3cf2..482b3c8e69 100644 --- a/src/cmd/link/internal/s390x/asm.go +++ b/src/cmd/link/internal/s390x/asm.go @@ -111,9 +111,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade if targType == sym.SDYNIMPORT { ldr.Errorf(s, "unexpected R_390_PCnn relocation for dynamic symbol %s", ldr.SymName(targ)) } - // TODO(mwhudson): the test of VisibilityHidden here probably doesn't make - // sense and should be removed when someone has thought about it properly. - if (targType == 0 || targType == sym.SXREF) && !ldr.AttrVisibilityHidden(targ) { + if targType == 0 || targType == sym.SXREF { ldr.Errorf(s, "unknown symbol %s in pcrel", ldr.SymName(targ)) } su := ldr.MakeSymbolUpdater(s) diff --git a/src/cmd/link/internal/x86/asm.go b/src/cmd/link/internal/x86/asm.go index 5f6bcfb8b1..3a33201fd9 100644 --- a/src/cmd/link/internal/x86/asm.go +++ b/src/cmd/link/internal/x86/asm.go @@ -147,9 +147,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade if targType == sym.SDYNIMPORT { ldr.Errorf(s, "unexpected R_386_PC32 relocation for dynamic symbol %s", ldr.SymName(targ)) } - // TODO(mwhudson): the test of VisibilityHidden here probably doesn't make - // sense and should be removed when someone has thought about it properly. - if (targType == 0 || targType == sym.SXREF) && !ldr.AttrVisibilityHidden(targ) { + if targType == 0 || targType == sym.SXREF { ldr.Errorf(s, "unknown symbol %s in pcrel", ldr.SymName(targ)) } su := ldr.MakeSymbolUpdater(s)