{"record":{"id":"246f8dbdb089bc1f","repo":"go-delve/delve","slug":"malformed-executable","errorCode":null,"errorMessage":"malformed executable","messagePattern":"malformed executable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/bininfo.go","lineNumber":1385,"sourceCode":"\t\treturn [][2]uint64{{0, ^uint64(0)}}, nil\n\t}\n\n\toff, ok := a.(int64)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"attribute %s of unsupported type %T\", attr, a)\n\t}\n\tcu := bi.Images[0].findCompileUnitForOffset(entry.Offset)\n\tif cu == nil {\n\t\treturn nil, errors.New(\"could not find compile unit\")\n\t}\n\tif cu.Version >= 5 && cu.image.loclist5 != nil {\n\t\treturn nil, errors.New(\"LocationCovers does not support DWARFv5\")\n\t}\n\n\timage := cu.image\n\tbase := cu.lowPC\n\tif image == nil || image.loclist2.Empty() {\n\t\treturn nil, errors.New(\"malformed executable\")\n\t}\n\n\tr := [][2]uint64{}\n\tvar e loclist.Entry\n\timage.loclist2.Seek(int(off))\n\tfor image.loclist2.Next(&e) {\n\t\tif e.BaseAddressSelection() {\n\t\t\tbase = e.HighPC\n\t\t\tcontinue\n\t\t}\n\t\tr = append(r, [2]uint64{e.LowPC + base, e.HighPC + base})\n\t}\n\treturn r, nil\n}\n\n// Location returns the location described by attribute attr of entry.\n// This will either be an int64 address or a slice of Pieces for locations\n// that don't correspond to a single memory address (registers, composite","sourceCodeStart":1367,"sourceCodeEnd":1403,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/bininfo.go#L1367-L1403","documentation":"After resolving the compile unit for a location entry, LocationCovers reads the legacy .debug_loc list through image.loclist2. If the image is nil or its loclist2 reader is empty there is no location list data to walk, so Delve reports the executable as malformed. This catches images whose DIEs reference loclists that don't exist.","triggerScenarios":"A DWARF DIE references a .debug_loc offset but the image has an empty/missing .debug_loc section; partially stripped binaries where sections were removed but DIE references remain.","commonSituations":"Aggressively stripped or section-trimmed binaries (strip removing .debug_loc only); corrupted downloads of executables; custom build pipelines that drop sections post-link.","solutions":["Rebuild or re-obtain the binary with complete DWARF sections","Run readelf -S / objdump --dwarf=loc to verify .debug_loc is present and non-empty","Keep the separate debug file together with the stripped binary (debuglink must resolve)","Re-download the binary if it was corrupted in transit"],"exampleFix":"// before\nstrip --strip-debug -o app app   // may leave dangling loclist refs\n// after\nobjcopy --only-keep-debug app app.debug && strip app && objcopy --add-gnu-debuglink=app.debug app","handlingStrategy":"validation","validationCode":"func hasLoclistData(ef *elf.File) bool {\n    s := ef.Section(\".debug_loc\")\n    return s != nil && s.Size > 0\n}","typeGuard":null,"tryCatchPattern":"if ranges, err := LocationCovers(...); err != nil && err.Error() == \"malformed executable\" {\n    // verify/recover the binary: re-download or reinstall debug file\n}","preventionTips":["Verify .debug_loc exists with readelf -S before symbolizing","Use objcopy --add-gnu-debuglink instead of stripping sections in place","Checksum-verify binaries after transfer"],"tags":["dwarf","elf","malformed","loclists"],"backgroundTag":"malformed-executable","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}