ruby-elf 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rbelf-nm +78 -0
- data/lib/elf.rb +1 -1
- data/lib/elf/section.rb +0 -18
- data/lib/elf/symbol.rb +30 -8
- data/manpages/elfgrep.1 +1 -1
- data/manpages/elfgrep.1.xml +1 -1
- data/manpages/rbelf-nm.1 +189 -0
- data/manpages/rbelf-nm.1.xml +299 -0
- metadata +8 -5
- data/tools/nm.rb +0 -78
data/bin/rbelf-nm
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright © 2007-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
|
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
|
+
# bsd-nm implementation based on elf.rb (very limited)
|
20
|
+
|
21
|
+
require 'elf/tools'
|
22
|
+
require 'getoptlong'
|
23
|
+
|
24
|
+
module Elf::Tools
|
25
|
+
class NM < Elf::Tool
|
26
|
+
|
27
|
+
def self.initialize
|
28
|
+
super
|
29
|
+
@options |= [
|
30
|
+
["--dynamic", "-D", GetoptLong::NO_ARGUMENT],
|
31
|
+
["--demangle", "-C", GetoptLong::NO_ARGUMENT]
|
32
|
+
]
|
33
|
+
|
34
|
+
@scan_section = '.symtab'
|
35
|
+
@demangle = false
|
36
|
+
@exitval = 0
|
37
|
+
|
38
|
+
# do not use multiple threads (unless we start caching the
|
39
|
+
# output, and synchronise on it).
|
40
|
+
@execution_threads = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.dynamic_cb
|
44
|
+
@scan_section = '.dynsym'
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.analysis(file)
|
48
|
+
Elf::File.open(file) do |elf|
|
49
|
+
if not elf.has_section? @scan_section
|
50
|
+
puterror "No symbols"
|
51
|
+
@exitval = 1
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
elf[@scan_section].each do |sym|
|
56
|
+
next if sym.name == ''
|
57
|
+
begin
|
58
|
+
flag = sym.nm_code
|
59
|
+
rescue Elf::Symbol::UnknownNMCode => e
|
60
|
+
puterror(e.message)
|
61
|
+
flag = "?"
|
62
|
+
end
|
63
|
+
|
64
|
+
version_name = sym.version
|
65
|
+
version_name = version_name ? "@#{sym.version_default? ? '@' : ''}#{version_name}" : ""
|
66
|
+
|
67
|
+
name = @demangle ? sym.demangle : sym.name
|
68
|
+
|
69
|
+
puts "#{sym.address_string} #{flag} #{name}#{version_name}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.results
|
75
|
+
exit @exitval
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/elf.rb
CHANGED
data/lib/elf/section.rb
CHANGED
@@ -240,24 +240,6 @@ module Elf
|
|
240
240
|
def flags_i
|
241
241
|
@flags_val
|
242
242
|
end
|
243
|
-
|
244
|
-
# Return the nm(1) code for the section.
|
245
|
-
#
|
246
|
-
# This function is usually mostly used by Elf::Symbol#nm_code. It
|
247
|
-
# moves the parts of the logic that have to deal with section
|
248
|
-
# flags and similar here, to stay closer with the section's data
|
249
|
-
def nm_code
|
250
|
-
@nmflag ||= case
|
251
|
-
when flags.include?(Flags::ExecInstr)
|
252
|
-
"T"
|
253
|
-
when type == Type::NoBits then "B"
|
254
|
-
when type == Type::Note then "N"
|
255
|
-
when name =~ /\.rodata.*/ then "R"
|
256
|
-
when name =~ /\.(t|pic)?data.*/ then "D"
|
257
|
-
else
|
258
|
-
nil
|
259
|
-
end
|
260
|
-
end
|
261
243
|
end
|
262
244
|
end
|
263
245
|
|
data/lib/elf/symbol.rb
CHANGED
@@ -268,16 +268,38 @@ module Elf
|
|
268
268
|
|
269
269
|
nmflag.downcase! if value == 0
|
270
270
|
|
271
|
-
when
|
272
|
-
nmflag =
|
273
|
-
|
274
|
-
|
275
|
-
|
271
|
+
when bind == Binding::GNU::Unique
|
272
|
+
nmflag = 'u'
|
273
|
+
|
274
|
+
when section == Elf::Section::Abs
|
275
|
+
nmflag = "A"
|
276
|
+
when type == Type::Common, section == Elf::Section::Common
|
277
|
+
# section check _should_ be limited to objects with
|
278
|
+
# Type::Data, but turns out that ICC does not emit
|
279
|
+
# uninitialised variables correctly, creating a Type::None
|
280
|
+
# object defined in Section::Common. Handle that properly.
|
281
|
+
nmflag = 'C'
|
282
|
+
|
283
|
+
when type == Type::Object, type == Type::TLS
|
284
|
+
# data object, distinguish between writable or read-only data,
|
285
|
+
# as well as data in Section::Type::NoBits sections.
|
286
|
+
nmflag = case
|
287
|
+
when section.is_a?(Integer) then nil
|
288
|
+
when !section.flags.include?(Elf::Section::Flags::Write) then "R"
|
289
|
+
when section.type == Elf::Section::Type::NoBits then "B"
|
290
|
+
else "D"
|
276
291
|
end
|
277
292
|
|
278
|
-
|
279
|
-
|
280
|
-
|
293
|
+
when type == Type::None
|
294
|
+
nmflag = 'N'
|
295
|
+
when type == Type::Func
|
296
|
+
nmflag = 'T'
|
297
|
+
when type == Type::Section
|
298
|
+
nmflag = 'S'
|
299
|
+
when type == Type::File
|
300
|
+
nmflag = 'F'
|
301
|
+
when type == Type::GNU::IFunc
|
302
|
+
nmflag = 'i'
|
281
303
|
end
|
282
304
|
|
283
305
|
# If we haven't found the flag with the above code, we don't
|
data/manpages/elfgrep.1
CHANGED
data/manpages/elfgrep.1.xml
CHANGED
@@ -346,7 +346,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
346
346
|
</citerefentry>,
|
347
347
|
|
348
348
|
<citerefentry>
|
349
|
-
<refentrytitle>nm</refentrytitle>
|
349
|
+
<refentrytitle>rbelf-nm</refentrytitle>
|
350
350
|
<manvolnum>1</manvolnum>
|
351
351
|
</citerefentry>.
|
352
352
|
</para>
|
data/manpages/rbelf-nm.1
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
'\" t
|
2
|
+
.\" Title: rbelf-size
|
3
|
+
.\" Author:
|
4
|
+
.\" Generator: DocBook XSL-NS Stylesheets v1.76.1 <http://docbook.sf.net/>
|
5
|
+
.\" Date: August 2011
|
6
|
+
.\" Manual: Reference
|
7
|
+
.\" Source: ruby-elf
|
8
|
+
.\" Language: English
|
9
|
+
.\"
|
10
|
+
.TH "RBELF\-SIZE" "1" "August 2011" "ruby-elf" "Reference"
|
11
|
+
.\" -----------------------------------------------------------------
|
12
|
+
.\" * Define some portability stuff
|
13
|
+
.\" -----------------------------------------------------------------
|
14
|
+
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
15
|
+
.\" http://bugs.debian.org/507673
|
16
|
+
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
17
|
+
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
18
|
+
.ie \n(.g .ds Aq \(aq
|
19
|
+
.el .ds Aq '
|
20
|
+
.\" -----------------------------------------------------------------
|
21
|
+
.\" * set default formatting
|
22
|
+
.\" -----------------------------------------------------------------
|
23
|
+
.\" disable hyphenation
|
24
|
+
.nh
|
25
|
+
.\" disable justification (adjust text to left margin only)
|
26
|
+
.ad l
|
27
|
+
.\" -----------------------------------------------------------------
|
28
|
+
.\" * MAIN CONTENT STARTS HERE *
|
29
|
+
.\" -----------------------------------------------------------------
|
30
|
+
.SH "NAME"
|
31
|
+
rbelf-nm \- List symbols from ELF files
|
32
|
+
.SH "SYNOPSIS"
|
33
|
+
.HP \w'\fBrbelf\-nm\fR\ 'u
|
34
|
+
\fBrbelf\-nm\fR [\fB\-\-dynamic\fR] [\fB\-\-demangle\fR] [\fB\-\-quiet\fR] [\fB\-\-recursive\fR] [\fB@\fR\fIfile\fR | \fIfile\fR...]
|
35
|
+
.SH "DESCRIPTION"
|
36
|
+
.PP
|
37
|
+
|
38
|
+
\fBrbelf\-nm\fR
|
39
|
+
is a replacement for the standard
|
40
|
+
\fBnm\fR(1)
|
41
|
+
utility, as provided by GNU binutils and similar suites\&.
|
42
|
+
.SH "OPTIONS"
|
43
|
+
.PP
|
44
|
+
\fB\-D\fR, \fB\-\-dynamic\fR
|
45
|
+
.RS 4
|
46
|
+
Display symbols in the dynamic symbol table, not the normal symbol table\&. This is useful to identify the symbols exported by a shared object\&.
|
47
|
+
.RE
|
48
|
+
.PP
|
49
|
+
\fB\-C\fR, \fB\-\-demangle\fR
|
50
|
+
.RS 4
|
51
|
+
Demangle encoded symbol names\&. Certain languages (C++) and interfaces (Java\*(Aqs JNI) transform their native symbol names into Unix\-compatible names to store in the symbol tables, this option applies the opposite transformation to identify the original symbols\&.
|
52
|
+
.RE
|
53
|
+
.PP
|
54
|
+
\fB\-q\fR, \fB\-\-quiet\fR
|
55
|
+
.RS 4
|
56
|
+
Do not output warnings and errors to the standard error\&. Designed to increase the signal\-to\-noise ratio when analysing eterogeneous trees recursively, or when producing output to redirect to automated systems\&.
|
57
|
+
.RE
|
58
|
+
.PP
|
59
|
+
\fB\-R\fR, \fB\-\-recursive\fR
|
60
|
+
.RS 4
|
61
|
+
Recursively descend into directories to search for files to scan\&. This affects both the paths passed from the command line and those found in argument files\&.
|
62
|
+
.RE
|
63
|
+
.PP
|
64
|
+
\fB@\fR\fIpath\fR
|
65
|
+
.RS 4
|
66
|
+
Read the list of files to analyse from the given file; useful to pass a long list of files\&. The files are read before the processing start, so that the list of target files is available\&.
|
67
|
+
.RE
|
68
|
+
.SH "OUTPUT"
|
69
|
+
.PP
|
70
|
+
Currently, the only output style implemented is BSD, which is the default of GNU
|
71
|
+
\fBnm\fR\&. In this style, the one\-character symbol type code is not standardised, and is thus not identical to the one provided by either the GNU implementation or Ulrich Drepper\*(Aqs
|
72
|
+
\fBeu\-nm\fR\&.
|
73
|
+
.PP
|
74
|
+
U
|
75
|
+
.RS 4
|
76
|
+
The symbol is undefined\&.
|
77
|
+
.RE
|
78
|
+
.PP
|
79
|
+
V, v
|
80
|
+
.RS 4
|
81
|
+
The symbol is a weak reference to a data object\&. When uppercase, a default value is provided, otherwise it is zero\&.
|
82
|
+
.RE
|
83
|
+
.PP
|
84
|
+
W, w
|
85
|
+
.RS 4
|
86
|
+
The symbol is a weak reference to a function\&. When uppercase, a default value is provided, otherwise it is zero\&.
|
87
|
+
.RE
|
88
|
+
.PP
|
89
|
+
A
|
90
|
+
.RS 4
|
91
|
+
The symbol is an absolute address\&.
|
92
|
+
.RE
|
93
|
+
.PP
|
94
|
+
C
|
95
|
+
.RS 4
|
96
|
+
The symbol is common\&.
|
97
|
+
.RE
|
98
|
+
.PP
|
99
|
+
D, d
|
100
|
+
.RS 4
|
101
|
+
The symbol is a writable data object\&.
|
102
|
+
.RE
|
103
|
+
.PP
|
104
|
+
R, r
|
105
|
+
.RS 4
|
106
|
+
The symbol is a read\-only data object\&. Note that relocated constants are still considered writable data objects as their value is set after execution\&.
|
107
|
+
.RE
|
108
|
+
.PP
|
109
|
+
B, b
|
110
|
+
.RS 4
|
111
|
+
The symbol is an uninitialised data object\&.
|
112
|
+
.RE
|
113
|
+
.PP
|
114
|
+
N
|
115
|
+
.RS 4
|
116
|
+
The symbol type is unspecified\&. This is usually used to refer to debug objects and notes, but the semantics of this code differ between GNU
|
117
|
+
\fBnm\fR
|
118
|
+
and
|
119
|
+
\fBeu\-nm\fR; we follow the latter\&.
|
120
|
+
.RE
|
121
|
+
.PP
|
122
|
+
T, t
|
123
|
+
.RS 4
|
124
|
+
The symbol is a function (text)\&.
|
125
|
+
.RE
|
126
|
+
.PP
|
127
|
+
S
|
128
|
+
.RS 4
|
129
|
+
The symbol is a section reference\&. The semantics of this code differ between GNU
|
130
|
+
\fBnm\fR
|
131
|
+
and
|
132
|
+
\fBeu\-nm\fR; we follow the latter\&.
|
133
|
+
.RE
|
134
|
+
.PP
|
135
|
+
F
|
136
|
+
.RS 4
|
137
|
+
The symbol is a file reference\&.
|
138
|
+
.RE
|
139
|
+
.PP
|
140
|
+
i
|
141
|
+
.RS 4
|
142
|
+
The symbol is an indirect function (only valid as a GNU extension)\&.
|
143
|
+
.RE
|
144
|
+
.PP
|
145
|
+
i
|
146
|
+
.RS 4
|
147
|
+
The symbol is an unique global symbol (only valid as a GNU extension)\&.
|
148
|
+
.RE
|
149
|
+
.SH "BUGS AND MISSING FEATURES"
|
150
|
+
.PP
|
151
|
+
Contrarily to the standard
|
152
|
+
\fBnm\fR
|
153
|
+
implementations,
|
154
|
+
\fBrbelf\-nm\fR
|
155
|
+
does not search for
|
156
|
+
a\&.out
|
157
|
+
when no parameter is provided\&. Instead, it waits for parameters on the standard input like the other Ruby\-Elf utilities\&.
|
158
|
+
.PP
|
159
|
+
Neither the full option set of GNU
|
160
|
+
\fBnm\fR
|
161
|
+
nor that of
|
162
|
+
\fBeu\-nm\fR
|
163
|
+
are currently implemented and require more work\&. No output style beside BSD is currently implemented\&.
|
164
|
+
.PP
|
165
|
+
Some of the codes from GNU
|
166
|
+
\fBnm\fR
|
167
|
+
are not implemented\&.
|
168
|
+
.PP
|
169
|
+
Parsing of files to provide further arguments (\fB@\fR\fIfile\fR) is not entirely comforming to other tools handling of the same syntax\&. No options are parsed from the file, and filenames are expected to be separated by newlines rather than whitespace\&.
|
170
|
+
.PP
|
171
|
+
Symbolic links are only followed when they are passed directly to the command line, or through @\-lists; symbolic links are
|
172
|
+
\fInot\fR
|
173
|
+
followed when using the
|
174
|
+
\fB\-\-recursive\fR
|
175
|
+
option, to avoid loops\&.
|
176
|
+
.SH "SEE ALSO"
|
177
|
+
.PP
|
178
|
+
|
179
|
+
\m[blue]\fBFlameeyes\*(Aqs Weblog\fR\m[]
|
180
|
+
http://blog\&.flameeyes\&.eu/
|
181
|
+
.PP
|
182
|
+
Related tools:
|
183
|
+
\fBnm\fR(1)
|
184
|
+
.SH "AUTHOR"
|
185
|
+
.PP
|
186
|
+
\fBDiego E. Pettenò\fR <\&flameeyes@gmail.com\&>
|
187
|
+
.RS 4
|
188
|
+
Author and main contributor.
|
189
|
+
.RE
|
@@ -0,0 +1,299 @@
|
|
1
|
+
<?xml version='1.0'?>
|
2
|
+
<!--
|
3
|
+
Copyright © 2011, Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
|
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
|
+
<article xmlns="http://docbook.org/ns/docbook"
|
20
|
+
xmlns:xl="http://www.w3.org/1999/xlink"
|
21
|
+
xmlns:xi="http://www.w3.org/2001/XInclude"
|
22
|
+
version="5.0" xml:lang="en">
|
23
|
+
<info>
|
24
|
+
<title>rbelf-nm</title>
|
25
|
+
|
26
|
+
<xi:include parse="xml" href="author.xmli" />
|
27
|
+
</info>
|
28
|
+
|
29
|
+
<section>
|
30
|
+
<title>Reference</title>
|
31
|
+
|
32
|
+
<refentry>
|
33
|
+
<info>
|
34
|
+
<date>August 2011</date>
|
35
|
+
<productname>ruby-elf</productname>
|
36
|
+
</info>
|
37
|
+
<refmeta>
|
38
|
+
<refentrytitle>rbelf-size</refentrytitle>
|
39
|
+
<manvolnum>1</manvolnum>
|
40
|
+
</refmeta>
|
41
|
+
<refnamediv>
|
42
|
+
<refname>rbelf-nm</refname>
|
43
|
+
<refpurpose>List symbols from ELF files</refpurpose>
|
44
|
+
</refnamediv>
|
45
|
+
<refsynopsisdiv>
|
46
|
+
<cmdsynopsis>
|
47
|
+
<command>rbelf-nm</command>
|
48
|
+
|
49
|
+
<arg choice="opt">
|
50
|
+
<option>--dynamic</option>
|
51
|
+
</arg>
|
52
|
+
|
53
|
+
<arg choice="opt">
|
54
|
+
<option>--demangle</option>
|
55
|
+
</arg>
|
56
|
+
|
57
|
+
<xi:include href="common.xmli" xpointer="xpointer(id('filelist.synopsis')/*)" />
|
58
|
+
</cmdsynopsis>
|
59
|
+
</refsynopsisdiv>
|
60
|
+
|
61
|
+
<refsect1>
|
62
|
+
<title>Description</title>
|
63
|
+
<para>
|
64
|
+
<command>rbelf-nm</command> is a replacement for the standard
|
65
|
+
<citerefentry><refentrytitle>nm</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
66
|
+
utility, as provided by GNU binutils and similar suites.
|
67
|
+
</para>
|
68
|
+
</refsect1>
|
69
|
+
|
70
|
+
<refsect1>
|
71
|
+
<title>Options</title>
|
72
|
+
|
73
|
+
<variablelist>
|
74
|
+
<varlistentry>
|
75
|
+
<term><option>-D</option></term>
|
76
|
+
<term><option>--dynamic</option></term>
|
77
|
+
<listitem>
|
78
|
+
<para>
|
79
|
+
Display symbols in the dynamic symbol table, not the normal symbol table. This is
|
80
|
+
useful to identify the symbols exported by a shared object.
|
81
|
+
</para>
|
82
|
+
</listitem>
|
83
|
+
</varlistentry>
|
84
|
+
|
85
|
+
<varlistentry>
|
86
|
+
<term><option>-C</option></term>
|
87
|
+
<term><option>--demangle</option></term>
|
88
|
+
<listitem>
|
89
|
+
<para>
|
90
|
+
Demangle encoded symbol names. Certain languages (C++) and interfaces (Java's JNI)
|
91
|
+
transform their native symbol names into Unix-compatible names to store in the
|
92
|
+
symbol tables, this option applies the opposite transformation to identify the
|
93
|
+
original symbols.
|
94
|
+
</para>
|
95
|
+
</listitem>
|
96
|
+
</varlistentry>
|
97
|
+
|
98
|
+
<xi:include href="common.xmli" xpointer="xpointer(id('filelist.option')/*)" />
|
99
|
+
</variablelist>
|
100
|
+
</refsect1>
|
101
|
+
|
102
|
+
<refsect1>
|
103
|
+
<title>Output</title>
|
104
|
+
|
105
|
+
<para>
|
106
|
+
Currently, the only output style implemented is BSD, which is the default of GNU
|
107
|
+
<command>nm</command>. In this style, the one-character symbol type code is not
|
108
|
+
standardised, and is thus not identical to the one provided by either the GNU
|
109
|
+
implementation or Ulrich Drepper's <command>eu-nm</command>.
|
110
|
+
</para>
|
111
|
+
|
112
|
+
<variablelist>
|
113
|
+
<varlistentry>
|
114
|
+
<term><literal>U</literal></term>
|
115
|
+
<listitem>
|
116
|
+
<para>
|
117
|
+
The symbol is undefined.
|
118
|
+
</para>
|
119
|
+
</listitem>
|
120
|
+
</varlistentry>
|
121
|
+
|
122
|
+
<varlistentry>
|
123
|
+
<term><literal>V</literal>, <literal>v</literal></term>
|
124
|
+
<listitem>
|
125
|
+
<para>
|
126
|
+
The symbol is a weak reference to a data object. When uppercase, a default value is
|
127
|
+
provided, otherwise it is zero.
|
128
|
+
</para>
|
129
|
+
</listitem>
|
130
|
+
</varlistentry>
|
131
|
+
|
132
|
+
<varlistentry>
|
133
|
+
<term><literal>W</literal>, <literal>w</literal></term>
|
134
|
+
<listitem>
|
135
|
+
<para>
|
136
|
+
The symbol is a weak reference to a function. When uppercase, a default value is
|
137
|
+
provided, otherwise it is zero.
|
138
|
+
</para>
|
139
|
+
</listitem>
|
140
|
+
</varlistentry>
|
141
|
+
|
142
|
+
<varlistentry>
|
143
|
+
<term><literal>A</literal></term>
|
144
|
+
<listitem>
|
145
|
+
<para>
|
146
|
+
The symbol is an absolute address.
|
147
|
+
</para>
|
148
|
+
</listitem>
|
149
|
+
</varlistentry>
|
150
|
+
|
151
|
+
<varlistentry>
|
152
|
+
<term><literal>C</literal></term>
|
153
|
+
<listitem>
|
154
|
+
<para>
|
155
|
+
The symbol is common.
|
156
|
+
</para>
|
157
|
+
</listitem>
|
158
|
+
</varlistentry>
|
159
|
+
|
160
|
+
<varlistentry>
|
161
|
+
<term><literal>D</literal>, <literal>d</literal></term>
|
162
|
+
<listitem>
|
163
|
+
<para>
|
164
|
+
The symbol is a writable data object.
|
165
|
+
</para>
|
166
|
+
</listitem>
|
167
|
+
</varlistentry>
|
168
|
+
|
169
|
+
<varlistentry>
|
170
|
+
<term><literal>R</literal>, <literal>r</literal></term>
|
171
|
+
<listitem>
|
172
|
+
<para>
|
173
|
+
The symbol is a read-only data object. Note that relocated constants are still
|
174
|
+
considered writable data objects as their value is set after execution.
|
175
|
+
</para>
|
176
|
+
</listitem>
|
177
|
+
</varlistentry>
|
178
|
+
|
179
|
+
<varlistentry>
|
180
|
+
<term><literal>B</literal>, <literal>b</literal></term>
|
181
|
+
<listitem>
|
182
|
+
<para>
|
183
|
+
The symbol is an uninitialised data object.
|
184
|
+
</para>
|
185
|
+
</listitem>
|
186
|
+
</varlistentry>
|
187
|
+
|
188
|
+
<varlistentry>
|
189
|
+
<term><literal>N</literal></term>
|
190
|
+
<listitem>
|
191
|
+
<para>
|
192
|
+
The symbol type is unspecified. This is usually used to refer to debug objects and
|
193
|
+
notes, but the semantics of this code differ between GNU <command>nm</command> and
|
194
|
+
<command>eu-nm</command>; we follow the latter.
|
195
|
+
</para>
|
196
|
+
</listitem>
|
197
|
+
</varlistentry>
|
198
|
+
|
199
|
+
<varlistentry>
|
200
|
+
<term><literal>T</literal>, <literal>t</literal></term>
|
201
|
+
<listitem>
|
202
|
+
<para>
|
203
|
+
The symbol is a function (text).
|
204
|
+
</para>
|
205
|
+
</listitem>
|
206
|
+
</varlistentry>
|
207
|
+
|
208
|
+
<varlistentry>
|
209
|
+
<term><literal>S</literal></term>
|
210
|
+
<listitem>
|
211
|
+
<para>
|
212
|
+
The symbol is a section reference. The semantics of this code differ between GNU
|
213
|
+
<command>nm</command> and <command>eu-nm</command>; we follow the latter.
|
214
|
+
</para>
|
215
|
+
</listitem>
|
216
|
+
</varlistentry>
|
217
|
+
|
218
|
+
<varlistentry>
|
219
|
+
<term><literal>F</literal></term>
|
220
|
+
<listitem>
|
221
|
+
<para>
|
222
|
+
The symbol is a file reference.
|
223
|
+
</para>
|
224
|
+
</listitem>
|
225
|
+
</varlistentry>
|
226
|
+
|
227
|
+
<varlistentry>
|
228
|
+
<term><literal>i</literal></term>
|
229
|
+
<listitem>
|
230
|
+
<para>
|
231
|
+
The symbol is an indirect function (only valid as a GNU extension).
|
232
|
+
</para>
|
233
|
+
</listitem>
|
234
|
+
</varlistentry>
|
235
|
+
|
236
|
+
<varlistentry>
|
237
|
+
<term><literal>i</literal></term>
|
238
|
+
<listitem>
|
239
|
+
<para>
|
240
|
+
The symbol is an unique global symbol (only valid as a GNU extension).
|
241
|
+
</para>
|
242
|
+
</listitem>
|
243
|
+
</varlistentry>
|
244
|
+
|
245
|
+
</variablelist>
|
246
|
+
</refsect1>
|
247
|
+
|
248
|
+
<refsect1>
|
249
|
+
<title>Bugs and Missing Features</title>
|
250
|
+
|
251
|
+
<para>
|
252
|
+
Contrarily to the standard <command>nm</command> implementations,
|
253
|
+
<command>rbelf-nm</command> does not search for <filename>a.out</filename> when no
|
254
|
+
parameter is provided. Instead, it waits for parameters on the standard input like the
|
255
|
+
other Ruby-Elf utilities.
|
256
|
+
</para>
|
257
|
+
|
258
|
+
<para>
|
259
|
+
Neither the full option set of GNU <command>nm</command> nor that of
|
260
|
+
<command>eu-nm</command> are currently implemented and require more work. No output style
|
261
|
+
beside BSD is currently implemented.
|
262
|
+
</para>
|
263
|
+
|
264
|
+
<para>
|
265
|
+
Some of the codes from GNU <command>nm</command> are not implemented.
|
266
|
+
</para>
|
267
|
+
|
268
|
+
<xi:include href="common.xmli" xpointer="xpointer(id('filelist.bugpara')/*)" />
|
269
|
+
</refsect1>
|
270
|
+
|
271
|
+
<refsect1>
|
272
|
+
<title>See Also</title>
|
273
|
+
<para>
|
274
|
+
<citation xl:href="http://blog.flameeyes.eu/">Flameeyes's Weblog</citation>
|
275
|
+
http://blog.flameeyes.eu/
|
276
|
+
</para>
|
277
|
+
|
278
|
+
<para>
|
279
|
+
Related tools:
|
280
|
+
|
281
|
+
<citerefentry>
|
282
|
+
<refentrytitle>nm</refentrytitle>
|
283
|
+
<manvolnum>1</manvolnum>
|
284
|
+
</citerefentry>
|
285
|
+
</para>
|
286
|
+
</refsect1>
|
287
|
+
</refentry>
|
288
|
+
</section>
|
289
|
+
</article>
|
290
|
+
<!--
|
291
|
+
Local Variables:
|
292
|
+
mode: nxml
|
293
|
+
mode: auto-fill
|
294
|
+
mode: flyspell
|
295
|
+
ispell-local-dictionary: "english"
|
296
|
+
fill-column: 100
|
297
|
+
indent-tabs-mode: nil
|
298
|
+
End:
|
299
|
+
-->
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-elf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Diego Elio Petten\xC3\xB2"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-28 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -27,6 +27,7 @@ description: |
|
|
27
27
|
|
28
28
|
email: flameeyes@gmail.com
|
29
29
|
executables:
|
30
|
+
- rbelf-nm
|
30
31
|
- elfgrep
|
31
32
|
- cowstats
|
32
33
|
- verify-lfs
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- bin/cowstats
|
44
45
|
- bin/elfgrep
|
45
46
|
- bin/missingstatic
|
47
|
+
- bin/rbelf-nm
|
46
48
|
- bin/rbelf-read
|
47
49
|
- bin/rbelf-size
|
48
50
|
- bin/verify-lfs
|
@@ -65,6 +67,7 @@ files:
|
|
65
67
|
- manpages/cowstats.1.xml
|
66
68
|
- manpages/elfgrep.1.xml
|
67
69
|
- manpages/missingstatic.1.xml
|
70
|
+
- manpages/rbelf-nm.1.xml
|
68
71
|
- manpages/rbelf-size.1.xml
|
69
72
|
- manpages/verify-lfs.1.xml
|
70
73
|
- tools/assess_duplicate_save.rb
|
@@ -73,11 +76,11 @@ files:
|
|
73
76
|
- tools/link-collisions/multimplementations
|
74
77
|
- tools/link-collisions/suppress.rb
|
75
78
|
- tools/link-collisions/suppressions
|
76
|
-
- tools/nm.rb
|
77
79
|
- tools/rbelf-lddtree.rb
|
78
80
|
- lib/elf/symbol/demangler_gcc3.rb
|
79
81
|
- manpages/verify-lfs.1
|
80
82
|
- manpages/elfgrep.1
|
83
|
+
- manpages/rbelf-nm.1
|
81
84
|
- manpages/missingstatic.1
|
82
85
|
- manpages/cowstats.1
|
83
86
|
- manpages/rbelf-size.1
|
data/tools/nm.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# Copyright © 2007-2010 Diego E. "Flameeyes" Pettenò <flameeyes@gmail.com>
|
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
|
-
# bsd-nm implementation based on elf.rb (very limited)
|
20
|
-
|
21
|
-
require 'elf'
|
22
|
-
require 'getoptlong'
|
23
|
-
|
24
|
-
opts = GetoptLong.new(
|
25
|
-
["--dynamic", "-D", GetoptLong::NO_ARGUMENT],
|
26
|
-
["--demangle", "-C", GetoptLong::NO_ARGUMENT]
|
27
|
-
)
|
28
|
-
|
29
|
-
scan_section = '.symtab'
|
30
|
-
demangle = false
|
31
|
-
|
32
|
-
opts.each do |opt, arg|
|
33
|
-
case opt
|
34
|
-
when '--dynamic'
|
35
|
-
scan_section = '.dynsym'
|
36
|
-
when '--demangle'
|
37
|
-
demangle = true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
exitval = 0
|
42
|
-
|
43
|
-
files = ARGV.length > 0 ? ARGV : ['a.out']
|
44
|
-
|
45
|
-
files.each do |file|
|
46
|
-
begin
|
47
|
-
Elf::File.open(file) do |elf|
|
48
|
-
addrsize = (elf.elf_class == Elf::Class::Elf32 ? 8 : 16)
|
49
|
-
|
50
|
-
if not elf.has_section? scan_section
|
51
|
-
$stderr.puts "nm.rb: #{elf.path}: No symbols"
|
52
|
-
exitval = 1
|
53
|
-
next
|
54
|
-
end
|
55
|
-
|
56
|
-
elf[scan_section].each do |sym|
|
57
|
-
next if sym.name == ''
|
58
|
-
begin
|
59
|
-
flag = sym.nm_code
|
60
|
-
rescue Elf::Symbol::UnknownNMCode => e
|
61
|
-
$stderr.puts e.message
|
62
|
-
flag = "?"
|
63
|
-
end
|
64
|
-
|
65
|
-
version_name = sym.version
|
66
|
-
version_name = version_name ? "@#{sym.version_default? ? '@' : ''}#{version_name}" : ""
|
67
|
-
|
68
|
-
name = demangle ? sym.demangle : sym.name
|
69
|
-
|
70
|
-
puts "#{sym.address_string} #{flag} #{name}#{version_name}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
rescue Errno::ENOENT
|
74
|
-
$stderr.puts "nm.rb: #{file}: No such file"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
exit exitval
|