Class: ELFTools::Dynamic::Tag
- Inherits:
-
Object
- Object
- ELFTools::Dynamic::Tag
- Defined in:
- lib/elftools/dynamic.rb
Overview
A tag class.
Constant Summary collapse
- TYPE_WITH_NAME =
Some dynamic have name.
[Constants::DT_NEEDED, Constants::DT_SONAME, Constants::DT_RPATH, Constants::DT_RUNPATH].freeze
Instance Attribute Summary collapse
-
#header ⇒ ELFTools::Structs::ELF_Dyn
readonly
The dynamic tag header.
-
#stream ⇒ #pos=, #read
readonly
Streaming object.
Instance Method Summary collapse
-
#initialize(header, stream, str_offset) ⇒ Tag
constructor
Instantiate a Tag object.
-
#name ⇒ String?
Return the name of this tag.
-
#name? ⇒ Boolean
Is this tag has a name?.
-
#value ⇒ Integer, String
Return the content of this tag records.
Constructor Details
#initialize(header, stream, str_offset) ⇒ Tag
Instantiate a ELFTools::Dynamic::Tag object.
129 130 131 132 133 |
# File 'lib/elftools/dynamic.rb', line 129 def initialize(header, stream, str_offset) @header = header @stream = stream @str_offset = str_offset end |
Instance Attribute Details
#header ⇒ ELFTools::Structs::ELF_Dyn (readonly)
Returns The dynamic tag header.
120 121 122 |
# File 'lib/elftools/dynamic.rb', line 120 def header @header end |
#stream ⇒ #pos=, #read (readonly)
Returns Streaming object.
121 122 123 |
# File 'lib/elftools/dynamic.rb', line 121 def stream @stream end |
Instance Method Details
#name ⇒ String?
Return the name of this tag.
Only tags with name would return a name. Others would return nil
.
171 172 173 174 175 |
# File 'lib/elftools/dynamic.rb', line 171 def name return nil unless name? Util.cstring(stream, @str_offset.call + header.d_val.to_i) end |
#name? ⇒ Boolean
Is this tag has a name?
The criteria here is if this tag’s type is in TYPE_WITH_NAME.
162 163 164 |
# File 'lib/elftools/dynamic.rb', line 162 def name? TYPE_WITH_NAME.include?(header.d_tag) end |
#value ⇒ Integer, String
Return the content of this tag records.
For normal tags, this method just return header.d_val
. For tags with header.d_val
in meaning of string offset (e.g. DT_NEEDED), this method would return the string it specified. Tags with type in TYPE_WITH_NAME are those tags with name.
154 155 156 |
# File 'lib/elftools/dynamic.rb', line 154 def value name || header.d_val.to_i end |