Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
david942j committed Oct 25, 2018
1 parent 52d4261 commit b9a4821
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 10 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ GEM
bindata (2.4.4)
coderay (1.1.2)
diff-lcs (1.3)
docile (1.3.0)
docile (1.3.1)
jaro_winkler (1.5.1)
json (2.1.0)
method_source (0.9.0)
parallel (1.12.1)
parser (2.5.1.0)
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
pry (0.11.3)
Expand All @@ -30,22 +30,22 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.57.2)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand All @@ -62,9 +62,9 @@ DEPENDENCIES
pry (~> 0.10)
rake (~> 12.1)
rspec (~> 3.7)
rubocop (~> 0.54)
rubocop (~> 0.59)
simplecov (~> 0.16.1)
yard (~> 0.9)

BUNDLED WITH
1.16.1
1.16.6
2 changes: 1 addition & 1 deletion elftools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry', '~> 0.10'
s.add_development_dependency 'rake', '~> 12.1'
s.add_development_dependency 'rspec', '~> 3.7'
s.add_development_dependency 'rubocop', '~> 0.54'
s.add_development_dependency 'rubocop', '~> 0.59'
s.add_development_dependency 'simplecov', '~> 0.16.1'
s.add_development_dependency 'yard', '~> 0.9'
end
4 changes: 4 additions & 0 deletions lib/elftools/dynamic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Dynamic
# Otherwise, return array of tags.
def each_tags(&block)
return enum_for(:each_tags) unless block_given?

arr = []
0.step do |i|
tag = tag_at(i).tap(&block)
Expand Down Expand Up @@ -77,8 +78,10 @@ def tag_by_type(type)
# @return [ELFTools::Dynamic::Tag] The desired tag.
def tag_at(n)
return if n < 0

@tag_at_map ||= {}
return @tag_at_map[n] if @tag_at_map[n]

dyn = Structs::ELF_Dyn.new(endian: endian)
dyn.elf_class = header.elf_class
stream.pos = tag_start + n * dyn.num_bytes
Expand Down Expand Up @@ -153,6 +156,7 @@ def name?
# @return [String, nil] The name.
def name
return nil unless name?

Util.cstring(stream, @str_offset.call + header.d_val.to_i)
end
end
Expand Down
8 changes: 8 additions & 0 deletions lib/elftools/elf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def initialize(stream)
# @return [ELFTools::Structs::ELF_Ehdr] The header.
def header
return @header if defined?(@header)

stream.pos = 0
@header = Structs::ELF_Ehdr.new(endian: endian, offset: stream.pos)
@header.elf_class = elf_class
Expand All @@ -49,8 +50,10 @@ def header
def build_id
section = section_by_name('.note.gnu.build-id')
return nil if section.nil?

note = section.notes.first
return nil if note.nil?

note.desc.unpack('H*').first
end

Expand Down Expand Up @@ -116,6 +119,7 @@ def section_by_name(name)
# otherwise, the whole sections will be returned.
def each_sections(&block)
return enum_for(:each_sections) unless block_given?

Array.new(num_sections) do |i|
section_at(i).tap(&block)
end
Expand Down Expand Up @@ -188,6 +192,7 @@ def num_segments
# Whole segments will be returned.
def each_segments(&block)
return enum_for(:each_segments) unless block_given?

Array.new(num_segments) do |i|
segment_at(i).tap(&block)
end
Expand Down Expand Up @@ -324,6 +329,7 @@ def loaded_headers
explore = lambda do |obj|
return obj if obj.is_a?(::ELFTools::Structs::ELFStruct)
return obj.map(&explore) if obj.is_a?(Array)

obj.instance_variables.map do |s|
explore.call(obj.instance_variable_get(s))
end
Expand All @@ -335,12 +341,14 @@ def identify
stream.pos = 0
magic = stream.read(4)
raise ELFError, "Invalid magic number #{magic.inspect}" unless magic == Constants::ELFMAG

ei_class = stream.read(1).ord
@elf_class = {
1 => 32,
2 => 64
}[ei_class]
raise ELFError, format('Invalid EI_CLASS "\x%02x"', ei_class) if elf_class.nil?

ei_data = stream.read(1).ord
@endian = {
1 => :little,
Expand Down
1 change: 1 addition & 0 deletions lib/elftools/lazy_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(size, &block)
def [](i)
# XXX: support negative index?
return nil if i < 0 || i >= @internal.size

@internal[i] ||= @block.call(i)
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/elftools/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module Note
# Otherwise, return the array of notes.
def each_notes
return enum_for(:each_notes) unless block_given?

@notes_offset_map ||= {}
cur = note_start
notes = []
Expand Down Expand Up @@ -101,14 +102,16 @@ def initialize(header, stream, offset)
# @return [String] The name.
def name
return @name if @name

stream.pos = @offset + SIZE_OF_NHDR
@name = stream.read(header.n_namesz)[0..-2]
end

# Description of this note.
# @return [String] The description.
def desc
return @desc if @desc
return @desc if instance_variable_defined?(:@desc)

stream.pos = @offset + SIZE_OF_NHDR + Util.align(header.n_namesz, 2)
@desc = stream.read(header.n_descsz)
end
Expand Down
1 change: 1 addition & 0 deletions lib/elftools/sections/relocation_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def relocation_at(n)
# Otherwise, the whole relocations will be returned.
def each_relocations(&block)
return enum_for(:each_relocations) unless block_given?

Array.new(num_relocations) do |i|
relocation_at(i).tap(&block)
end
Expand Down
1 change: 1 addition & 0 deletions lib/elftools/sections/sym_tab_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def symbol_at(n)
# Otherwise return array of symbols.
def each_symbols(&block)
return enum_for(:each_symbols) unless block_given?

Array.new(num_symbols) do |i|
symbol_at(i).tap(&block)
end
Expand Down
1 change: 1 addition & 0 deletions lib/elftools/structs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def self_endian
# @return [String]
def pack(val, bytes)
raise ArgumentError, "Not supported assign type #{val.class}" unless val.is_a?(Integer)

number = val & ((1 << (8 * bytes)) - 1)
out = []
bytes.times do
Expand Down
4 changes: 4 additions & 0 deletions lib/elftools/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module ClassMethods
def align(num, bit)
n = 2**bit
return num if (num % n).zero?

(num + n) & ~(n - 1)
end

Expand All @@ -36,13 +37,15 @@ def to_constant(mod, val)
# if val is an integer, check if exists in mod
if val.is_a?(Integer)
return val if mod.constants.any? { |c| mod.const_get(c) == val }

raise ArgumentError, "No constants in #{module_name} is #{val}"
end
val = val.to_s.upcase
prefix = module_name.split('::')[-1]
val = prefix + '_' + val unless val.start_with?(prefix)
val = val.to_sym
raise ArgumentError, "No constants in #{module_name} named \"#{val}\"" unless mod.const_defined?(val)

mod.const_get(val)
end

Expand All @@ -61,6 +64,7 @@ def cstring(stream, offset)
c = stream.read(1)
return nil if c.nil? # reach EOF
break if c == "\x00"

ret += c
end
ret
Expand Down

0 comments on commit b9a4821

Please sign in to comment.