Apple's linker warns about a malformed LC_DYSYMTAB in a Go build
Your error
ld: warning: '/private/var/folders/.../T/go-link-876362130/go.o' has malformed LC_DYSYMTAB, expected 152 undefined symbols to start at index 168240, found 170 undefined symbols starting at index 1351 more line it can showFix it fast
Most common cause, 1 of 3go.o is named: a Go release from before the ld-prime fixes
Install a supported Go release from the downloads page (1.27.4 or 1.26.11 at the time of writing) and build again.
# after installing Go from https://go.dev/dl/
go version
go build -o app .Short answer
ld: warning: has malformed LC_DYSYMTAB comes from Apple's newer linker, the default since Xcode 15, reading an object Go handed it. It is only a warning; the binary works. A file named go.o means an outdated Go; a numbered 0000NN.o under -race is the race detector runtime, fixed in Go 1.26. Upgrade to Go 1.26.11 or 1.27.4.
Which cause do you have?
Print the Go version, then rerun the build or test that showed the warning and keep only the object name. The Go team sorts this warning by that name: go.o, or a six-digit numbered object with and without -race.
go version
go test -race ./... 2>&1 | grep -o "[^/]*\.o' has malformed LC_DYSYMTAB"Then find the line you see in this list and open its fix:
- 1go.o is named: a Go release from before the ld-prime fixes
The warned file is go.o, and go version shows a release that is no longer supported - 2A numbered object under -race: the race detector runtime on Go 1.22 to 1.25
The object is 0000NN.o and the line disappears when you drop -race - 3A numbered object without -race: C code your own package compiles
Normal builds show the warning on a 0000NN.o file, and the package uses cgo
What does the error look like?
ld: warning: '/private/var/folders/.../T/go-link-876362130/go.o' has malformed LC_DYSYMTAB, expected 152 undefined symbols to start at index 168240, found 170 undefined symbols starting at index 135ld: warning: '/private/var/folders/.../T/go-link-715828973/000034.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
Cause 1 of 3
go.o is named: a Go release from before the ld-prime fixes
You seeThe warned file is go.o, and go version shows a release that is no longer supported
Check
When the malformed LC_DYSYMTAB warning names go.o, the object came from the Go linker itself. Go changed cmd/link to stop writing a DYSYMTAB for external linking on Mach-O and backported it, so a current release should never print this line for go.o.
go versionFix
Install a supported Go release from the downloads page (1.27.4 or 1.26.11 at the time of writing) and build again. Nothing in your code needs to change.
# after installing Go from https://go.dev/dl/
go version
go build -o app .Verify
go version prints go1.26 or go1.27 and the build log no longer mentions LC_DYSYMTAB.
go build -o app . 2>&1 | grep -c LC_DYSYMTABConfirmed by github.com
Cause 2 of 3
A numbered object under -race: the race detector runtime on Go 1.22 to 1.25
You seeThe object is 0000NN.o and the line disappears when you drop -race
Check
With -race, a numbered object in this warning is usually ThreadSanitizer's C code that Go links into the test binary, not yours. The Go team traced it to assembler aliases in LLVM's sanitizer sources that leave undefined symbols carrying values, which ld-prime dislikes. Go 1.22 through 1.25 ship that object.
go test ./... 2>&1 | grep -c LC_DYSYMTABFix
Use Go 1.26 or newer, where the race object is passed through ld -r to drop the unneeded LC_DYSYMTAB. Stuck on an older Go for a while? The warning does no harm, and you can let Go's own linker do the whole link for that run, though it is not guaranteed to handle every C object.
go test -race ./...
# older Go only:
go test -race -ldflags=-linkmode=internal ./...Verify
go test -race completes and prints no malformed LC_DYSYMTAB line.
Confirmed by github.com
Cause 3 of 3
A numbered object without -race: C code your own package compiles
You seeNormal builds show the warning on a 0000NN.o file, and the package uses cgo
Check
Once a package contains C code, Go hands the final link to Apple's linker, which reads every C object. A numbered object outside -race builds comes from the project's C sources or a library they pull in. The Go team states the output binary is correct and the line is only a warning.
Fix
Ship the binary as it is and make sure the IDE or CI does not treat linker warnings as failures; the Go team says an IDE should not do that by default. To hide the line, pass -w to the external linker, which also silences every other warning that linker prints.
go build -ldflags=-extldflags=-Wl,-w -o app .Verify
The build log is clean and the binary behaves exactly as before.
Confirmed by github.com
How do I stop it coming back?
- Pin CI to Go 1.26 or later and raise it with each new minor release, so an old runner image cannot bring the go.o case back.
- Set build log parsers to fail on ld errors and non-zero exits only, not on lines starting with ld: warning.
- If you add -extldflags=-Wl,-w, keep it on the one target that needs it and leave a comment, because it also hides warnings you would want to see.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.