Class: ELFTools::Relocation

Inherits:
Object
  • Object
show all
Defined in:
lib/elftools/relocation.rb

Overview

A relocation entry.

Can be either a REL or RELA relocation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, stream, machine: nil) ⇒ Relocation

Instantiate a ELFTools::Relocation object.

Parameters:



20
21
22
23
24
# File 'lib/elftools/relocation.rb', line 20

def initialize(header, stream, machine: nil)
  @header = header
  @stream = stream
  @machine = machine
end

Instance Attribute Details

#headerELFTools::Structs::ELF_Rel, ELFTools::Structs::ELF_Rela (readonly)

Returns Rel(a) header.



10
11
12
# File 'lib/elftools/relocation.rb', line 10

def header
  @header
end

#stream#pos=, #read (readonly)

Returns Streaming object.

Returns:

  • (#pos=, #read)

    Streaming object.



11
12
13
# File 'lib/elftools/relocation.rb', line 11

def stream
  @stream
end

Instance Method Details

#symbol_indexInteger

Which symbol this relocation is against, as an index into the symbol table.

Returns:

  • (Integer)

    The symbol index.



29
30
31
# File 'lib/elftools/relocation.rb', line 29

def symbol_index
  sym_and_type.first
end

#typeInteger

What this relocation does, which only means something together with the machine of the file. #type_name names it.

Returns:

  • (Integer)

    The relocation type.



36
37
38
# File 'lib/elftools/relocation.rb', line 36

def type
  sym_and_type.last
end

#type_nameString

The name of #type.

Every architecture numbers relocation types on its own, so the name is only known when the machine of the file is.

Examples:

relocation.type_name
#=> 'R_X86_64_JUMP_SLOT'

Returns:

  • (String)

    The name.



48
49
50
# File 'lib/elftools/relocation.rb', line 48

def type_name
  Constants::R.mapping(@machine, type)
end