go-delve/delve · error

found section but could not read .gopclntab

Error message

found section but could not read .gopclntab

What it means

The .gopclntab section exists in the ELF file, but reading its bytes (section.Data()) failed. This usually means the section header is valid but the referenced bytes are truncated, outside the file, or the file is corrupted.

Source

Thrown at pkg/proc/pclntab.go:27

	"github.com/go-delve/delve/pkg/internal/gosym"
)

func readPcLnTableElf(exe *elf.File, path string) (*gosym.Table, uint64, error) {
	// Default section label is .gopclntab
	sectionLabel := ".gopclntab"

	section := exe.Section(sectionLabel)
	if section == nil {
		// binary may be built with -pie
		sectionLabel = ".data.rel.ro.gopclntab"
		section = exe.Section(sectionLabel)
		if section == nil {
			return nil, 0, errors.New("could not read section .gopclntab")
		}
	}
	tableData, err := section.Data()
	if err != nil {
		return nil, 0, errors.New("found section but could not read .gopclntab")
	}

	addr := exe.Section(".text").Addr
	lineTable := gosym.NewLineTable(tableData, addr)
	symTable, err := gosym.NewTable([]byte{}, lineTable)
	if err != nil {
		return nil, 0, fmt.Errorf("could not create symbol table from  %s ", path)
	}
	return symTable, section.Addr, nil
}

func readPcLnTableMacho(exe *macho.File, path string) (*gosym.Table, uint64, error) {
	// Default section label is __gopclntab
	sectionLabel := "__gopclntab"

	section := exe.Section(sectionLabel)
	if section == nil {
		return nil, 0, errors.New("could not read section __gopclntab")

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Re-obtain or rebuild the binary and compare checksums against the original artifact
  2. Check the file size matches the build output (truncated transfer)
  3. Remove any post-processing (packers, obfuscators, section rewriting)
  4. Open the file with readelf -S to confirm .gopclntab has a valid offset/size in the file

Example fix

// before
dlv exec ./corrupted-binary
// after
go build -o app . && dlv exec ./app // rebuild from a known-good source
Defensive patterns

Strategy: validation

Validate before calling

fi, err := os.Stat(path)
if err != nil || fi.Size() == 0 {
    return fmt.Errorf("binary missing or empty: %s", path)
}
// optionally compare against a known checksum

Try / catch

if err != nil && strings.Contains(err.Error(), "found section but could not read .gopclntab") {
    return fmt.Errorf("binary file appears corrupted/truncated: %w", err)
}

Prevention

When it happens

Trigger: loadBinaryInfoGoRuntimeElf -> readPcLnTableElf on a truncated or corrupted ELF file, a file modified after build, or exotic section types/offsets that debug/elf cannot map to file bytes.

Common situations: Partially downloaded or copied binaries; core/debug artifacts from broken packaging pipelines; binaries post-processed by obfuscators or packers that rewrite sections.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/d89a31e450a3c53d. Report an issue: GitHub.