(name string, start, limit, offset uint64)
| 379 | } |
| 380 | |
| 381 | func (b *binrep) openFatMachO(name string, start, limit, offset uint64) (plugin.ObjFile, error) { |
| 382 | of, err := macho.OpenFat(name) |
| 383 | if err != nil { |
| 384 | return nil, fmt.Errorf("error parsing %s: %v", name, err) |
| 385 | } |
| 386 | defer of.Close() |
| 387 | |
| 388 | if len(of.Arches) == 0 { |
| 389 | return nil, fmt.Errorf("empty fat Mach-O file: %s", name) |
| 390 | } |
| 391 | |
| 392 | var arch macho.Cpu |
| 393 | // Use the host architecture. |
| 394 | // TODO: This is not ideal because the host architecture may not be the one |
| 395 | // that was profiled. E.g. an amd64 host can profile a 386 program. |
| 396 | switch runtime.GOARCH { |
| 397 | case "386": |
| 398 | arch = macho.Cpu386 |
| 399 | case "amd64", "amd64p32": |
| 400 | arch = macho.CpuAmd64 |
| 401 | case "arm", "armbe", "arm64", "arm64be": |
| 402 | arch = macho.CpuArm |
| 403 | case "ppc": |
| 404 | arch = macho.CpuPpc |
| 405 | case "ppc64", "ppc64le": |
| 406 | arch = macho.CpuPpc64 |
| 407 | default: |
| 408 | return nil, fmt.Errorf("unsupported host architecture for %s: %s", name, runtime.GOARCH) |
| 409 | } |
| 410 | for i := range of.Arches { |
| 411 | if of.Arches[i].Cpu == arch { |
| 412 | return b.openMachOCommon(name, of.Arches[i].File, start, limit, offset) |
| 413 | } |
| 414 | } |
| 415 | return nil, fmt.Errorf("architecture not found in %s: %s", name, runtime.GOARCH) |
| 416 | } |
| 417 | |
| 418 | func (b *binrep) openMachO(name string, start, limit, offset uint64) (plugin.ObjFile, error) { |
| 419 | of, err := macho.Open(name) |
no test coverage detected