zobjinspect 1.0.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.
- data/History.txt +6 -0
- data/Manifest.txt +13 -0
- data/README.txt +42 -0
- data/Rakefile +11 -0
- data/bin/zlibinspect +10 -0
- data/bin/zobjinspect +7 -0
- data/lib/library_file.rb +21 -0
- data/lib/object_file.rb +81 -0
- data/lib/zobjinspect.rb +3 -0
- data/test/block_device.lib.bin +0 -0
- data/test/read_block.o.bin +0 -0
- data/test/test_library_file.rb +14 -0
- data/test/test_object_file.rb +28 -0
- metadata +80 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/zlibinspect
|
6
|
+
bin/zobjinspect
|
7
|
+
lib/library_file.rb
|
8
|
+
lib/object_file.rb
|
9
|
+
lib/zobjinspect.rb
|
10
|
+
test/block_device.lib.bin
|
11
|
+
test/read_block.o.bin
|
12
|
+
test/test_library_file.rb
|
13
|
+
test/test_object_file.rb
|
data/README.txt
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= zobjinspect
|
2
|
+
|
3
|
+
* http://zobjinspect.rubyforge.org
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
* A set of utilities for inspecting object and library files generated
|
8
|
+
by z80asm, the assembler from z88dk - http://www.z88dk.org/
|
9
|
+
|
10
|
+
== SYNOPSIS:
|
11
|
+
|
12
|
+
zobjinspect something.o
|
13
|
+
zlibinspect something_else.lib
|
14
|
+
|
15
|
+
== INSTALL:
|
16
|
+
|
17
|
+
* sudo gem install zobjinspect
|
18
|
+
|
19
|
+
== LICENSE:
|
20
|
+
|
21
|
+
(The MIT License)
|
22
|
+
|
23
|
+
Copyright (c) 2009 Matthew Westcott
|
24
|
+
|
25
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
26
|
+
a copy of this software and associated documentation files (the
|
27
|
+
'Software'), to deal in the Software without restriction, including
|
28
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
29
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
30
|
+
permit persons to whom the Software is furnished to do so, subject to
|
31
|
+
the following conditions:
|
32
|
+
|
33
|
+
The above copyright notice and this permission notice shall be
|
34
|
+
included in all copies or substantial portions of the Software.
|
35
|
+
|
36
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
37
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
38
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
39
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
40
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
41
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
42
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/zlibinspect
ADDED
data/bin/zobjinspect
ADDED
data/lib/library_file.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'object_file'
|
2
|
+
|
3
|
+
module LibraryFile
|
4
|
+
def self.read(io)
|
5
|
+
if io.read(8) != 'Z80LMF01'
|
6
|
+
raise "not a Z80asm library file"
|
7
|
+
end
|
8
|
+
|
9
|
+
next_object_file_ptr = 8
|
10
|
+
|
11
|
+
objects = []
|
12
|
+
|
13
|
+
while next_object_file_ptr != 0xffffffff
|
14
|
+
io.seek(next_object_file_ptr)
|
15
|
+
next_object_file_ptr, next_object_file_length = io.read(8).unpack('VV')
|
16
|
+
objects << ObjectFile.read(io)
|
17
|
+
end
|
18
|
+
|
19
|
+
objects
|
20
|
+
end
|
21
|
+
end
|
data/lib/object_file.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
class ObjectFile < Struct.new(
|
2
|
+
:name, :org_address, :expression_declarations, :name_declarations, :library_name_declarations)
|
3
|
+
|
4
|
+
class ExpressionDeclaration < Struct.new(:type, :patchptr, :expression)
|
5
|
+
end
|
6
|
+
|
7
|
+
class NameDeclaration < Struct.new(:scope, :type, :value, :name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.read(io)
|
11
|
+
if io.read(8) != 'Z80RMF01'
|
12
|
+
raise "not a Z80asm object file"
|
13
|
+
end
|
14
|
+
org_address, module_name_ptr, expression_declarations_ptr,
|
15
|
+
name_declarations_ptr, library_name_declarations_ptr,
|
16
|
+
machine_code_block_ptr = io.read(22).unpack('vVVVVV')
|
17
|
+
|
18
|
+
expression_declarations = []
|
19
|
+
if expression_declarations_ptr != 0xffffffff
|
20
|
+
expression_declarations_length = [name_declarations_ptr, library_name_declarations_ptr, module_name_ptr].min - expression_declarations_ptr
|
21
|
+
expression_declarations_bin =
|
22
|
+
io.read(expression_declarations_length)
|
23
|
+
until expression_declarations_bin == ''
|
24
|
+
type, patchptr, length =
|
25
|
+
expression_declarations_bin.slice!(0...4).unpack('a1vc')
|
26
|
+
expression = expression_declarations_bin.slice!(0...length)
|
27
|
+
expression_declarations_bin.slice!(0) # strip off null
|
28
|
+
expression_declarations << ExpressionDeclaration.new(type, patchptr, expression)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
name_declarations = []
|
33
|
+
if name_declarations_ptr != 0xffffffff
|
34
|
+
name_declarations_length = [library_name_declarations_ptr, module_name_ptr].min - name_declarations_ptr
|
35
|
+
name_declarations_bin =
|
36
|
+
io.read(name_declarations_length)
|
37
|
+
until name_declarations_bin == ''
|
38
|
+
scope, type, value, length =
|
39
|
+
name_declarations_bin.slice!(0...7).unpack('a1a1Vc')
|
40
|
+
name = name_declarations_bin.slice!(0...length)
|
41
|
+
name_declarations << NameDeclaration.new(scope, type, value, name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
library_name_declarations = []
|
46
|
+
if library_name_declarations_ptr != 0xffffffff
|
47
|
+
library_name_declarations_bin =
|
48
|
+
io.read(module_name_ptr - library_name_declarations_ptr)
|
49
|
+
until library_name_declarations_bin == ''
|
50
|
+
length = library_name_declarations_bin.slice!(0)
|
51
|
+
library_name_declarations << library_name_declarations_bin.slice!(0...length)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module_name_length, = io.read(1).unpack('c')
|
56
|
+
module_name = io.read(module_name_length)
|
57
|
+
|
58
|
+
new(module_name, org_address, expression_declarations, name_declarations,
|
59
|
+
library_name_declarations)
|
60
|
+
end
|
61
|
+
|
62
|
+
def describe
|
63
|
+
out = ''
|
64
|
+
out << "#{name}, org #{org_address}\n===============\n"
|
65
|
+
out << "Expression declarations:\n"
|
66
|
+
for expr in expression_declarations
|
67
|
+
out << "#{expr.type == 'C' ? 'Constant' : 'Relocatable address'} at #{expr.patchptr} = #{expr.expression}\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
out << "\nName declarations:\n"
|
71
|
+
for name in name_declarations
|
72
|
+
out << "#{name.scope} #{name.type} #{name.name} = #{name.value}\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
out << "\nLibrary name declarations:\n"
|
76
|
+
for name in library_name_declarations
|
77
|
+
out << "#{name}\n"
|
78
|
+
end
|
79
|
+
out
|
80
|
+
end
|
81
|
+
end
|
data/lib/zobjinspect.rb
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
4
|
+
require "library_file"
|
5
|
+
|
6
|
+
class TestLibraryFile < Test::Unit::TestCase
|
7
|
+
def test_library_file
|
8
|
+
io = File.open "#{File.dirname(__FILE__)}/block_device.lib.bin"
|
9
|
+
library_file = LibraryFile.read(io)
|
10
|
+
assert_equal 2, library_file.size
|
11
|
+
assert_equal "READ_BLOCK", library_file[0].name
|
12
|
+
assert_equal "READ_BLOCK_CALLEE", library_file[1].name
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
4
|
+
require "object_file"
|
5
|
+
|
6
|
+
class TestObjectFile < Test::Unit::TestCase
|
7
|
+
def test_object_file
|
8
|
+
io = File.open "#{File.dirname(__FILE__)}/read_block.o.bin"
|
9
|
+
obj = ObjectFile.read(io)
|
10
|
+
assert_equal "READ_BLOCK", obj.name
|
11
|
+
assert_equal 0xffff, obj.org_address
|
12
|
+
|
13
|
+
assert_equal 1, obj.expression_declarations.size
|
14
|
+
expr = obj.expression_declarations[0]
|
15
|
+
assert_equal "C", expr.type
|
16
|
+
assert_equal 13, expr.patchptr
|
17
|
+
assert_equal "READ_BLOCK_CALLEE+ASMDISP_READ_BLOCK_CALLEE", expr.expression
|
18
|
+
|
19
|
+
assert_equal 1, obj.name_declarations.size
|
20
|
+
name = obj.name_declarations[0]
|
21
|
+
assert_equal "X", name.scope
|
22
|
+
assert_equal "A", name.type
|
23
|
+
assert_equal 0, name.value
|
24
|
+
assert_equal "READ_BLOCK", name.name
|
25
|
+
|
26
|
+
assert_equal ["READ_BLOCK_CALLEE"], obj.library_name_declarations
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zobjinspect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Westcott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-09 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.2
|
24
|
+
version:
|
25
|
+
description: "* A set of utilities for inspecting object and library files generated by z80asm, the assembler from z88dk - http://www.z88dk.org/"
|
26
|
+
email:
|
27
|
+
- matt@west.co.tt
|
28
|
+
executables:
|
29
|
+
- zlibinspect
|
30
|
+
- zobjinspect
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- History.txt
|
35
|
+
- Manifest.txt
|
36
|
+
- README.txt
|
37
|
+
files:
|
38
|
+
- History.txt
|
39
|
+
- Manifest.txt
|
40
|
+
- README.txt
|
41
|
+
- Rakefile
|
42
|
+
- bin/zlibinspect
|
43
|
+
- bin/zobjinspect
|
44
|
+
- lib/library_file.rb
|
45
|
+
- lib/object_file.rb
|
46
|
+
- lib/zobjinspect.rb
|
47
|
+
- test/block_device.lib.bin
|
48
|
+
- test/read_block.o.bin
|
49
|
+
- test/test_library_file.rb
|
50
|
+
- test/test_object_file.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://zobjinspect.rubyforge.org
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options:
|
55
|
+
- --main
|
56
|
+
- README.txt
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project: zobjinspect
|
74
|
+
rubygems_version: 1.3.1
|
75
|
+
signing_key:
|
76
|
+
specification_version: 2
|
77
|
+
summary: "* A set of utilities for inspecting object and library files generated by z80asm, the assembler from z88dk - http://www.z88dk.org/"
|
78
|
+
test_files:
|
79
|
+
- test/test_library_file.rb
|
80
|
+
- test/test_object_file.rb
|