class Elf::SunW::Capabilities

Public Instance Methods

[](idx) click to toggle source
# File lib/elf/sunw.rb, line 150
def [](idx)
  load unless @entries
  
  @entries[idx]
end
load_internal() click to toggle source
# File lib/elf/sunw.rb, line 96
def load_internal
  elf32 = @file.elf_class == Class::Elf32

  @entries = []
  loop do
    entry = {}
    tag = elf32 ? @file.read_word : @file.read_xword
    entry[:tag] = Tag[tag]

    # This marks the end of the array.
    break if entry[:tag] == Tag::Null

    # Right now the only two types used make only use of c_val,
    # but in the future there might be capabilities using c_ptr,
    # so prepare for that.
    case entry[:tag]
    when Tag::SF1
      val = elf32 ? @file.read_word : @file.read_xword
      entry[:flags] = Set.new
      
      Software1.each do |flag|
        entry[:flags].add(flag) if (val & flag.val) == flag.val
      end
    when Tag::HW1
      val = elf32 ? @file.read_word : @file.read_xword
      entry[:flags] = Set.new

      case @file.machine
      when Machine::Sparc
        Hardware1::Sparc.each do |flag|
          entry[:flags].add(flag) if (val & flag.val) == flag.val
        end
      when Machine::I386
        Hardware1::I386.each do |flag|
          entry[:flags].add(flag) if (val & flag.val) == flag.val
        end
      else
        raise "Sun-specific extensions only support i386/Sparc!"
      end
          
    else
      entry[:ptr] = @file.read_addr
    end

    @entries << entry
  end
end
size() click to toggle source
# File lib/elf/sunw.rb, line 144
def size
  load unless @entries
  
  @entries.size
end