Class: ELFTools::Sections::VersionNeedSection

Inherits:
Section
  • Object
show all
Defined in:
lib/elftools/sections/version_need_section.rb

Overview

Class of the section recording the versions a file needs of the files it is loaded with.

This section is usually named .gnu.version_r, and records the very versions the DT_VERNEED tag points at.

Instance Attribute Summary

Attributes inherited from Section

#header, #stream

Instance Method Summary collapse

Methods inherited from Section

#allocated?, create, #data, #executable?, #name, #null?, #type, #writable?

Constructor Details

#initialize(header, stream, section_at: nil, **_kwargs) ⇒ VersionNeedSection

Parameters:



22
23
24
25
# File 'lib/elftools/sections/version_need_section.rb', line 22

def initialize(header, stream, section_at: nil, **_kwargs)
  @section_at = section_at
  super
end

Instance Method Details

#requirementsArray<ELFTools::VersionTables::Requirement>

The versions this file needs of the files it is loaded with.

Examples:

section.requirements.map { |need| [need.file, need.versions.map(&:name)] }
#=> [['libc.so.6', ['GLIBC_2.4', 'GLIBC_2.2.5']]]

Returns:



33
34
35
36
37
# File 'lib/elftools/sections/version_need_section.rb', line 33

def requirements
  @requirements ||= VersionTables.new(stream, @section_at.call(header.sh_link),
                                      endian: header.class.self_endian)
                                 .requirements(header.sh_offset.to_i, header.sh_info.to_i)
end