go-delve/delve · error

ErrCouldNotDetermineRelocation

ErrCouldNotDetermineRelocation

Error message

could not determine the base address of a PIE

What it means

ErrCouldNotDetermineRelocation is returned when Delve cannot compute the base address (load bias) of a position independent executable (PIE). PIE code and DWARF addresses are link-time offsets; without the runtime base address, symbol and breakpoint addresses cannot be relocated. It is wrapped with details by callers when the ELF program headers don't reveal where the executable was mapped.

Source

Thrown at pkg/proc/bininfo.go:130

	moduleDataCache []ModuleData

	// Go 1.17 register ABI is enabled.
	regabi bool

	debugPinnerFn *Function
	logger        logflags.Logger
	eventsFn      func(*Event)

	cancelDownloadsMu sync.Mutex
	cancelDownloads   func()
	downloadsCtx      context.Context
}

var (
	// ErrCouldNotDetermineRelocation is an error returned when Delve could not determine the base address of a
	// position independent executable.
	ErrCouldNotDetermineRelocation = errors.New("could not determine the base address of a PIE")

	// ErrNoDebugInfoFound is returned when Delve cannot open the debug_info
	// section or find an external debug info file.
	ErrNoDebugInfoFound = errors.New("could not open debug info")
)

var (
	supportedLinuxArch = map[elf.Machine]bool{
		elf.EM_X86_64:    true,
		elf.EM_AARCH64:   true,
		elf.EM_386:       true,
		elf.EM_PPC64:     true,
		elf.EM_RISCV:     true,
		elf.EM_LOONGARCH: true,
	}

	supportedWindowsArch = map[_PEMachine]bool{
		_IMAGE_FILE_MACHINE_AMD64: true,

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Ensure the target process memory maps are readable (check /proc/<pid>/maps permissions, same namespace)
  2. Verify you are attaching to the correct PID and the executable path matches the running mapping
  3. Use dlv exec/attach with the exact binary that was executed so mapping checks succeed
  4. Retry after the process has finished loading (PIE base is set at exec time)

Example fix

// before
bi.LoadBinaryInfo(path, 0) // PIE, no mapping info -> ErrCouldNotDetermineRelocation
// after
entry, err := findEntryPointFromProcMaps(pid, path) // supply runtime entry point
if err != nil { return err }
bi.LoadBinaryInfo(path, entry)
Defensive patterns

Strategy: try-catch

Validate before calling

// check the mapping is discoverable first
if _, err := os.ReadFile(fmt.Sprintf("/proc/%d/maps", pid)); err != nil {
    return fmt.Errorf("cannot read process maps needed for PIE relocation: %w", err)
}

Type guard

func isPIERelocationError(err error) bool {
    return errors.Is(err, proc.ErrCouldNotDetermineRelocation)
}

Try / catch

if err := loadImageError; err != nil {
    if errors.Is(err, proc.ErrCouldNotDetermineRelocation) {
        // recover base from /proc/<pid>/maps or re-attach with explicit entry point
    }
}

Prevention

When it happens

Trigger: Loading binary info for a PIE whose mapping base cannot be found — e.g. reading /proc/<pid>/maps fails for the executable's mapping, or the core file / memory reader lacks the ELF mapping entry.

Common situations: Attaching to a PIE process running under restricted /proc access or a different mount namespace; analyzing core dumps that omit file mappings; debugging PIE binaries through backends with incomplete memory maps.

Related errors


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