Class: ELFTools::Sections::RelocationSection
- Defined in:
- lib/elftools/sections/relocation_section.rb
Overview
Class of note section. Note section records notes
Instance Attribute Summary
Attributes inherited from Section
Instance Method Summary collapse
-
#each_relocations {|rel| ... } ⇒ Enumerator<ELFTools::Relocation>, Array<ELFTools::Relocation>
Iterate all relocations.
-
#num_relocations ⇒ Integer
Number of relocations in this section.
-
#rela? ⇒ Boolean
Is this relocation a RELA or REL type.
-
#relocation_at(n) ⇒ ELFTools::Relocation?
Acquire the
n
-th relocation, 0-based. -
#relocations ⇒ Array<ELFTools::Relocation>
Simply use #relocations to get all relocations.
Methods inherited from Section
create, #data, #initialize, #name, #null?, #type
Constructor Details
This class inherits a constructor from ELFTools::Sections::Section
Instance Method Details
#each_relocations {|rel| ... } ⇒ Enumerator<ELFTools::Relocation>, Array<ELFTools::Relocation>
Iterate all relocations.
All relocations are lazy loading, the relocation only be created whenever accessing it.
45 46 47 48 49 50 51 |
# File 'lib/elftools/sections/relocation_section.rb', line 45 def each_relocations(&block) return enum_for(:each_relocations) unless block_given? Array.new(num_relocations) do |i| relocation_at(i).tap(&block) end end |
#num_relocations ⇒ Integer
Number of relocations in this section.
20 21 22 |
# File 'lib/elftools/sections/relocation_section.rb', line 20 def num_relocations header.sh_size / header.sh_entsize end |
#rela? ⇒ Boolean
Is this relocation a RELA or REL type.
14 15 16 |
# File 'lib/elftools/sections/relocation_section.rb', line 14 def rela? header.sh_type == Constants::SHT_RELA end |
#relocation_at(n) ⇒ ELFTools::Relocation?
Acquire the n
-th relocation, 0-based.
relocations are lazy loaded.
31 32 33 34 |
# File 'lib/elftools/sections/relocation_section.rb', line 31 def relocation_at(n) @relocations ||= LazyArray.new(num_relocations, &method(:create_relocation)) @relocations[n] end |
#relocations ⇒ Array<ELFTools::Relocation>
Simply use #relocations to get all relocations.
56 57 58 |
# File 'lib/elftools/sections/relocation_section.rb', line 56 def relocations each_relocations.to_a end |