Skip to content

Commit

Permalink
proc/gdbserial: Added support for darwin/arm64 using gdbserver (go-de…
Browse files Browse the repository at this point in the history
…lve#2285)

* Added support for reading darwin/arm64 using gdbserver

* Trying to fix test failures

* Addressing review comments
  • Loading branch information
oxisto authored and zhaixiaojuan committed Apr 25, 2021
1 parent cc07f56 commit 261b3b6
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 189 deletions.
11 changes: 11 additions & 0 deletions pkg/proc/bininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ var (

supportedDarwinArch = map[macho.Cpu]bool{
macho.CpuAmd64: true,
macho.CpuArm64: true,
}
)

Expand Down Expand Up @@ -1373,9 +1374,19 @@ func findPESymbol(f *pe.File, name string) (*pe.Symbol, error) {
// loadBinaryInfoMacho specifically loads information from a Mach-O binary.
func loadBinaryInfoMacho(bi *BinaryInfo, image *Image, path string, entryPoint uint64, wg *sync.WaitGroup) error {
exe, err := macho.Open(path)

if err != nil {
return err
}

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
}

image.closer = exe
if !supportedDarwinArch[exe.Cpu] {
return &ErrUnsupportedArch{os: "darwin", cpuArch: exe.Cpu}
Expand Down
Loading

0 comments on commit 261b3b6

Please sign in to comment.