ony-ruby-elf 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright © 2007-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this generator; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ # This script is used to harvest the symbols defined in the shared
20
+ # objects of the whole system.
21
+
22
+ require 'getoptlong'
23
+ require 'postgres'
24
+
25
+ opts = GetoptLong.new(
26
+ ["--suppressions", "-s", GetoptLong::REQUIRED_ARGUMENT ],
27
+ ["--postgres-username", "-U", GetoptLong::REQUIRED_ARGUMENT ],
28
+ ["--postgres-password", "-P", GetoptLong::REQUIRED_ARGUMENT ],
29
+ ["--postgres-hostname", "-H", GetoptLong::REQUIRED_ARGUMENT ],
30
+ ["--postgres-port", "-T", GetoptLong::REQUIRED_ARGUMENT ],
31
+ ["--postgres-database", "-D", GetoptLong::REQUIRED_ARGUMENT ]
32
+ )
33
+
34
+ suppression_files = File.exist?('suppressions') ? [ 'suppressions' ] : []
35
+
36
+ pg_params = {}
37
+
38
+ opts.each do |opt, arg|
39
+ case opt
40
+ when '--suppressions'
41
+ unless File.exist? arg
42
+ $stderr.puts "harvest.rb: no such file or directory - #{arg}"
43
+ exit -1
44
+ end
45
+ suppression_files << arg
46
+ when '--postgres-username' then pg_params['user'] = arg
47
+ when '--postgres-password' then pg_params['password'] = arg
48
+ when '--postgres-hostname' then pg_params['host'] = arg
49
+ when '--postgres-port' then pg_params['port'] = arg
50
+ when '--postgres-database' then pg_params['dbname'] = arg
51
+ end
52
+ end
53
+
54
+ db = PGconn.open(pg_params)
55
+
56
+ db.exec("BEGIN TRANSACTION")
57
+
58
+ # Total suppressions are for directories to skip entirely
59
+ # Partial suppressions are the ones that apply only to a subset
60
+ # of symbols.
61
+ suppression_files.each do |suppression|
62
+ File.open(suppression) do |file|
63
+ file.each_line do |line|
64
+ path, symbols = line.
65
+ gsub(/#\s.*/, '').
66
+ strip.
67
+ split(/\s+/, 2)
68
+
69
+ next unless path
70
+
71
+ if not symbols or symbols == ""
72
+ # the POSIX regular expressions and the Ruby ones differ from
73
+ # how + and \+ are used. PgSQL uses POSIX.
74
+ path = path.gsub('+', '\+').gsub('\\+', '+')
75
+ db.exec("DELETE FROM objects WHERE name ~ '#{path}'")
76
+ else
77
+ symbols.sub!(/(\$)?$/, '@\1')
78
+ db.exec("DELETE FROM symbols WHERE symbol ~ '#{symbols}' AND object IN (SELECT id FROM objects WHERE name ~ '#{path}')")
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ db.exec("COMMIT")
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright © 2007-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this generator; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ # Proof of Concept tool to implement ldd-like dependency scan with
20
+ # dependency tree. It is similar to lddtree.sh script as provided by
21
+ # scanelf, but not the same thing.
22
+
23
+ require 'elf'
24
+ require 'elf/utils/loader'
25
+
26
+ require 'set'
27
+
28
+ $seen_libraries = Set.new
29
+
30
+ def print_dependency_list(elf, indent_level)
31
+ elf[".dynamic"].needed_libraries.each_pair do |soname, lib|
32
+ case
33
+ when lib.nil?
34
+ puts "#{" "*indent_level}#{soname} => not found"
35
+ when $seen_libraries.include?(lib.path)
36
+ puts "#{" "*indent_level}#{soname} => #{lib.path} +"
37
+ else
38
+ puts "#{" "*indent_level}#{soname} => #{lib.path}"
39
+ print_dependency_list(lib, indent_level+1)
40
+
41
+ $seen_libraries |= lib.path
42
+ end
43
+ end
44
+ end
45
+
46
+ Elf::File.open(ARGV[0]) do |elf|
47
+ puts ARGV[0]
48
+ print_dependency_list(elf, 1)
49
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ony-ruby-elf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Diego Elio Pettenò
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ Ruby-Elf is a pure-Ruby library for parse and fetch information about
15
+ ELF format used by Linux, FreeBSD, Solaris and other Unix-like
16
+ operating systems, and include a set of analysis tools helpful for
17
+ both optimisations and verification of compiled ELF files.
18
+ email: flameeyes@flameeyes.eu
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - COPYING
24
+ - DONATING
25
+ - README.md
26
+ - lib/bytestream-reader.rb
27
+ - lib/elf.rb
28
+ - lib/elf/dynamic.rb
29
+ - lib/elf/file.rb
30
+ - lib/elf/gnu.rb
31
+ - lib/elf/section.rb
32
+ - lib/elf/stringtable.rb
33
+ - lib/elf/sunw.rb
34
+ - lib/elf/symbol.rb
35
+ - lib/elf/symboltable.rb
36
+ - lib/elf/tools.rb
37
+ - lib/elf/utils/loader.rb
38
+ - lib/elf/utils/offsettable.rb
39
+ - lib/elf/utils/pool.rb
40
+ - lib/elf/value.rb
41
+ - ruby-elf.gemspec
42
+ - tools/assess_duplicate_save.rb
43
+ - tools/link-collisions/harvest.rb
44
+ - tools/link-collisions/suppress.rb
45
+ - tools/rbelf-lddtree.rb
46
+ homepage: http://www.flameeyes.eu/projects/ruby-elf
47
+ licenses:
48
+ - GPL-2 or later
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements:
65
+ - none
66
+ rubyforge_project:
67
+ rubygems_version: 2.4.5
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Pure Ruby ELF file parser and utilities
71
+ test_files: []