go-delve/delve · error
malformed executable
Error message
malformed executable
What it means
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.
Source
Thrown at pkg/proc/bininfo.go:1385
return [][2]uint64{{0, ^uint64(0)}}, nil
}
off, ok := a.(int64)
if !ok {
return nil, fmt.Errorf("attribute %s of unsupported type %T", attr, a)
}
cu := bi.Images[0].findCompileUnitForOffset(entry.Offset)
if cu == nil {
return nil, errors.New("could not find compile unit")
}
if cu.Version >= 5 && cu.image.loclist5 != nil {
return nil, errors.New("LocationCovers does not support DWARFv5")
}
image := cu.image
base := cu.lowPC
if image == nil || image.loclist2.Empty() {
return nil, errors.New("malformed executable")
}
r := [][2]uint64{}
var e loclist.Entry
image.loclist2.Seek(int(off))
for image.loclist2.Next(&e) {
if e.BaseAddressSelection() {
base = e.HighPC
continue
}
r = append(r, [2]uint64{e.LowPC + base, e.HighPC + base})
}
return r, nil
}
// Location returns the location described by attribute attr of entry.
// This will either be an int64 address or a slice of Pieces for locations
// that don't correspond to a single memory address (registers, compositeView on GitHub (pinned to a23773e6c3)
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
Example fix
// before strip --strip-debug -o app app // may leave dangling loclist refs // after objcopy --only-keep-debug app app.debug && strip app && objcopy --add-gnu-debuglink=app.debug app
Defensive patterns
Strategy: validation
Validate before calling
func hasLoclistData(ef *elf.File) bool {
s := ef.Section(".debug_loc")
return s != nil && s.Size > 0
} Try / catch
if ranges, err := LocationCovers(...); err != nil && err.Error() == "malformed executable" {
// verify/recover the binary: re-download or reinstall debug file
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Aggressively stripped or section-trimmed binaries (strip removing .debug_loc only); corrupted downloads of executables; custom build pipelines that drop sections post-link.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- ErrNoDebugInfoFound
- LocationCovers does not support DWARFv5
- could not read debug info (%v) and could not read go symbol
- ErrStackUnderflow
- ErrStackIndexOutOfBounds
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/246f8dbdb089bc1f.
Report an issue: GitHub.