Class: MachO::MachHeader
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::MachHeader
- Defined in:
- lib/macho/headers.rb
Overview
32-bit Mach-O file header structure
Direct Known Subclasses
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.
"L=7".freeze
- 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.
28
Instance Attribute Summary collapse
-
#cpusubtype ⇒ Fixnum
readonly
The CPU subtype of the Mach-O.
-
#cputype ⇒ Fixnum
readonly
The CPU type of the Mach-O.
-
#filetype ⇒ Fixnum
readonly
The file type of the Mach-O.
-
#flags ⇒ Fixnum
readonly
The header flags associated with the Mach-O.
-
#magic ⇒ Fixnum
readonly
The magic number.
-
#ncmds ⇒ Fixnum
readonly
The number of load commands in the Mach-O.
-
#sizeofcmds ⇒ Fixnum
readonly
The size of all load commands, in bytes, in the Mach-O.
Instance Method Summary collapse
-
#flag?(flag) ⇒ Boolean
True if
flagis present in the header's flag section. -
#initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags) ⇒ MachHeader
constructor
private
A new instance of MachHeader.
Methods inherited from MachOStructure
Constructor Details
#initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags) ⇒ MachHeader
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 MachHeader.
543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/macho/headers.rb', line 543 def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags) @magic = magic @cputype = cputype # For now we're not interested in additional capability bits also to be # found in the `cpusubtype` field. We only care about the CPU sub-type. @cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK @filetype = filetype @ncmds = ncmds @sizeofcmds = sizeofcmds @flags = flags end |
Instance Attribute Details
#cpusubtype ⇒ Fixnum (readonly)
Returns the CPU subtype of the Mach-O.
520 521 522 |
# File 'lib/macho/headers.rb', line 520 def cpusubtype @cpusubtype end |
#cputype ⇒ Fixnum (readonly)
Returns the CPU type of the Mach-O.
517 518 519 |
# File 'lib/macho/headers.rb', line 517 def cputype @cputype end |
#filetype ⇒ Fixnum (readonly)
Returns the file type of the Mach-O.
523 524 525 |
# File 'lib/macho/headers.rb', line 523 def filetype @filetype end |
#flags ⇒ Fixnum (readonly)
Returns the header flags associated with the Mach-O.
532 533 534 |
# File 'lib/macho/headers.rb', line 532 def flags @flags end |
#magic ⇒ Fixnum (readonly)
Returns the magic number.
514 515 516 |
# File 'lib/macho/headers.rb', line 514 def magic @magic end |
#ncmds ⇒ Fixnum (readonly)
Returns the number of load commands in the Mach-O.
526 527 528 |
# File 'lib/macho/headers.rb', line 526 def ncmds @ncmds end |
#sizeofcmds ⇒ Fixnum (readonly)
Returns the size of all load commands, in bytes, in the Mach-O.
529 530 531 |
# File 'lib/macho/headers.rb', line 529 def sizeofcmds @sizeofcmds end |
Instance Method Details
#flag?(flag) ⇒ Boolean
Returns true if flag is present in the header's flag section.
560 561 562 563 564 |
# File 'lib/macho/headers.rb', line 560 def flag?(flag) flag = MH_FLAGS[flag] return false if flag.nil? flags & flag == flag end |