From 1f325af4dd6c07f899da0a7c0512a7d470cebf9f Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Thu, 14 May 2020 12:16:10 -0400 Subject: [PATCH] cmd/link: fix SCONST symbol handling on darwin Don't include SCONST symbols in the symbol table when NotInSymbolTable is set. This is what the old code (genasmsym) does. In fact, SCONST symbol is only emitted by the field tracking code, and is always NotInSymbolTable. So we should just not include them at all, or not generate SCONST symbols at all. But at this late stage I'll just restore the old behavior. Change-Id: If6843003e16701d45b8c67b2297098a7babdec52 Reviewed-on: https://go-review.googlesource.com/c/go/+/233997 Run-TryBot: Cherry Zhang Reviewed-by: Jeremy Faller TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ld/macho.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index 4dc7f819eb4546..5548b8c6664c57 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -798,7 +798,7 @@ func collectmachosyms(ctxt *Link) { continue } t := ldr.SymType(s) - if t >= sym.SELFRXSECT && t < sym.SXREF { // data sections handled in dodata + if t >= sym.SELFRXSECT && t < sym.SXREF || t == sym.SCONST { // data sections handled in dodata if t == sym.STLSBSS { // TLSBSS is not used on darwin. See data.go:allocateDataSections continue @@ -810,7 +810,7 @@ func collectmachosyms(ctxt *Link) { } switch t { - case sym.SDYNIMPORT, sym.SHOSTOBJ, sym.SUNDEFEXT, sym.SCONST: + case sym.SDYNIMPORT, sym.SHOSTOBJ, sym.SUNDEFEXT: addsym(s) }