github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/debug/macho/fat.go (about)

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package macho
     6  
     7  import (
     8  	"github.com/shogo82148/std/io"
     9  )
    10  
    11  // FatFileは、少なくとも1つのアーキテクチャを含むMach-Oユニバーサルバイナリです。
    12  type FatFile struct {
    13  	Magic  uint32
    14  	Arches []FatArch
    15  	closer io.Closer
    16  }
    17  
    18  // FatArchHeaderは、特定のイメージアーキテクチャのためのファットヘッダーを表します。
    19  type FatArchHeader struct {
    20  	Cpu    Cpu
    21  	SubCpu uint32
    22  	Offset uint32
    23  	Size   uint32
    24  	Align  uint32
    25  }
    26  
    27  // FatArchは、FatFile内のMach-Oファイルです。
    28  type FatArch struct {
    29  	FatArchHeader
    30  	*File
    31  }
    32  
    33  // ErrNotFatは、ファイルがユニバーサルバイナリではなく、
    34  // マジックナンバーに基づいてシンバイナリである可能性がある場合、
    35  // [NewFatFile] または [OpenFat] から返されます。
    36  var ErrNotFat = &FormatError{0, "not a fat Mach-O file", nil}
    37  
    38  // NewFatFileは、ユニバーサルバイナリ内のすべてのMach-Oイメージにアクセスするための新しい [FatFile] を作成します。
    39  // Mach-Oバイナリは、ReaderAtの位置0で開始することが期待されています。
    40  func NewFatFile(r io.ReaderAt) (*FatFile, error)
    41  
    42  // OpenFatは、[os.Open] を使用して指定されたファイルを開き、それをMach-Oユニバーサルバイナリとして使用するための準備をします。
    43  func OpenFat(name string) (*FatFile, error)
    44  
    45  func (ff *FatFile) Close() error