Class: ELFTools::Dynamic::Tag
- Inherits:
-
Object
- Object
- ELFTools::Dynamic::Tag
- Defined in:
- lib/elftools/dynamic/tag.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, strtab) ⇒ 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, strtab) ⇒ Tag
Instantiate a ELFTools::Dynamic::Tag object.
17 18 19 20 21 |
# File 'lib/elftools/dynamic/tag.rb', line 17 def initialize(header, stream, strtab) @header = header @stream = stream @strtab = strtab end |
Instance Attribute Details
#header ⇒ ELFTools::Structs::ELF_Dyn (readonly)
Returns The dynamic tag header.
9 10 11 |
# File 'lib/elftools/dynamic/tag.rb', line 9 def header @header end |
#stream ⇒ #pos=, #read (readonly)
Returns Streaming object.
10 11 12 |
# File 'lib/elftools/dynamic/tag.rb', line 10 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.
59 60 61 62 63 |
# File 'lib/elftools/dynamic/tag.rb', line 59 def name return nil unless name? @strtab.name_at(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.
50 51 52 |
# File 'lib/elftools/dynamic/tag.rb', line 50 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.
42 43 44 |
# File 'lib/elftools/dynamic/tag.rb', line 42 def value name || header.d_val.to_i end |