ruby-elf 1.0.6.1 → 1.0.7

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.
Files changed (45) hide show
  1. data/DONATING +1 -1
  2. data/bin/cowstats +1 -1
  3. data/bin/elfgrep +55 -16
  4. data/bin/missingstatic +1 -1
  5. data/bin/rbelf-nm +46 -11
  6. data/bin/rbelf-read +4 -6
  7. data/bin/rbelf-size +4 -2
  8. data/bin/verify-lfs +1 -1
  9. data/extras/bindings-parsers.rb +1 -1
  10. data/lib/bytestream-reader.rb +1 -1
  11. data/lib/elf.rb +2 -2
  12. data/lib/elf/dynamic.rb +2 -2
  13. data/lib/elf/file.rb +10 -1
  14. data/lib/elf/gnu.rb +1 -1
  15. data/lib/elf/section.rb +1 -1
  16. data/lib/elf/stringtable.rb +4 -14
  17. data/lib/elf/sunw.rb +1 -1
  18. data/lib/elf/symbol.rb +43 -37
  19. data/lib/elf/symboltable.rb +1 -1
  20. data/lib/elf/tools.rb +3 -2
  21. data/lib/elf/utils/loader.rb +1 -1
  22. data/lib/elf/utils/offsettable.rb +49 -0
  23. data/lib/elf/utils/pool.rb +1 -1
  24. data/lib/elf/value.rb +1 -1
  25. data/manpages/cowstats.1 +2 -2
  26. data/manpages/cowstats.1.xml +1 -1
  27. data/manpages/elfgrep.1 +39 -5
  28. data/manpages/elfgrep.1.xml +53 -2
  29. data/manpages/missingstatic.1 +2 -2
  30. data/manpages/missingstatic.1.xml +1 -1
  31. data/manpages/rbelf-nm.1 +18 -3
  32. data/manpages/rbelf-nm.1.xml +41 -1
  33. data/manpages/rbelf-size.1 +2 -2
  34. data/manpages/rbelf-size.1.xml +1 -1
  35. data/manpages/verify-lfs.1 +2 -2
  36. data/manpages/verify-lfs.1.xml +1 -1
  37. data/tools/assess_duplicate_save.rb +1 -1
  38. data/tools/link-collisions/harvest.rb +19 -9
  39. data/tools/link-collisions/known-broken +7 -18
  40. data/tools/link-collisions/multimplementations +35 -4
  41. data/tools/link-collisions/suppress.rb +1 -1
  42. data/tools/link-collisions/suppressions +22 -18
  43. data/tools/rbelf-lddtree.rb +1 -1
  44. metadata +13 -16
  45. data/lib/elf/symbol/demangler_gcc3.rb +0 -1952
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Simple ELF parser for Ruby
3
3
  #
4
- # Copyright © 2008-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
4
+ # Copyright © 2008-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
5
5
  # Portions inspired by elf.py
6
6
  # Copyright © 2002 Netgraft Corporation
7
7
  # Portions inspired by elf.h
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Simple ELF parser for Ruby
3
3
  #
4
- # Copyright © 2007-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
4
+ # Copyright © 2007-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
5
5
  # Portions inspired by elf.py
6
6
  # Copyright © 2002 Netgraft Corporation
7
7
  # Portions inspired by elf.h
@@ -160,7 +160,7 @@ module Elf
160
160
  if @name.is_a? Integer and @symsect.link
161
161
  begin
162
162
  name = @symsect.link[@name]
163
- rescue StringTable::InvalidIndex
163
+ rescue Utilities::OffsetTable::InvalidIndex
164
164
  raise InvalidName.new(@name, self, @symsect)
165
165
  end
166
166
  @name = name if name
@@ -196,10 +196,14 @@ module Elf
196
196
 
197
197
  return '' if version_idx == 1
198
198
 
199
- if section.nil? or @file['.gnu.version_d'][version_idx].nil?
199
+ begin
200
+ if section.nil?
201
+ return @file['.gnu.version_r'][version_idx][:name]
202
+ else
203
+ return @file['.gnu.version_d'][version_idx][:names][0]
204
+ end
205
+ rescue Elf::File::MissingSection
200
206
  return @file['.gnu.version_r'][version_idx][:name]
201
- else
202
- return @file['.gnu.version_d'][version_idx][:names][0]
203
207
  end
204
208
  end
205
209
 
@@ -262,12 +266,14 @@ module Elf
262
266
 
263
267
  when bind == Binding::Weak
264
268
  nmflag = case type
265
- when Type::Object then "V"
266
- else "W"
269
+ when Type::Object then 'V'
270
+ # we cannot use 'v' when value is zero, as for a
271
+ # variable, a zero address is correct, it's just
272
+ # functions that cannot be at zero address.
273
+ when value == 0 then 'w'
274
+ else 'W'
267
275
  end
268
276
 
269
- nmflag.downcase! if value == 0
270
-
271
277
  when bind == Binding::GNU::Unique
272
278
  nmflag = 'u'
273
279
 
@@ -291,7 +297,15 @@ module Elf
291
297
  end
292
298
 
293
299
  when type == Type::None
294
- nmflag = 'N'
300
+ # try being smarter than simply reporthing this as a none-type
301
+ # symbol, as some compilers (namely pathCC) emit STT_NONE
302
+ # symbols that are instead functions.
303
+ nmflag = case
304
+ when section.is_a?(Integer) then "N"
305
+ when section.flags.include?(Elf::Section::Flags::ExecInstr) then "T"
306
+ when section.type == Elf::Section::Type::NoBits then "B"
307
+ else "N"
308
+ end
295
309
  when type == Type::Func
296
310
  nmflag = 'T'
297
311
  when type == Type::Section
@@ -318,13 +332,7 @@ module Elf
318
332
  # Reports a string full of whitespace if the symbols is not
319
333
  # defined (as there is no address)
320
334
  def address_string
321
- addrsize = (@file.elf_class == Elf::Class::Elf32 ? 8 : 16)
322
-
323
- if section
324
- sprintf("%0#{addrsize}x", value)
325
- else
326
- ' ' * addrsize
327
- end
335
+ section ? sprintf("%0#{@file.address_print_size}x", value) : ''
328
336
  end
329
337
 
330
338
  # Check whether two symbols are the same
@@ -364,29 +372,27 @@ module Elf
364
372
  return true
365
373
  end
366
374
 
367
- begin
368
- require 'elf/symbol/demangler_gcc3'
369
-
370
- Demanglers = [ Elf::Symbol::Demangler::GCC3 ]
371
- def demangle
372
- return @demangled if @demangled
373
-
374
- Demanglers.each do |demangler|
375
- break if (@demangled ||= demangler.demangle(name))
376
- end
377
-
378
- # We're going to remove top-namespace specifications as we don't
379
- # need them, but it's easier for the demangler to still emit
380
- # them.
381
- @demangled.gsub!(/(^| |\()::/, '\1') if @demangled
382
-
383
- return @demangled ||= name
384
- end
385
- rescue LoadError
375
+ # begin
376
+ # Demanglers = [ ]
377
+ # def demangle
378
+ # return @demangled if @demangled
379
+ #
380
+ # Demanglers.each do |demangler|
381
+ # break if (@demangled ||= demangler.demangle(name))
382
+ # end
383
+ #
384
+ # # We're going to remove top-namespace specifications as we don't
385
+ # # need them, but it's easier for the demangler to still emit
386
+ # # them.
387
+ # @demangled.gsub!(/(^| |\()::/, '\1') if @demangled
388
+ #
389
+ # return @demangled ||= name
390
+ # end
391
+ # rescue LoadError
386
392
  def demangle
387
393
  return name
388
394
  end
389
- end
395
+ # end
390
396
 
391
397
  private
392
398
  def version_index
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Simple ELF parser for Ruby
3
3
  #
4
- # Copyright © 2007-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
4
+ # Copyright © 2007-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
5
5
  # Portions inspired by elf.py
6
6
  # Copyright © 2002 Netgraft Corporation
7
7
  # Portions inspired by elf.h
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright © 2008-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
2
+ # Copyright © 2008-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
3
3
  #
4
4
  # This program is free software; you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -224,7 +224,7 @@ module Elf
224
224
  # arguments.
225
225
  @targets = ARGV.collect { |argument|
226
226
  if argument[0..0] == "@"
227
- ::File.new(argument[1..-1]).read.split(/\r?\n/)
227
+ ::File.read(argument[1..-1]).split(/\r?\n/)
228
228
  else
229
229
  argument
230
230
  end
@@ -239,6 +239,7 @@ module Elf
239
239
  try_execute(input.sub(/\r?\n/, ''))
240
240
  }
241
241
  else
242
+ $stdin.close
242
243
  @targets.uniq.each { |target| try_execute(target) }
243
244
  end
244
245
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright © 2009-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
2
+ # Copyright © 2009-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
3
3
  #
4
4
  # This program is free software; you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Offset-based string table
3
+ #
4
+ # Copyright © 2007-2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
5
+ #
6
+ # This program is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this generator; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+
20
+ module Elf
21
+ module Utilities
22
+ class OffsetTable
23
+ class InvalidIndex < Exception
24
+ def initialize(idx, max_idx)
25
+ super("Invalid index #{idx} (maximum index: #{max_idx})")
26
+ end
27
+ end
28
+
29
+ def initialize(content, separator)
30
+ @content = content
31
+ @separator = separator
32
+ end
33
+
34
+ def size
35
+ @content.size
36
+ end
37
+
38
+ def [](idx)
39
+ raise InvalidIndex.new(idx, size) if idx >= size
40
+
41
+ # find the first occurrence of the separator starting from the
42
+ # given index
43
+ endidx = @content.index(@separator, idx)
44
+
45
+ return @content[idx..endidx].chomp(@separator)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright © 2009 Alex Legler <a3li@gentoo.org>
3
- # Copyright © 2009-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
3
+ # Copyright © 2009-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
4
4
  #
5
5
  # This program is free software; you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Simple ELF parser for Ruby
3
3
  #
4
- # Copyright © 2007-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
4
+ # Copyright © 2007-2010 Diego Elio Pettenò <flameeyes@flameeyes.eu>
5
5
  # Portions inspired by elf.py
6
6
  # Copyright © 2002 Netgraft Corporation
7
7
  # Portions inspired by elf.h
@@ -1,7 +1,7 @@
1
1
  '\" t
2
2
  .\" Title: cowstats
3
3
  .\" Author:
4
- .\" Generator: DocBook XSL-NS Stylesheets v1.76.0 <http://docbook.sf.net/>
4
+ .\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
5
5
  .\" Date: October 2008
6
6
  .\" Manual: Reference
7
7
  .\" Source: ruby-elf
@@ -171,7 +171,7 @@ Related tools:
171
171
  \fBobjdump\fR(1)\&.
172
172
  .SH "AUTHOR"
173
173
  .PP
174
- \fBDiego E. Pettenò\fR <\&flameeyes@gmail.com\&>
174
+ \fBDiego E. Pettenò\fR <\&flameeyes@flameeyes.eu\&>
175
175
  .RS 4
176
176
  Author and main contributor.
177
177
  .RE
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0'?>
2
2
  <!--
3
- Copyright © 2008-2011, Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
3
+ Copyright © 2008-2011, Diego Elio Pettenò <flameeyes@flameeyes.eu>
4
4
 
5
5
  This program is free software; you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,13 +1,13 @@
1
1
  '\" t
2
2
  .\" Title: elfgrep
3
3
  .\" Author:
4
- .\" Generator: DocBook XSL-NS Stylesheets v1.76.1 <http://docbook.sf.net/>
5
- .\" Date: January 2011
4
+ .\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
5
+ .\" Date: November 2011
6
6
  .\" Manual: Reference
7
7
  .\" Source: ruby-elf
8
8
  .\" Language: English
9
9
  .\"
10
- .TH "ELFGREP" "1" "January 2011" "ruby-elf" "Reference"
10
+ .TH "ELFGREP" "1" "November 2011" "ruby-elf" "Reference"
11
11
  .\" -----------------------------------------------------------------
12
12
  .\" * Define some portability stuff
13
13
  .\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
31
31
  elfgrep \- Search for symbols matching an expression in ELF files
32
32
  .SH "SYNOPSIS"
33
33
  .HP \w'\fBelfgrep\fR\ 'u
34
- \fBelfgrep\fR [\fB\-\-fixed\-strings\fR] [\fB\-\-ignore\-case\fR] [\fB\-\-match\-version\fR] [\fB\-\-match\-undefined\fR | \fB\-\-match\-defined\fR] [\fB\-\-invert\-match\fR] [\fB\-\-count\fR] [\fB\-\-files\-without\-match\fR | \fB\-\-files\-with\-matches\fR] [\fB\-\-with\-filename\fR | \fB\-\-no\-filename\fR] [\fB\-\-null\fR] [\fB\-\-quiet\fR] [\fB\-\-recursive\fR] {\fB\-\-regexp\fR\ \fIPATTERN\fR... | \fIPATTERN\fR} [\fB@\fR\fIfile\fR | \fIfile\fR...]
34
+ \fBelfgrep\fR [\fB\-\-fixed\-strings\fR] [\fB\-\-ignore\-case\fR] [\fB\-\-match\-version\fR] [\fB\-\-match\-undefined\fR | \fB\-\-match\-defined\fR] [\fB\-\-invert\-match\fR] [\fB\-\-count\fR] [\fB\-\-files\-without\-match\fR | \fB\-\-files\-with\-matches\fR] [\fB\-\-with\-filename\fR | \fB\-\-no\-filename\fR] [\fB\-\-null\fR] [\fB\-\-symbol\-regexp\fR] [\fB\-\-quiet\fR] [\fB\-\-recursive\fR] {\fB\-\-regexp\fR\ \fIPATTERN\fR... | \fB\-\-file\fR\ \fIFILE\fR... | \fIPATTERN\fR} [\fB@\fR\fIfile\fR | \fIfile\fR...]
35
35
  .SH "DESCRIPTION"
36
36
  .PP
37
37
 
@@ -56,6 +56,35 @@ Use
56
56
  as the pattern\&. This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (\-)\&.
57
57
  .RE
58
58
  .PP
59
+ \fB\-f\fR \fIFILE\fR, \fB\-\-file\fR \fIFILE\fR
60
+ .RS 4
61
+ Obtain patterns from
62
+ \fIFILE\fR, one per line\&.
63
+ .if n \{\
64
+ .sp
65
+ .\}
66
+ .RS 4
67
+ .it 1 an-trap
68
+ .nr an-no-space-flag 1
69
+ .nr an-break-flag 1
70
+ .br
71
+ .ps +1
72
+ \fBBehaviour difference from grep semantics\fR
73
+ .ps -1
74
+ .br
75
+ For
76
+ grep\*(Aqs
77
+ \fB\-\-file\fR
78
+ option, an empty line (with only a newline character) is a \(lqmatch all\(rq pattern, while a totally empty file (zero bytes sized) is a \(lqmatch none\(rq pattern\&. This doesn\*(Aqt make much sense, especially for
79
+ elfgrep, so both empty lines and empty files are simply skipped over\&. Passing
80
+ \fB\-\-file\fR
81
+ pointing to a file that gets totally ignored (zero bytes sized, or a sequence of newline characters) will still stop
82
+ elfgrep
83
+ from looking for a pattern in the first non\-option argument\&.
84
+ .sp .5v
85
+ .RE
86
+ .RE
87
+ .PP
59
88
  \fB\-i\fR, \fB\-\-ignore\-case\fR
60
89
  .RS 4
61
90
  Ignore case distinction in both the
@@ -89,6 +118,11 @@ Invert the sense of matching, to select non\-matching symbols\&. This does not i
89
118
  and
90
119
  \fB\-\-no\-match\-defined\fR\&.
91
120
  .RE
121
+ .PP
122
+ \fB\-s\fR, \fB\-\-symbol\-regexp\fR
123
+ .RS 4
124
+ Select only those matches that exactly match the whole line\&.
125
+ .RE
92
126
  .SS "Output Control"
93
127
  .PP
94
128
  \fB\-c\fR, \fB\-\-count\fR
@@ -173,7 +207,7 @@ grep
173
207
  man page, to avoid confusing with different wordings\&.
174
208
  .SH "AUTHOR"
175
209
  .PP
176
- \fBDiego E. Pettenò\fR <\&flameeyes@gmail.com\&>
210
+ \fBDiego E. Pettenò\fR <\&flameeyes@flameeyes.eu\&>
177
211
  .RS 4
178
212
  Author and main contributor.
179
213
  .RE
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0'?>
2
2
  <!--
3
- Copyright © 2011, Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
3
+ Copyright © 2011, Diego Elio Pettenò <flameeyes@flameeyes.eu>
4
4
 
5
5
  This program is free software; you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
31
 
32
32
  <refentry>
33
33
  <info>
34
- <date>January 2011</date>
34
+ <date>November 2011</date>
35
35
  <productname>ruby-elf</productname>
36
36
  </info>
37
37
  <refmeta>
@@ -100,6 +100,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
100
100
  <option>--null</option>
101
101
  </arg>
102
102
 
103
+ <arg choice="opt">
104
+ <option>--symbol-regexp</option>
105
+ </arg>
106
+
103
107
  <xi:include href="common.xmli" xpointer="xpointer(id('filelist.synopsis.options')/*)" />
104
108
 
105
109
  <group choice="req">
@@ -108,6 +112,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
108
112
  <replaceable>PATTERN</replaceable>
109
113
  </arg>
110
114
 
115
+ <arg choice="plain" rep="repeat">
116
+ <option>--file</option>
117
+ <replaceable>FILE</replaceable>
118
+ </arg>
119
+
111
120
  <arg choice="plain">
112
121
  <replaceable>PATTERN</replaceable>
113
122
  </arg>
@@ -165,6 +174,38 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
165
174
  </listitem>
166
175
  </varlistentry>
167
176
 
177
+ <varlistentry>
178
+ <term>
179
+ <option>-f</option>
180
+ <replaceable>FILE</replaceable>
181
+ </term>
182
+ <term>
183
+ <option>--file</option>
184
+ <replaceable>FILE</replaceable>
185
+ </term>
186
+
187
+ <listitem>
188
+ <para>
189
+ Obtain patterns from <replaceable>FILE</replaceable>, one per line.
190
+ </para>
191
+
192
+ <note>
193
+ <title>Behaviour difference from <application>grep</application> semantics</title>
194
+
195
+ <para>
196
+ For <application>grep</application>'s <option>--file</option> option, an empty
197
+ line (with only a newline character) is a “match all” pattern, while a totally
198
+ empty file (zero bytes sized) is a “match none” pattern. This doesn't make much
199
+ sense, especially for <application>elfgrep</application>, so both empty lines
200
+ and empty files are simply skipped over. Passing <option>--file</option>
201
+ pointing to a file that gets totally ignored (zero bytes sized, or a sequence of
202
+ newline characters) will still stop <application>elfgrep</application> from
203
+ looking for a pattern in the first non-option argument.
204
+ </para>
205
+ </note>
206
+ </listitem>
207
+ </varlistentry>
208
+
168
209
  <varlistentry>
169
210
  <term><option>-i</option></term>
170
211
  <term><option>--ignore-case</option></term>
@@ -223,6 +264,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
223
264
  </para>
224
265
  </listitem>
225
266
  </varlistentry>
267
+
268
+ <varlistentry>
269
+ <term><option>-s</option></term>
270
+ <term><option>--symbol-regexp</option></term>
271
+ <listitem>
272
+ <para>
273
+ Select only those matches that exactly match the whole line.
274
+ </para>
275
+ </listitem>
276
+ </varlistentry>
226
277
  </variablelist>
227
278
  </refsect2>
228
279