Class: Elf::SunW::Capabilities

Inherits:
Elf::Section show all
Defined in:
lib/elf/sunw.rb

Defined Under Namespace

Modules: Hardware1 Classes: Software1, Tag

Constant Summary

Constants inherited from Elf::Section

Elf::Section::Abs, Elf::Section::Common, Elf::Section::FlagsToChars, Elf::Section::OsSpecific, Elf::Section::ProcSpecific, Elf::Section::Reserved, Elf::Section::SunW, Elf::Section::SunWIgnore, Elf::Section::Undef, Elf::Section::XIndex

Instance Attribute Summary

Attributes inherited from Elf::Section

#addr, #addralign, #entsize, #file, #index, #info, #offset, #type

Instance Method Summary collapse

Methods inherited from Elf::Section

#==, #flags, #flags_i, #flags_s, #initialize, #link, #load, #name, read, #summary

Constructor Details

This class inherits a constructor from Elf::Section

Instance Method Details

#[](idx) ⇒ Object



151
152
153
154
155
# File 'lib/elf/sunw.rb', line 151

def [](idx)
  load unless @entries
  
  @entries[idx]
end

#load_internalObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/elf/sunw.rb', line 97

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

#sizeObject



145
146
147
148
149
# File 'lib/elf/sunw.rb', line 145

def size
  load unless @entries
  
  @entries.size
end