{"record":{"id":"b473ec58706f184d","repo":"golang/go","slug":"missing-dwarf-segment","errorCode":null,"errorMessage":"missing __DWARF segment","messagePattern":"missing __DWARF segment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/ld/macho_combine_dwarf.go","lineNumber":93,"sourceCode":"\n\t// The string table needs to be the last thing in the file\n\t// for code signing to work. So we'll need to move the\n\t// linkedit section, but all the others can be copied directly.\n\tlinkseg := exem.Segment(\"__LINKEDIT\")\n\tif linkseg == nil {\n\t\treturn fmt.Errorf(\"missing __LINKEDIT segment\")\n\t}\n\n\tif _, err := exef.Seek(0, 0); err != nil {\n\t\treturn err\n\t}\n\tif _, err := io.CopyN(outf, exef, int64(linkseg.Offset)); err != nil {\n\t\treturn err\n\t}\n\n\trealdwarf := dwarfm.Segment(\"__DWARF\")\n\tif realdwarf == nil {\n\t\treturn fmt.Errorf(\"missing __DWARF segment\")\n\t}\n\n\t// Try to compress the DWARF sections. This includes some Apple\n\t// proprietary sections like __apple_types.\n\tcompressedSects, compressedBytes, err := machoCompressSections(ctxt, dwarfm)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Now copy the dwarf data into the output.\n\t// Kernel requires all loaded segments to be page-aligned in the file,\n\t// even though we mark this one as being 0 bytes of virtual address space.\n\tdwarfstart := Rnd(int64(linkseg.Offset), *FlagRound)\n\tif _, err := outf.Seek(dwarfstart, 0); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := dwarff.Seek(int64(realdwarf.Offset), 0); err != nil {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/macho_combine_dwarf.go#L75-L111","documentation":"In the combine-DWARF flow, after opening the DWARF file (produced by `dsymutil`), the linker looks for a `__DWARF` segment to copy into the executable. If `dsymutil` produced no DWARF (e.g. it was run on a binary with no debug info, or failed silently and emitted an empty file), there is nothing to merge and the link aborts.","triggerScenarios":"The program was compiled without debug info (`-ldflags='-s -w'` or `-gcflags=-l` stripping) yet the combine-DWARF path was triggered; `dsymutil` ran on a pre-stripped binary; the DWARF file passed in is actually a different kind of Mach-O (e.g. the executable itself, by mistake).","commonSituations":"Build pipeline stripping debug info before/instead of `dsymutil`; misconfigured CI passing the wrong file to the combine step; building with `-trimpath` plus aggressive strip flags.","solutions":["Keep debug info through link (`-ldflags='-s -w'` must be removed if you want DWARF).","Ensure `dsymutil` runs on the unstripped binary and produces a `.dSYM` with a `__DWARF` segment (`dwarfdump --uuid out.dSYM`).","Pass the `.dSYM` DWARF file (not the executable) to the combine step."],"exampleFix":"# before: stripped binary yields no __DWARF in dSYM\ngo build -ldflags='-s -w' -o bin/app ./...\ndsymutil bin/app\n\n# after\ngo build -o bin/app ./...\ndsymutil bin/app -o bin/app.dSYM","handlingStrategy":"validation","validationCode":"# Confirm the dSYM has a __DWARF segment before combining\nDSYM=bin/app.dSYM/Contents/Resources/DWARF/app\ntest -f \"$DSYM\" && dwarfdump --uuid \"$DSYM\" >/dev/null 2>&1 && echo 'DWARF present' || echo 'no DWARF; rebuild without -s -w'","typeGuard":null,"tryCatchPattern":"# If DWARF combine fails, fall back to a stripped build\nset +e\ngo build -o bin/app ./...\nrc=$?\nset -e\nif [ $rc -ne 0 ]; then\n  echo 'DWARF combine failed; building stripped' >&2\n  go build -ldflags='-s -w' -o bin/app ./...\nfi","preventionTips":["Keep debug info (`-s -w` off) if you intend to combine DWARF.","Run `dsymutil` on the unstripped binary.","Pass the `.dSYM` DWARF file, not the executable, to combineDwarf."],"tags":["linker","go-toolchain","macos","dwarf","dsymutil"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}