Class: MachO::Headers::FatArch

Inherits:
MachOStructure show all
Defined in:
lib/macho/headers.rb

Overview

Note:

"32-bit" indicates the fact that this structure stores 32-bit offsets, not that the Mach-Os that it points to necessarily are 32-bit.

32-bit fat binary header architecture structure. A 32-bit fat Mach-O has one or more of these, indicating one or more internal Mach-O blobs.

See Also:

Direct Known Subclasses

FatArch64

Constant Summary collapse

FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Note:

Always big endian.

"L>5"
SIZEOF =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

20

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(cputype, cpusubtype, offset, size, align) ⇒ FatArch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FatArch.



554
555
556
557
558
559
560
561
# File 'lib/macho/headers.rb', line 554

def initialize(cputype, cpusubtype, offset, size, align)
  super()
  @cputype = cputype
  @cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK
  @offset = offset
  @size = size
  @align = align
end

Instance Attribute Details

#alignInteger (readonly)

Returns the alignment, as a power of 2.

Returns:

  • (Integer)

    the alignment, as a power of 2



542
543
544
# File 'lib/macho/headers.rb', line 542

def align
  @align
end

#cpusubtypeInteger (readonly)

Returns the CPU subtype of the Mach-O.

Returns:

  • (Integer)

    the CPU subtype of the Mach-O



533
534
535
# File 'lib/macho/headers.rb', line 533

def cpusubtype
  @cpusubtype
end

#cputypeInteger (readonly)

Returns the CPU type of the Mach-O.

Returns:

  • (Integer)

    the CPU type of the Mach-O



530
531
532
# File 'lib/macho/headers.rb', line 530

def cputype
  @cputype
end

#offsetInteger (readonly)

Returns the file offset to the beginning of the Mach-O data.

Returns:

  • (Integer)

    the file offset to the beginning of the Mach-O data



536
537
538
# File 'lib/macho/headers.rb', line 536

def offset
  @offset
end

#sizeInteger (readonly)

Returns the size, in bytes, of the Mach-O data.

Returns:

  • (Integer)

    the size, in bytes, of the Mach-O data



539
540
541
# File 'lib/macho/headers.rb', line 539

def size
  @size
end

Instance Method Details

#serializeString

Returns the serialized fields of the fat arch.

Returns:

  • (String)

    the serialized fields of the fat arch



564
565
566
# File 'lib/macho/headers.rb', line 564

def serialize
  [cputype, cpusubtype, offset, size, align].pack(FORMAT)
end

#to_hHash

Returns a hash representation of this MachO::Headers::FatArch.

Returns:



569
570
571
572
573
574
575
576
577
578
579
# File 'lib/macho/headers.rb', line 569

def to_h
  {
    "cputype" => cputype,
    "cputype_sym" => CPU_TYPES[cputype],
    "cpusubtype" => cpusubtype,
    "cpusubtype_sym" => CPU_SUBTYPES[cputype][cpusubtype],
    "offset" => offset,
    "size" => size,
    "align" => align,
  }.merge super
end