Module: ELFTools::Note
- Included in:
- Sections::NoteSection, Segments::NoteSegment
- Defined in:
- lib/elftools/note.rb
Overview
Note:
This module can only be included in Sections::NoteSection and Segments::NoteSegment since some methods here assume some attributes already exist.
Since both note sections and note segments refer to notes, this module defines common methods for Sections::NoteSection and Segments::NoteSegment.
Defined Under Namespace
Classes: Note
Constant Summary collapse
- SIZE_OF_NHDR =
Since size of Structs::ELF_Nhdr will not change no matter in what endian and what arch, we can do this here. This value should equal to 12.
Structs::ELF_Nhdr.new(endian: :little).num_bytes
Instance Method Summary collapse
-
#each_note ⇒ Enumerator<ELFTools::Note::Note>, Array<ELFTools::Note::Note>
(also: #each_notes)
Iterate all notes in a note section or segment.
-
#notes ⇒ Array<ELFTools::Note::Note>
Simply
#notesto get all notes.
Instance Method Details
#each_note ⇒ Enumerator<ELFTools::Note::Note>, Array<ELFTools::Note::Note> Also known as: each_notes
Note:
This method assume following methods exist:
stream
note_start
note_total_sizeIterate all notes in a note section or segment.
Structure of notes are:
+---------------+
| Note 1 header |
+---------------+
| Note 1 name |
+---------------+
| Note 1 desc |
+---------------+
| Note 2 header |
+---------------+
| ... |
+---------------+
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elftools/note.rb', line 44 def each_note return enum_for(:each_note) unless block_given? @notes_offset_map ||= {} cur = note_start notes = [] while cur < note_start + note_total_size stream.pos = cur @notes_offset_map[cur] ||= create_note(cur) note = @notes_offset_map[cur] # name and desc size needs to be 4-bytes align name_size = Util.align(note.header.n_namesz, 2) desc_size = Util.align(note.header.n_descsz, 2) cur += SIZE_OF_NHDR + name_size + desc_size notes << note yield note end notes end |
#notes ⇒ Array<ELFTools::Note::Note>
Simply #notes to get all notes.
70 71 72 |
# File 'lib/elftools/note.rb', line 70 def notes each_note.to_a end |