{"record":{"id":"0639e8820375b690","repo":"golang/go","slug":"unknown-load-command-0x-x-s","errorCode":null,"errorMessage":"unknown load command 0x%x (%s)","messagePattern":"unknown load command 0x%x \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/ld/macho_combine_dwarf.go","lineNumber":213,"sourceCode":"\t\tcase imacho.LC_UUID:\n\t\t\tvar u uuidCmd\n\t\t\terr = reader.ReadAt(0, &u)\n\t\t\tif err == nil && len(buildinfo) > 0 {\n\t\t\t\tclear(u.Uuid[:])\n\t\t\t\tcopy(u.Uuid[:], buildinfo)\n\t\t\t\terr = reader.WriteAt(0, &u)\n\t\t\t}\n\t\tcase macho.LoadCmdDylib, macho.LoadCmdThread, macho.LoadCmdUnixThread,\n\t\t\timacho.LC_PREBOUND_DYLIB, imacho.LC_VERSION_MIN_MACOSX, imacho.LC_VERSION_MIN_IPHONEOS, imacho.LC_SOURCE_VERSION,\n\t\t\timacho.LC_MAIN, imacho.LC_LOAD_DYLINKER, imacho.LC_LOAD_WEAK_DYLIB, imacho.LC_REEXPORT_DYLIB, imacho.LC_RPATH, imacho.LC_ID_DYLIB,\n\t\t\timacho.LC_SYMSEG, imacho.LC_LOADFVMLIB, imacho.LC_IDFVMLIB, imacho.LC_IDENT, imacho.LC_FVMFILE, imacho.LC_PREPAGE, imacho.LC_ID_DYLINKER,\n\t\t\timacho.LC_ROUTINES, imacho.LC_SUB_FRAMEWORK, imacho.LC_SUB_UMBRELLA, imacho.LC_SUB_CLIENT, imacho.LC_SUB_LIBRARY, imacho.LC_TWOLEVEL_HINTS,\n\t\t\timacho.LC_PREBIND_CKSUM, imacho.LC_ROUTINES_64, imacho.LC_LAZY_LOAD_DYLIB, imacho.LC_LOAD_UPWARD_DYLIB, imacho.LC_DYLD_ENVIRONMENT,\n\t\t\timacho.LC_LINKER_OPTION, imacho.LC_LINKER_OPTIMIZATION_HINT, imacho.LC_VERSION_MIN_TVOS, imacho.LC_VERSION_MIN_WATCHOS,\n\t\t\timacho.LC_VERSION_NOTE, imacho.LC_BUILD_VERSION:\n\t\t\t// Nothing to update\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"unknown load command 0x%x (%s)\", int(cmd.Cmd), cmd.Cmd)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t// Do the final update of the DWARF segment's load command.\n\treturn machoUpdateDwarfHeader(&reader, compressedSects, dwarfsize, dwarfstart, realdwarf)\n}\n\n// machoCompressSections tries to compress the DWARF segments in dwarfm,\n// returning the updated sections and segment contents, nils if the sections\n// weren't compressed, or an error if there was a problem reading dwarfm.\nfunc machoCompressSections(ctxt *Link, dwarfm *macho.File) ([]*macho.Section, []byte, error) {\n\tif !ctxt.compressDWARF {\n\t\treturn nil, nil, nil\n\t}\n\n\tdwarfseg := dwarfm.Segment(\"__DWARF\")","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/macho_combine_dwarf.go#L195-L231","documentation":"While rewriting load commands during DWARF combination, the linker walks every load command to adjust offsets. It has a hardcoded set of known command types (LC_SEGMENT, LC_SYMTAB, LC_DYLD_INFO, LC_VERSION_MIN_*, LC_BUILD_VERSION, the many LC_*_DYLIB variants, etc.). Any command not in that set is rejected, because the linker cannot safely relocate an unknown command's offsets and would corrupt the binary.","triggerScenarios":"Linking on a newer macOS/Xcode whose `ld` emits a load command the Go toolchain version predates (e.g. a new LC_* added after the Go release); combining DWARF into a binary produced by a non-Go, non-Apple toolchain that emits uncommon commands; a binary post-processed by a tool that injected a custom load command.","commonSituations":"Using the latest Xcode/macOS with an older Go release; mixing toolchains in a monorepo; building for a newer Apple platform (visionOS, etc.) before Go added support.","solutions":["Upgrade the Go toolchain to a release that supports your macOS/Xcode load commands.","Downgrade/lock the Xcode SDK to one supported by your Go version (`xcode-select`).","Avoid combining DWARF (`-ldflags='-s -w'`) if you cannot upgrade Go, since the unknown command is only hit in that path.","If you injected custom load commands via a post-processor, remove them before combineDwarf."],"exampleFix":"# before: older Go meets newer Xcode load commands\ngo1.20 build -o bin/app ./...\n\n# after: use a Go release that knows the new LC_* commands\ngo1.22 build -o bin/app ./...","handlingStrategy":"fallback","validationCode":"# Check for load commands the current Go may not know\notool -l bin/app | grep -oE 'LC_[A-Z_]+' | sort -u\n# Compare against the list in macho_combine_dwarf.go to spot unknown ones","typeGuard":null,"tryCatchPattern":"# Fall back to a stripped build (skipping combineDwarf) on unknown LC\nset +e\ngo build -o bin/app ./...\nrc=$?\nset -e\nif [ $rc -ne 0 ]; then\n  echo 'unknown load command; building stripped' >&2\n  go build -ldflags='-s -w' -o bin/app ./...\nfi","preventionTips":["Keep the Go toolchain at least as new as your Xcode/macOS.","Lock the Xcode SDK via `xcode-select` to a version Go supports.","Strip DWARF for release builds to avoid the combine path.","Do not inject custom load commands before combineDwarf."],"tags":["linker","go-toolchain","macos","dwarf","load-command","version-skew"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}