{"record":{"id":"0824fe683f4ec635","repo":"go-delve/delve","slug":"errcouldnotdeterminerelocation","errorCode":"ErrCouldNotDetermineRelocation","errorMessage":"could not determine the base address of a PIE","messagePattern":"could not determine the base address of a PIE","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/bininfo.go","lineNumber":130,"sourceCode":"\n\tmoduleDataCache []ModuleData\n\n\t// Go 1.17 register ABI is enabled.\n\tregabi bool\n\n\tdebugPinnerFn *Function\n\tlogger        logflags.Logger\n\teventsFn      func(*Event)\n\n\tcancelDownloadsMu sync.Mutex\n\tcancelDownloads   func()\n\tdownloadsCtx      context.Context\n}\n\nvar (\n\t// ErrCouldNotDetermineRelocation is an error returned when Delve could not determine the base address of a\n\t// position independent executable.\n\tErrCouldNotDetermineRelocation = errors.New(\"could not determine the base address of a PIE\")\n\n\t// ErrNoDebugInfoFound is returned when Delve cannot open the debug_info\n\t// section or find an external debug info file.\n\tErrNoDebugInfoFound = errors.New(\"could not open debug info\")\n)\n\nvar (\n\tsupportedLinuxArch = map[elf.Machine]bool{\n\t\telf.EM_X86_64:    true,\n\t\telf.EM_AARCH64:   true,\n\t\telf.EM_386:       true,\n\t\telf.EM_PPC64:     true,\n\t\telf.EM_RISCV:     true,\n\t\telf.EM_LOONGARCH: true,\n\t}\n\n\tsupportedWindowsArch = map[_PEMachine]bool{\n\t\t_IMAGE_FILE_MACHINE_AMD64: true,","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/bininfo.go#L112-L148","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the target process memory maps are readable (check /proc/<pid>/maps permissions, same namespace)","Verify you are attaching to the correct PID and the executable path matches the running mapping","Use dlv exec/attach with the exact binary that was executed so mapping checks succeed","Retry after the process has finished loading (PIE base is set at exec time)"],"exampleFix":"// before\nbi.LoadBinaryInfo(path, 0) // PIE, no mapping info -> ErrCouldNotDetermineRelocation\n// after\nentry, err := findEntryPointFromProcMaps(pid, path) // supply runtime entry point\nif err != nil { return err }\nbi.LoadBinaryInfo(path, entry)","handlingStrategy":"try-catch","validationCode":"// check the mapping is discoverable first\nif _, err := os.ReadFile(fmt.Sprintf(\"/proc/%d/maps\", pid)); err != nil {\n    return fmt.Errorf(\"cannot read process maps needed for PIE relocation: %w\", err)\n}","typeGuard":"func isPIERelocationError(err error) bool {\n    return errors.Is(err, proc.ErrCouldNotDetermineRelocation)\n}","tryCatchPattern":"if err := loadImageError; err != nil {\n    if errors.Is(err, proc.ErrCouldNotDetermineRelocation) {\n        // recover base from /proc/<pid>/maps or re-attach with explicit entry point\n    }\n}","preventionTips":["Attach with the exact executable path that was executed","Ensure /proc access (same PID namespace, ptrace_scope allows it)","Avoid analyzing PIE core dumps that lack file mapping notes"],"tags":["elf","pie","relocation","debugger"],"backgroundTag":"pie-base-address-unknown","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}