Class: ELFTools::RelativeRelocations
- Inherits:
-
Object
- Object
- ELFTools::RelativeRelocations
- Defined in:
- lib/elftools/relative_relocations.rb
Overview
The relocations a file packs into a bitmap instead of recording one by one.
Almost every relocation of a file that is loaded anywhere only adds the load bias to a word, which takes an entry recording an address, a type that is the same every time, and an addend that repeats what the word already holds. A file may pack them instead, as a run of addresses in ascending order, and spend a bit rather than an entry on each.
An even entry is an address, and relocates the word there. An odd entry is a bitmap of the words following the last address, a set bit relocating one of them. Nothing records a type, because every relocation here is the one Constants::R.relative names.
Instance Method Summary collapse
-
#initialize(stream, bytes, elf_class:, endian:, machine:) ⇒ RelativeRelocations
constructor
Instantiate a RelativeRelocations object.
-
#to_a ⇒ Array<ELFTools::Relocation>
The relocations the table packs.
Constructor Details
#initialize(stream, bytes, elf_class:, endian:, machine:) ⇒ RelativeRelocations
Instantiate a ELFTools::RelativeRelocations object.
28 29 30 31 32 33 34 |
# File 'lib/elftools/relative_relocations.rb', line 28 def initialize(stream, bytes, elf_class:, endian:, machine:) @stream = stream @bytes = bytes @elf_class = elf_class @endian = endian @machine = machine end |
Instance Method Details
#to_a ⇒ Array<ELFTools::Relocation>
The relocations the table packs.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/elftools/relative_relocations.rb', line 39 def to_a type = Constants::R.relative(@machine) addresses.map do |address, from| rel = Structs::ELF_Rel.new(endian: @endian, offset: from) rel.elf_class = @elf_class rel.r_offset = address relocation = Relocation.new(rel, @stream, machine: @machine) # Through the relocation, so that the type is laid out in +r_info+ the # way the machine lays it out. relocation.type = type if type relocation end end |