Class: ELFTools::Relocation
- Inherits:
-
Object
- Object
- ELFTools::Relocation
- Defined in:
- lib/elftools/relocation.rb
Overview
A relocation entry.
Can be either a REL or RELA relocation.
Instance Attribute Summary collapse
-
#stream ⇒ #pos=, #read
readonly
Streaming object.
Instance Method Summary collapse
-
#header ⇒ ELFTools::Structs::ELF_Rel, ELFTools::Structs::ELF_Rela
The structure the file records this relocation in.
-
#initialize(header, stream, machine: nil) ⇒ Relocation
constructor
Instantiate a Relocation object.
-
#symbol_index ⇒ Integer
Which symbol this relocation is against, as an index into the symbol table.
-
#symbol_index=(index) ⇒ Object
Sets which symbol this relocation is against.
-
#type ⇒ Integer
What this relocation does, which only means something together with the machine of the file.
-
#type=(type) ⇒ Object
Sets what this relocation does.
-
#type_name ⇒ String
The name of #type.
Constructor Details
#initialize(header, stream, machine: nil) ⇒ Relocation
Instantiate a ELFTools::Relocation object.
23 24 25 26 27 |
# File 'lib/elftools/relocation.rb', line 23 def initialize(header, stream, machine: nil) @fields = header.is_a?(Structs::Fields) ? header : Structs::Fields.of(header) @stream = stream @machine = machine end |
Instance Attribute Details
#stream ⇒ #pos=, #read (readonly)
Returns Streaming object.
12 13 14 |
# File 'lib/elftools/relocation.rb', line 12 def stream @stream end |
Instance Method Details
#header ⇒ ELFTools::Structs::ELF_Rel, ELFTools::Structs::ELF_Rela
The structure the file records this relocation in.
One is built here for a relocation read without it, which is what assigning to a field of one needs and what ELFFile#patches reports the changes of.
35 36 37 |
# File 'lib/elftools/relocation.rb', line 35 def header @fields.struct end |
#symbol_index ⇒ Integer
Which symbol this relocation is against, as an index into the symbol table.
42 43 44 |
# File 'lib/elftools/relocation.rb', line 42 def symbol_index sym_and_type.first end |
#symbol_index=(index) ⇒ Object
Sets which symbol this relocation is against.
58 59 60 |
# File 'lib/elftools/relocation.rb', line 58 def symbol_index=(index) @fields[:r_info] = info_of(Util.fits!(index, index_bits, 'Symbol index'), type) end |
#type ⇒ Integer
What this relocation does, which only means something together with the machine of the file. #type_name names it.
49 50 51 |
# File 'lib/elftools/relocation.rb', line 49 def type sym_and_type.last end |