Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required Ruby version >= 2.3 #40

Merged
merged 1 commit into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions elftools.gemspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'elftools/version'

require 'date'

require 'elftools/version'

Gem::Specification.new do |s|
s.name = 'elftools'
s.version = ::ELFTools::VERSION
Expand All @@ -17,14 +19,14 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/*.rb'] + %w(README.md)
s.homepage = 'https://github.com/david942j/rbelftools'
s.license = 'MIT'
s.required_ruby_version = '>= 2.1.0'
s.required_ruby_version = '>= 2.3'

s.add_runtime_dependency 'bindata', '~> 2'

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.59'
s.add_development_dependency 'simplecov', '~> 0.16.1'
s.add_development_dependency 'simplecov', '~> 0.17'
s.add_development_dependency 'yard', '~> 0.9'
end
2 changes: 2 additions & 0 deletions lib/elftools.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/constants'
require 'elftools/elf_file'
require 'elftools/version'
Expand Down
4 changes: 3 additions & 1 deletion lib/elftools/constants.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module ELFTools
# Define constants from elf.h.
# Mostly refer from https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h
# and binutils/elfcpp/elfcpp.h.
module Constants
# ELF magic header
ELFMAG = "\x7FELF".freeze
ELFMAG = "\x7FELF"

# Values of `d_un.d_val' in the DT_FLAGS and DT_FLAGS_1 entry.
module DF
Expand Down
4 changes: 3 additions & 1 deletion lib/elftools/dynamic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ELFTools
# Define common methods for dynamic sections and dynamic segments.
#
Expand Down Expand Up @@ -89,7 +91,7 @@ def tags_by_type(type)
# @param [Integer] n The index.
# @return [ELFTools::Dynamic::Tag] The desired tag.
def tag_at(n)
return if n < 0
return if n.negative?

@tag_at_map ||= {}
return @tag_at_map[n] if @tag_at_map[n]
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/elf_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/constants'
require 'elftools/exceptions'
require 'elftools/lazy_array'
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ELFTools
# Being raised when parsing error.
class ELFError < StandardError; end
Expand Down
4 changes: 3 additions & 1 deletion lib/elftools/lazy_array.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ELFTools
# A helper class for {ELFTools} easy to implement
# 'lazy loading' objects.
Expand Down Expand Up @@ -37,7 +39,7 @@ def initialize(size, &block)
# return type of block given in {#initialize}.
def [](i)
# XXX: support negative index?
return nil if i < 0 || i >= @internal.size
return nil unless i.between?(0, @internal.size - 1)

@internal[i] ||= @block.call(i)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/note.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/structs'
require 'elftools/util'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/dynamic_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/dynamic'
require 'elftools/sections/section'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/note_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/note'
require 'elftools/sections/section'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/null_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/sections/section'

module ELFTools
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/relocation_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/constants'
require 'elftools/sections/section'
require 'elftools/structs'
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/constants'
module ELFTools
module Sections
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/sections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Require this file to load all sections classes.

require 'elftools/sections/section'
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/str_tab_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/sections/section'
require 'elftools/util'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/sections/sym_tab_section.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/sections/section'

module ELFTools
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/dynamic_segment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/segments/segment'
require 'elftools/dynamic'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/interp_segment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/segments/segment'

module ELFTools
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/load_segment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/segments/segment'

module ELFTools
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/note_segment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/note'
require 'elftools/segments/segment'

Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/segment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ELFTools
module Segments
# Base class of segments.
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/segments/segments.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Require this file to load all segment classes.

require 'elftools/segments/segment'
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/structs.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bindata'
module ELFTools
# Define ELF related structures in this module.
Expand Down
2 changes: 2 additions & 0 deletions lib/elftools/util.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ELFTools
# Define some util methods.
module Util
Expand Down
4 changes: 3 additions & 1 deletion lib/elftools/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

module ELFTools
# Current gem version
VERSION = '1.1.0'.freeze
VERSION = '1.1.0'
end
2 changes: 2 additions & 0 deletions spec/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/constants'

describe ELFTools::Constants do
Expand Down
2 changes: 2 additions & 0 deletions spec/dynamic_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/elf_file'

describe ELFTools::Dynamic do
Expand Down
1 change: 1 addition & 0 deletions spec/elf_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: ascii-8bit
# frozen_string_literal: true

require 'tempfile'

Expand Down
2 changes: 2 additions & 0 deletions spec/full_test/i386_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools'

describe 'Full test for i386' do
Expand Down
2 changes: 2 additions & 0 deletions spec/full_test/pie_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools'

describe 'Full test for PIE' do
Expand Down
2 changes: 2 additions & 0 deletions spec/full_test/relro_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools'

describe 'Full test for relro types' do
Expand Down
2 changes: 2 additions & 0 deletions spec/full_test/so_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools'

describe 'Full test for shared object' do
Expand Down
2 changes: 2 additions & 0 deletions spec/full_test/striped_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools'

describe 'Full test for striped binary' do
Expand Down
1 change: 1 addition & 0 deletions spec/sections_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: ascii-8bit
# frozen_string_literal: true

require 'elftools/sections/sections'
require 'elftools/structs'
Expand Down
1 change: 1 addition & 0 deletions spec/segments_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: ascii-8bit
# frozen_string_literal: true

require 'elftools/segments/segments'
require 'elftools/structs'
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[SimpleCov::Formatter::HTMLFormatter]
Expand Down
2 changes: 2 additions & 0 deletions spec/util_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'elftools/util'

describe ELFTools::Util do
Expand Down