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
-
#stream ⇒ #pos=, #read
readonly
Streaming object.
Instance Method Summary collapse
-
#header ⇒ ELFTools::Structs::ELF_Dyn
The structure the file records this tag in.
-
#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?.
-
#type ⇒ Integer
What kind of tag this is, which Constants::DT names.
-
#value ⇒ Integer, String
Return the content of this tag records.
Constructor Details
#initialize(header, stream, strtab) ⇒ Tag
Instantiate a ELFTools::Dynamic::Tag object.
20 21 22 23 24 |
# File 'lib/elftools/dynamic/tag.rb', line 20 def initialize(header, stream, strtab) @fields = header.is_a?(Structs::Fields) ? header : Structs::Fields.of(header) @stream = stream @strtab = strtab end |
Instance Attribute Details
#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
#header ⇒ ELFTools::Structs::ELF_Dyn
The structure the file records this tag in.
One is built here for a tag read without it, which is what assigning to a field of one needs and what ELFFile#patches reports the changes of.
32 33 34 |
# File 'lib/elftools/dynamic/tag.rb', line 32 def header @fields.struct end |
#name ⇒ String?
Return the name of this tag.
Only tags with name would return a name.
Others would return nil.
81 82 83 84 85 |
# File 'lib/elftools/dynamic/tag.rb', line 81 def name return nil unless name? @strtab.name_at(@fields[:d_val]) end |
#name? ⇒ Boolean
Is this tag has a name?
The criteria here is if this tag's type is in TYPE_WITH_NAME.
72 73 74 |
# File 'lib/elftools/dynamic/tag.rb', line 72 def name? TYPE_WITH_NAME.include?(type) end |
#type ⇒ Integer
What kind of tag this is, which Constants::DT names.
41 42 43 |
# File 'lib/elftools/dynamic/tag.rb', line 41 def type @fields[: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.
64 65 66 |
# File 'lib/elftools/dynamic/tag.rb', line 64 def value name || @fields[:d_val] end |