lisette-stdlib 0.1.16

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
// Generated by Lisette bindgen
// Source: debug/macho (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.14

import "go:debug/dwarf"
import "go:encoding/binary"
import "go:io"

pub enum Cpu: uint32 {
  Cpu386 = 7,
  CpuAmd64 = 16777223,
  CpuArm = 12,
  CpuArm64 = 16777228,
  CpuPpc = 18,
  CpuPpc64 = 16777234,
}

pub const Cpu386: Cpu = 7

pub const CpuAmd64: Cpu = 16777223

pub const CpuArm: Cpu = 12

pub const CpuArm64: Cpu = 16777228

pub const CpuPpc: Cpu = 18

pub const CpuPpc64: Cpu = 16777234

pub enum LoadCmd: uint32 {
  LoadCmdDylib = 0xc,
  LoadCmdDylinker = 0xf,
  LoadCmdDysymtab = 0xb,
  LoadCmdRpath = 0x8000001c,
  LoadCmdSegment = 0x1,
  LoadCmdSegment64 = 0x19,
  LoadCmdSymtab = 0x2,
  LoadCmdThread = 0x4,
  LoadCmdUnixThread = 0x5,
}

pub const LoadCmdDylib: LoadCmd = 0xc

pub const LoadCmdDylinker: LoadCmd = 0xf

pub const LoadCmdDysymtab: LoadCmd = 0xb

pub const LoadCmdRpath: LoadCmd = 0x8000001c

pub const LoadCmdSegment: LoadCmd = 0x1

pub const LoadCmdSegment64: LoadCmd = 0x19

pub const LoadCmdSymtab: LoadCmd = 0x2

pub const LoadCmdThread: LoadCmd = 0x4

pub const LoadCmdUnixThread: LoadCmd = 0x5

pub enum RelocTypeARM: int {
  ARM_RELOC_BR24 = 5,
  ARM_RELOC_HALF = 8,
  ARM_RELOC_HALF_SECTDIFF = 9,
  ARM_RELOC_LOCAL_SECTDIFF = 3,
  ARM_RELOC_PAIR = 1,
  ARM_RELOC_PB_LA_PTR = 4,
  ARM_RELOC_SECTDIFF = 2,
  ARM_RELOC_VANILLA = 0,
  ARM_THUMB_32BIT_BRANCH = 7,
  ARM_THUMB_RELOC_BR22 = 6,
}

pub const ARM_RELOC_BR24: RelocTypeARM = 5

pub const ARM_RELOC_HALF: RelocTypeARM = 8

pub const ARM_RELOC_HALF_SECTDIFF: RelocTypeARM = 9

pub const ARM_RELOC_LOCAL_SECTDIFF: RelocTypeARM = 3

pub const ARM_RELOC_PAIR: RelocTypeARM = 1

pub const ARM_RELOC_PB_LA_PTR: RelocTypeARM = 4

pub const ARM_RELOC_SECTDIFF: RelocTypeARM = 2

pub const ARM_RELOC_VANILLA: RelocTypeARM = 0

pub const ARM_THUMB_32BIT_BRANCH: RelocTypeARM = 7

pub const ARM_THUMB_RELOC_BR22: RelocTypeARM = 6

pub enum RelocTypeARM64: int {
  ARM64_RELOC_ADDEND = 10,
  ARM64_RELOC_BRANCH26 = 2,
  ARM64_RELOC_GOT_LOAD_PAGE21 = 5,
  ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6,
  ARM64_RELOC_PAGE21 = 3,
  ARM64_RELOC_PAGEOFF12 = 4,
  ARM64_RELOC_POINTER_TO_GOT = 7,
  ARM64_RELOC_SUBTRACTOR = 1,
  ARM64_RELOC_TLVP_LOAD_PAGE21 = 8,
  ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9,
  ARM64_RELOC_UNSIGNED = 0,
}

pub const ARM64_RELOC_ADDEND: RelocTypeARM64 = 10

pub const ARM64_RELOC_BRANCH26: RelocTypeARM64 = 2

pub const ARM64_RELOC_GOT_LOAD_PAGE21: RelocTypeARM64 = 5

pub const ARM64_RELOC_GOT_LOAD_PAGEOFF12: RelocTypeARM64 = 6

pub const ARM64_RELOC_PAGE21: RelocTypeARM64 = 3

pub const ARM64_RELOC_PAGEOFF12: RelocTypeARM64 = 4

pub const ARM64_RELOC_POINTER_TO_GOT: RelocTypeARM64 = 7

pub const ARM64_RELOC_SUBTRACTOR: RelocTypeARM64 = 1

pub const ARM64_RELOC_TLVP_LOAD_PAGE21: RelocTypeARM64 = 8

pub const ARM64_RELOC_TLVP_LOAD_PAGEOFF12: RelocTypeARM64 = 9

pub const ARM64_RELOC_UNSIGNED: RelocTypeARM64 = 0

pub enum RelocTypeGeneric: int {
  GENERIC_RELOC_LOCAL_SECTDIFF = 4,
  GENERIC_RELOC_PAIR = 1,
  GENERIC_RELOC_PB_LA_PTR = 3,
  GENERIC_RELOC_SECTDIFF = 2,
  GENERIC_RELOC_TLV = 5,
  GENERIC_RELOC_VANILLA = 0,
}

pub const GENERIC_RELOC_LOCAL_SECTDIFF: RelocTypeGeneric = 4

pub const GENERIC_RELOC_PAIR: RelocTypeGeneric = 1

pub const GENERIC_RELOC_PB_LA_PTR: RelocTypeGeneric = 3

pub const GENERIC_RELOC_SECTDIFF: RelocTypeGeneric = 2

pub const GENERIC_RELOC_TLV: RelocTypeGeneric = 5

pub const GENERIC_RELOC_VANILLA: RelocTypeGeneric = 0

pub enum RelocTypeX86_64: int {
  X86_64_RELOC_BRANCH = 2,
  X86_64_RELOC_GOT = 4,
  X86_64_RELOC_GOT_LOAD = 3,
  X86_64_RELOC_SIGNED = 1,
  X86_64_RELOC_SIGNED_1 = 6,
  X86_64_RELOC_SIGNED_2 = 7,
  X86_64_RELOC_SIGNED_4 = 8,
  X86_64_RELOC_SUBTRACTOR = 5,
  X86_64_RELOC_TLV = 9,
  X86_64_RELOC_UNSIGNED = 0,
}

pub const X86_64_RELOC_BRANCH: RelocTypeX86_64 = 2

pub const X86_64_RELOC_GOT: RelocTypeX86_64 = 4

pub const X86_64_RELOC_GOT_LOAD: RelocTypeX86_64 = 3

pub const X86_64_RELOC_SIGNED: RelocTypeX86_64 = 1

pub const X86_64_RELOC_SIGNED_1: RelocTypeX86_64 = 6

pub const X86_64_RELOC_SIGNED_2: RelocTypeX86_64 = 7

pub const X86_64_RELOC_SIGNED_4: RelocTypeX86_64 = 8

pub const X86_64_RELOC_SUBTRACTOR: RelocTypeX86_64 = 5

pub const X86_64_RELOC_TLV: RelocTypeX86_64 = 9

pub const X86_64_RELOC_UNSIGNED: RelocTypeX86_64 = 0

pub fn NewFatFile(r: io.ReaderAt) -> Result<Ref<FatFile>, error>

pub fn NewFile(r: io.ReaderAt) -> Result<Ref<File>, error>

pub fn Open(name: string) -> Result<Ref<File>, error>

pub fn OpenFat(name: string) -> Result<Ref<FatFile>, error>

/// A Dylib represents a Mach-O load dynamic library command.
pub struct Dylib {
  pub LoadBytes: LoadBytes,
  pub Name: string,
  pub Time: uint32,
  pub CurrentVersion: uint32,
  pub CompatVersion: uint32,
}

/// A DylibCmd is a Mach-O load dynamic library command.
pub struct DylibCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: uint32,
  pub Time: uint32,
  pub CurrentVersion: uint32,
  pub CompatVersion: uint32,
}

/// A Dysymtab represents a Mach-O dynamic symbol table command.
pub struct Dysymtab {
  pub LoadBytes: LoadBytes,
  pub DysymtabCmd: DysymtabCmd,
  pub IndirectSyms: Slice<uint32>,
}

/// A DysymtabCmd is a Mach-O dynamic symbol table command.
pub struct DysymtabCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Ilocalsym: uint32,
  pub Nlocalsym: uint32,
  pub Iextdefsym: uint32,
  pub Nextdefsym: uint32,
  pub Iundefsym: uint32,
  pub Nundefsym: uint32,
  pub Tocoffset: uint32,
  pub Ntoc: uint32,
  pub Modtaboff: uint32,
  pub Nmodtab: uint32,
  pub Extrefsymoff: uint32,
  pub Nextrefsyms: uint32,
  pub Indirectsymoff: uint32,
  pub Nindirectsyms: uint32,
  pub Extreloff: uint32,
  pub Nextrel: uint32,
  pub Locreloff: uint32,
  pub Nlocrel: uint32,
}

/// A FatArch is a Mach-O File inside a FatFile.
pub struct FatArch {
  pub FatArchHeader: FatArchHeader,
  pub File: Option<Ref<File>>,
}

/// A FatArchHeader represents a fat header for a specific image architecture.
pub struct FatArchHeader {
  pub Cpu: Cpu,
  pub SubCpu: uint32,
  pub Offset: uint32,
  pub Size: uint32,
  pub Align: uint32,
}

/// A FatFile is a Mach-O universal binary that contains at least one architecture.
pub struct FatFile {
  pub Magic: uint32,
  pub Arches: Slice<FatArch>,
}

/// A File represents an open Mach-O file.
pub struct File {
  pub FileHeader: FileHeader,
  pub ByteOrder: Option<binary.ByteOrder>,
  pub Loads: Slice<Option<Load>>,
  pub Sections: Slice<Option<Ref<Section>>>,
  pub Symtab: Option<Ref<Symtab>>,
  pub Dysymtab: Option<Ref<Dysymtab>>,
}

/// A FileHeader represents a Mach-O file header.
pub struct FileHeader {
  pub Magic: uint32,
  pub Cpu: Cpu,
  pub SubCpu: uint32,
  pub Type: Type,
  pub Ncmd: uint32,
  pub Cmdsz: uint32,
  pub Flags: uint32,
}

/// FormatError is returned by some operations if the data does
/// not have the correct format for an object file.
pub type FormatError

/// A Load represents any Mach-O load command.
pub interface Load {
  fn Raw() -> Slice<uint8>
}

/// A LoadBytes is the uninterpreted bytes of a Mach-O load command.
pub struct LoadBytes(Slice<uint8>)

/// An Nlist32 is a Mach-O 32-bit symbol table entry.
pub struct Nlist32 {
  pub Name: uint32,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint32,
}

/// An Nlist64 is a Mach-O 64-bit symbol table entry.
pub struct Nlist64 {
  pub Name: uint32,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint64,
}

/// Regs386 is the Mach-O 386 register structure.
pub struct Regs386 {
  pub AX: uint32,
  pub BX: uint32,
  pub CX: uint32,
  pub DX: uint32,
  pub DI: uint32,
  pub SI: uint32,
  pub BP: uint32,
  pub SP: uint32,
  pub SS: uint32,
  pub FLAGS: uint32,
  pub IP: uint32,
  pub CS: uint32,
  pub DS: uint32,
  pub ES: uint32,
  pub FS: uint32,
  pub GS: uint32,
}

/// RegsAMD64 is the Mach-O AMD64 register structure.
pub struct RegsAMD64 {
  pub AX: uint64,
  pub BX: uint64,
  pub CX: uint64,
  pub DX: uint64,
  pub DI: uint64,
  pub SI: uint64,
  pub BP: uint64,
  pub SP: uint64,
  pub R8: uint64,
  pub R9: uint64,
  pub R10: uint64,
  pub R11: uint64,
  pub R12: uint64,
  pub R13: uint64,
  pub R14: uint64,
  pub R15: uint64,
  pub IP: uint64,
  pub FLAGS: uint64,
  pub CS: uint64,
  pub FS: uint64,
  pub GS: uint64,
}

/// A Reloc represents a Mach-O relocation.
pub struct Reloc {
  pub Addr: uint32,
  pub Value: uint32,
  pub Type: uint8,
  pub Len: uint8,
  pub Pcrel: bool,
  pub Extern: bool,
  pub Scattered: bool,
}

/// A Rpath represents a Mach-O rpath command.
pub struct Rpath {
  pub LoadBytes: LoadBytes,
  pub Path: string,
}

/// A RpathCmd is a Mach-O rpath command.
pub struct RpathCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Path: uint32,
}

pub struct Section {
  pub SectionHeader: SectionHeader,
  pub Relocs: Slice<Reloc>,
  pub ReaderAt: Option<io.ReaderAt>,
}

/// A Section32 is a 32-bit Mach-O section header.
pub struct Section32 {
  pub Name: Slice<uint8>,
  pub Seg: Slice<uint8>,
  pub Addr: uint32,
  pub Size: uint32,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
  pub Reserve1: uint32,
  pub Reserve2: uint32,
}

/// A Section64 is a 64-bit Mach-O section header.
pub struct Section64 {
  pub Name: Slice<uint8>,
  pub Seg: Slice<uint8>,
  pub Addr: uint64,
  pub Size: uint64,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
  pub Reserve1: uint32,
  pub Reserve2: uint32,
  pub Reserve3: uint32,
}

pub struct SectionHeader {
  pub Name: string,
  pub Seg: string,
  pub Addr: uint64,
  pub Size: uint64,
  pub Offset: uint32,
  pub Align: uint32,
  pub Reloff: uint32,
  pub Nreloc: uint32,
  pub Flags: uint32,
}

/// A Segment represents a Mach-O 32-bit or 64-bit load segment command.
pub struct Segment {
  pub LoadBytes: LoadBytes,
  pub SegmentHeader: SegmentHeader,
  pub ReaderAt: Option<io.ReaderAt>,
}

/// A Segment32 is a 32-bit Mach-O segment load command.
pub struct Segment32 {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: Slice<uint8>,
  pub Addr: uint32,
  pub Memsz: uint32,
  pub Offset: uint32,
  pub Filesz: uint32,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A Segment64 is a 64-bit Mach-O segment load command.
pub struct Segment64 {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: Slice<uint8>,
  pub Addr: uint64,
  pub Memsz: uint64,
  pub Offset: uint64,
  pub Filesz: uint64,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
pub struct SegmentHeader {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Name: string,
  pub Addr: uint64,
  pub Memsz: uint64,
  pub Offset: uint64,
  pub Filesz: uint64,
  pub Maxprot: uint32,
  pub Prot: uint32,
  pub Nsect: uint32,
  pub Flag: uint32,
}

/// A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.
pub struct Symbol {
  pub Name: string,
  pub Type: uint8,
  pub Sect: uint8,
  pub Desc: uint16,
  pub Value: uint64,
}

/// A Symtab represents a Mach-O symbol table command.
pub struct Symtab {
  pub LoadBytes: LoadBytes,
  pub SymtabCmd: SymtabCmd,
  pub Syms: Slice<Symbol>,
}

/// A SymtabCmd is a Mach-O symbol table command.
pub struct SymtabCmd {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Symoff: uint32,
  pub Nsyms: uint32,
  pub Stroff: uint32,
  pub Strsize: uint32,
}

/// A Thread is a Mach-O thread state command.
pub struct Thread {
  pub Cmd: LoadCmd,
  pub Len: uint32,
  pub Type: uint32,
  pub Data: Slice<uint32>,
}

/// A Type is the Mach-O file type, e.g. an object file, executable, or dynamic library.
pub struct Type(uint32)

const FlagAllModsBound = 0x1000

const FlagAllowStackExecution = 0x20000

const FlagAppExtensionSafe = 0x2000000

const FlagBindAtLoad = 0x8

const FlagBindsToWeak = 0x10000

const FlagCanonical = 0x4000

const FlagDeadStrippableDylib = 0x400000

const FlagDyldLink = 0x4

const FlagForceFlat = 0x100

const FlagHasTLVDescriptors = 0x800000

const FlagIncrLink = 0x2

const FlagLazyInit = 0x40

const FlagNoFixPrebinding = 0x400

const FlagNoHeapExecution = 0x1000000

const FlagNoMultiDefs = 0x200

const FlagNoReexportedDylibs = 0x100000

const FlagNoUndefs = 0x1

const FlagPIE = 0x200000

const FlagPrebindable = 0x800

const FlagPrebound = 0x10

const FlagRootSafe = 0x40000

const FlagSetuidSafe = 0x80000

const FlagSplitSegs = 0x20

const FlagSubsectionsViaSymbols = 0x2000

const FlagTwoLevel = 0x80

const FlagWeakDefines = 0x8000

const Magic32 = 0xfeedface

const Magic64 = 0xfeedfacf

const MagicFat = 0xcafebabe

const TypeBundle: Type = 8

const TypeDylib: Type = 6

const TypeExec: Type = 2

const TypeObj: Type = 1

/// ErrNotFat is returned from [NewFatFile] or [OpenFat] when the file is not a
/// universal binary but may be a thin binary, based on its magic number.
pub var ErrNotFat: Ref<FormatError>

impl Cpu {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl Dylib {
  fn Raw(self) -> Slice<uint8>
}

impl Dysymtab {
  fn Raw(self) -> Slice<uint8>
}

impl FatArch {
  /// Close closes the [File].
  /// If the [File] was created using [NewFile] directly instead of [Open],
  /// Close has no effect.
  #[allow(unused_result)]
  fn Close(self) -> Result<(), error>

  /// DWARF returns the DWARF debug information for the Mach-O file.
  fn DWARF(self) -> Result<Ref<dwarf.Data>, error>

  /// ImportedLibraries returns the paths of all libraries
  /// referred to by the binary f that are expected to be
  /// linked with the binary at dynamic link time.
  fn ImportedLibraries(self) -> Result<Slice<string>, error>

  /// ImportedSymbols returns the names of all symbols
  /// referred to by the binary f that are expected to be
  /// satisfied by other libraries at dynamic load time.
  fn ImportedSymbols(self) -> Result<Slice<string>, error>

  /// Section returns the first section with the given name, or nil if no such
  /// section exists.
  fn Section(self, name: string) -> Option<Ref<Section>>

  /// Segment returns the first Segment with the given name, or nil if no such segment exists.
  fn Segment(self, name: string) -> Option<Ref<Segment>>
}

impl FatFile {
  #[allow(unused_result)]
  fn Close(self: Ref<FatFile>) -> Result<(), error>
}

impl File {
  /// Close closes the [File].
  /// If the [File] was created using [NewFile] directly instead of [Open],
  /// Close has no effect.
  #[allow(unused_result)]
  fn Close(self: Ref<File>) -> Result<(), error>

  /// DWARF returns the DWARF debug information for the Mach-O file.
  fn DWARF(self: Ref<File>) -> Result<Ref<dwarf.Data>, error>

  /// ImportedLibraries returns the paths of all libraries
  /// referred to by the binary f that are expected to be
  /// linked with the binary at dynamic link time.
  fn ImportedLibraries(self: Ref<File>) -> Result<Slice<string>, error>

  /// ImportedSymbols returns the names of all symbols
  /// referred to by the binary f that are expected to be
  /// satisfied by other libraries at dynamic load time.
  fn ImportedSymbols(self: Ref<File>) -> Result<Slice<string>, error>

  /// Section returns the first section with the given name, or nil if no such
  /// section exists.
  fn Section(self: Ref<File>, name: string) -> Option<Ref<Section>>

  /// Segment returns the first Segment with the given name, or nil if no such segment exists.
  fn Segment(self: Ref<File>, name: string) -> Option<Ref<Segment>>
}

impl FormatError {
  fn Error(self: Ref<FormatError>) -> string
}

impl LoadBytes {
  fn Raw(self) -> Slice<uint8>
}

impl LoadCmd {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeARM {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeARM64 {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeGeneric {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl RelocTypeX86_64 {
  fn GoString(self) -> string

  fn String(self) -> string
}

impl Rpath {
  fn Raw(self) -> Slice<uint8>
}

impl Section {
  /// Data reads and returns the contents of the Mach-O section.
  fn Data(self: Ref<Section>) -> Result<Slice<uint8>, error>

  /// Open returns a new ReadSeeker reading the Mach-O section.
  fn Open(self: Ref<Section>) -> io.ReadSeeker

  fn ReadAt(self, mut p: Slice<uint8>, off: int64) -> Partial<int, error>
}

impl Segment {
  /// Data reads and returns the contents of the segment.
  fn Data(self: Ref<Segment>) -> Result<Slice<uint8>, error>

  /// Open returns a new ReadSeeker reading the segment.
  fn Open(self: Ref<Segment>) -> io.ReadSeeker

  fn Raw(self) -> Slice<uint8>

  fn ReadAt(self, mut p: Slice<uint8>, off: int64) -> Partial<int, error>
}

impl Symtab {
  fn Raw(self) -> Slice<uint8>
}

impl Type {
  fn GoString(self) -> string

  fn String(self) -> string
}