go-delve/delve · error

architecture mismatch between core file (%#x) and…

Error message

architecture mismatch between core file (%#x) and executable file (%#x)

What it means

After parsing the core, readLinuxOrPlatformIndependentCore opens the executable ELF and compares e_machine with the core's machine type. A mismatch (e.g. arm64 core with amd64 executable) makes register/memory interpretation impossible, so loading fails with both machine values reported in hex.

Solutions

  1. Provide the executable built for the same GOARCH as the core (compare with 'file core' and 'file exe').
  2. Cross-compile the matching binary: GOARCH=<core arch> go build and rerun.
  3. Run delve itself on/for the matching architecture.
  4. Verify with 'readelf -h': Machine fields of both files must match.

Example fix

// before
GOOS=linux GOARCH=amd64 go build -o app .  # core is arm64
// after
GOOS=linux GOARCH=arm64 go build -o app .  # matches core architecture
Defensive patterns

Strategy: validation

Validate before calling

coreELF, _ := elf.Open(corePath)
exeELF, _ := elf.Open(exePath)
if coreELF.Machine != exeELF.Machine {
	return fmt.Errorf("arch mismatch: core=%v exe=%v", coreELF.Machine, exeELF.Machine)
}

Type guard

func archMatches(corePath, exePath string) bool {
	c, err1 := elf.Open(corePath)
	if err1 != nil { return false }
	defer c.Close()
	e, err2 := elf.Open(exePath)
	if err2 != nil { return false }
	defer e.Close()
	return c.Machine == e.Machine
}

Try / catch

p, err := core.ReadFile(exePath, corePath)
if err != nil && strings.Contains(err.Error(), "architecture mismatch") {
	return fmt.Errorf("rebuild the exe for the core's GOARCH (see 'readelf -h <core>')")
}

Prevention

When it happens

Trigger: readLinuxOrPlatformIndependentCore: exeELF opens successfully but exeELF.Machine != machineType from the core's ELF header — cross-architecture core/exe pair supplied to the core loader.

Common situations: Debugging a core captured on another machine/architecture (e.g. from CI or production on ARM) with a locally built x86-64 binary; wrong binary chosen from a multi-arch build directory.

Related errors


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

Appendix: source

Thrown at pkg/proc/core/linux_core.go:142

	machineType := coreFile.Machine
	notes, platformIndependentDelveCore, err := readNotes(coreFile, machineType)
	if err != nil {
		return nil, nil, err
	}

	exe, err := os.Open(exePath)
	if err != nil {
		return nil, nil, err
	}
	exeELF, err := elf.NewFile(exe)
	if err != nil {
		if !platformIndependentDelveCore {
			return nil, nil, err
		}
	} else {
		if exeELF.Machine != machineType {
			return nil, nil, fmt.Errorf("architecture mismatch between core file (%#x) and executable file (%#x)", machineType, exeELF.Machine)
		}
		if exeELF.Type != elf.ET_EXEC && exeELF.Type != elf.ET_DYN {
			return nil, nil, fmt.Errorf("%v is not an exe file", exeELF)
		}
	}

	memory := buildMemory(coreFile, exeELF, exe, notes)

	// TODO support 386
	var bi *proc.BinaryInfo
	if platformIndependentDelveCore {
		goos, goarch, err := platformFromNotes(notes)
		if err != nil {
			return nil, nil, err
		}
		bi = proc.NewBinaryInfo(goos, goarch)
	} else if goarch, ok := supportedLinuxMachines[machineType]; ok {
		bi = proc.NewBinaryInfo("linux", goarch)

View on GitHub (pinned to a23773e6c3)