elf_utils 0.3.0 → 0.3.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/elf_utils.gemspec +1 -1
- data/lib/elf_utils/section/debug_info/die.rb +32 -10
- data/lib/elf_utils/symbol.rb +3 -2
- data/lib/elf_utils/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6fa495dbda4f982713d3cd015abe94c0a292f0cfcf44a91cc13aeef85a4429
|
4
|
+
data.tar.gz: 6bbfb945c6cb8240f71f92c2b0db81f8df94c8837f76d9adc1a52613781ce663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0ed80f8d44d903cc4aa5835612b1bd9e6930643a7f5f371589caad5f97564832b90458fdb4628524dfb0f9a68f27ef8ee10d8098aedbf4e86a6220b6be04691
|
7
|
+
data.tar.gz: 3458490318399305bbefe45d957af6b4f4e8d2bb2b7a23f52efba27fb62c238d3ed69ef7f4c3909cf4bc28736fee6abd627ced01a868a1186fb2274c616e8034
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/elf_utils)
|
4
4
|
[](http://github.com/cisco-open/ruby-elf_utils)
|
5
|
-
[](
|
5
|
+
[](https://rubydoc.info/gems/elf_utils/frames)
|
6
6
|
|
7
7
|
[](CODE_OF_CONDUCT.md)
|
8
8
|
[](https://opensource.cisco.com)
|
data/elf_utils.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
# Uncomment to register a new dependency of your gem
|
36
36
|
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
-
spec.add_dependency "ctypes", "~> 0.
|
37
|
+
spec.add_dependency "ctypes", "~> 0.3"
|
38
38
|
|
39
39
|
# For more information and examples about making a new gem, check out our
|
40
40
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -137,15 +137,28 @@ module ElfUtils
|
|
137
137
|
@attrs ||= parse_attrs
|
138
138
|
|
139
139
|
raise "not a subrange DIE: %p" % [self] unless @tag == :subrange_type
|
140
|
-
|
140
|
+
count = @attrs[:count]
|
141
|
+
case count
|
142
|
+
when Integer
|
143
|
+
return count
|
144
|
+
when Section::DebugInfo::Die
|
145
|
+
# return a size of nil for variable-length array
|
146
|
+
return nil if count.tag == :variable
|
147
|
+
raise ElfUtils::Error, "unexpected DIE type in subrange[:count]: %p" %
|
148
|
+
[count]
|
149
|
+
when nil
|
150
|
+
# fall through when there is no count attribute
|
151
|
+
else
|
152
|
+
raise ElfUtils::Error, "unexpected value in subrange[:count]: %p" %
|
153
|
+
[count]
|
154
|
+
end
|
141
155
|
|
142
156
|
# upper bound may be DW_TAG_variable, so special handling
|
143
157
|
if (upper_bound = @attrs[:upper_bound])
|
144
158
|
return @attrs[:upper_bound] + 1 if upper_bound.is_a?(Integer)
|
145
159
|
end
|
146
160
|
|
147
|
-
# XXX we'll need to do some work to support flexible array members
|
148
|
-
# arrays with an upper bound defined by DW_TAG_variable
|
161
|
+
# XXX we'll need to do some work to support flexible array members
|
149
162
|
0
|
150
163
|
end
|
151
164
|
|
@@ -173,12 +186,19 @@ module ElfUtils
|
|
173
186
|
when :const_type
|
174
187
|
"const #{@attrs[:type]&.type_name || "void"}"
|
175
188
|
when :array_type
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
189
|
+
buf = "#{@attrs[:type]&.type_name}"
|
190
|
+
sizes = children.each do |child|
|
191
|
+
next unless child.tag == :subrange_type
|
192
|
+
|
193
|
+
# subrange_len may return nil for variable-length arrays
|
194
|
+
len = child.subrange_len
|
195
|
+
if len
|
196
|
+
buf << "[%d]" % len
|
197
|
+
else
|
198
|
+
buf << "[]"
|
199
|
+
end
|
180
200
|
end
|
181
|
-
|
201
|
+
buf
|
182
202
|
when :pointer_type
|
183
203
|
inner = @attrs[:type]&.type_name || "void"
|
184
204
|
if inner.end_with?("*")
|
@@ -221,8 +241,10 @@ module ElfUtils
|
|
221
241
|
when :pointer_type, :subroutine_type
|
222
242
|
@cu.addr_type
|
223
243
|
when :array_type
|
244
|
+
# subrange_len may return nil for variable-length arrays
|
224
245
|
sizes = children
|
225
|
-
.
|
246
|
+
.select { |c| c.tag == :subrange_type }
|
247
|
+
.map { |c| c.subrange_len }
|
226
248
|
|
227
249
|
# if we have a signed char array, we'll use a string to hold it
|
228
250
|
inner_type = @attrs[:type].ctype
|
@@ -232,7 +254,7 @@ module ElfUtils
|
|
232
254
|
inner_type = CTypes::String.new(size: sizes.pop)
|
233
255
|
end
|
234
256
|
|
235
|
-
|
257
|
+
sizes.reverse_each do |size|
|
236
258
|
inner_type = CTypes::Array.new(type: inner_type, size:)
|
237
259
|
end
|
238
260
|
|
data/lib/elf_utils/symbol.rb
CHANGED
@@ -88,11 +88,12 @@ module ElfUtils
|
|
88
88
|
return nil unless type == :object && (debug_info = @file.debug_info)
|
89
89
|
|
90
90
|
name = self.name
|
91
|
-
addr
|
91
|
+
# use st_value because #addr may be relocated
|
92
|
+
location = @sym.st_value
|
92
93
|
die = debug_info.dies(top: true).find do |die|
|
93
94
|
die.tag == :variable &&
|
94
95
|
die[:name] == name &&
|
95
|
-
die.location ==
|
96
|
+
die.location == location
|
96
97
|
end or return nil
|
97
98
|
die[:type]&.ctype
|
98
99
|
end
|
data/lib/elf_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elf_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David M. Lary
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ctypes
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- dmlary@gmail.com
|