go-delve/delve · error

could not read section __gopclntab

Error message

could not read section __gopclntab

What it means

readPcLnTableMacho cannot find the __gopclntab section in a macOS Mach-O binary. Unlike the ELF path, there is no fallback section name. Delve requires this section to build the gosym line table for Go runtime symbolization.

Source

Thrown at pkg/proc/pclntab.go:45

		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")
	}
	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
}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Verify the target is a Go binary (go version -m <binary>)
  2. Rebuild without stripping pclntab (avoid objcopy/strip on Go macOS binaries)
  3. Check that you are debugging the correct architecture slice of a fat binary
  4. Use a delve version matching your Go toolchain version

Example fix

// before
strip app && dlv exec app
// after
go build -o app . && dlv exec app
Defensive patterns

Strategy: validation

Validate before calling

out, _ := exec.Command("go", "version", "-m", binaryPath).Output()
if !strings.Contains(string(out), "go") {
    return fmt.Errorf("%s is not a Go binary", binaryPath)
}

Try / catch

if err != nil && strings.Contains(err.Error(), "could not read section __gopclntab") {
    return fmt.Errorf("not a Go-built Mach-O binary (or pclntab stripped): %w", err)
}

Prevention

When it happens

Trigger: Opening a Mach-O binary via loadBinaryInfoGoRuntimeMacho that lacks __gopclntab — non-Go binaries, stripped Go binaries, or Go binaries built with toolchains that place pclntab elsewhere.

Common situations: Debugging a C/C++ macOS executable; a Go binary stripped of its pclntab; universal/fat binaries handled by extracting the wrong slice; third-party signed/re-signed app bundles that altered sections.

Related errors


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