Skip to content

cmd/nm: bss symbols not correctly reported on linux/amd64 #77301

@egonelbre

Description

@egonelbre

Go version

go1.26rc2

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/egon/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/egon/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/1w/2x_sgq2j111d19xj1kpxkgp40000gn/T/go-build3668712380=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/egon/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/egon/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/egon/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.26rc2'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

package main

var globalUninitialized int64     // should be in BSS
var globalInitialized int64 = 42  // should be in DATA

func main() {
    println(globalUninitialized)
    println(globalInitialized)
}

What did you see happen?

∫ GOOS=linux GOARCH=amd64 go build -o example example.go && go tool nm example | grep main.global
  534490 D main.globalInitialized
  55d510 D main.globalUninitialized

What did you expect to see?

∫ nm --version
llvm-nm, compatible with GNU nm
Apple LLVM version 17.0.0
  Optimized build.

∫ nm example | grep main.global
0000000000534490 D main.globalInitialized
000000000055d510 B main.globalUninitialized

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions