diff --git a/pkg/proc/bininfo.go b/pkg/proc/bininfo.go index c63fb16f4a..4183196dcc 100644 --- a/pkg/proc/bininfo.go +++ b/pkg/proc/bininfo.go @@ -1805,11 +1805,17 @@ func loadBinaryInfoMacho(bi *BinaryInfo, image *Image, path string, entryPoint u } if entryPoint != 0 { - // This is a little bit hacky. We use the entryPoint variable, but it - // actually holds the address of the mach-o header. We can use this - // to calculate the offset to the non-aslr location of the mach-o header - // (which is 0x100000000) - image.StaticBase = entryPoint - 0x100000000 + machoOff := uint64(0x100000000) + for _, ld := range exe.Loads { + if seg, _ := ld.(*macho.Segment); seg != nil { + if seg.Name == "__TEXT" { + machoOff = seg.Addr + break + } + } + } + logflags.DebuggerLogger().Debugf("entryPoint %#x machoOff %#x", entryPoint, machoOff) + image.StaticBase = entryPoint - machoOff } image.closer = exe diff --git a/pkg/proc/gdbserial/gdbserver.go b/pkg/proc/gdbserial/gdbserver.go index bb57f3d587..311a21cd02 100644 --- a/pkg/proc/gdbserial/gdbserver.go +++ b/pkg/proc/gdbserial/gdbserver.go @@ -662,7 +662,7 @@ func LLDBAttach(pid int, path string, waitFor *proc.WaitFor, debugInfoDirs []str // debugging PIEs. func (p *gdbProcess) EntryPoint() (uint64, error) { var entryPoint uint64 - if p.bi.GOOS == "darwin" && p.bi.Arch.Name == "arm64" { + if p.bi.GOOS == "darwin" { // There is no auxv on darwin, however, we can get the location of the mach-o // header from the debugserver by going through the loaded libraries, which includes // the exe itself