Class: Dply::Elf

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/dply/elf.rb

Constant Summary collapse

MAGIC_STRING =
"\177ELF"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#cmd, #error, #git, #logger, #sh, #symlink

Constructor Details

#initialize(path) ⇒ Elf

Returns a new instance of Elf.



18
19
20
21
# File 'lib/dply/elf.rb', line 18

def initialize(path)
  @path = Pathname.new(path)
  @elf = ::Elf::File.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/dply/elf.rb', line 16

def path
  @path
end

Class Method Details

.elf?(path) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/dply/elf.rb', line 11

def self.elf?(path)
  return false if not File.file? path
  IO.binread(path, 4) == MAGIC_STRING
end

Instance Method Details

#external_libsObject



23
24
25
26
27
28
29
# File 'lib/dply/elf.rb', line 23

def external_libs
  return [] if not @elf.has_section? ".dynamic"
  dynamic = dynamic_libs()
  external = dynamic.reject { |i| lib_in_relative_rpath? i }.map { |l| "#{l}#{lib_type}" }
  logger.debug { "[#{@path}]: dynamic:#{dynamic.size} rpath:#{dynamic.size - external.size} ext:#{external.size}" } if logger.debug?
  external
end