objutils 0.10.22__cp315-cp315-win_arm64.whl
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.
- objutils/.coveragerc +21 -0
- objutils/.vscode/launch.json +10 -0
- objutils/.vscode/settings.json +63 -0
- objutils/__init__.py +255 -0
- objutils/a2l_test.shf +14901 -0
- objutils/ash.py +199 -0
- objutils/binfile.py +163 -0
- objutils/checksums.py +811 -0
- objutils/cosmac.py +146 -0
- objutils/dwarf/__init__.py +1303 -0
- objutils/dwarf/attrparser.py +603 -0
- objutils/dwarf/c_generator.py +1015 -0
- objutils/dwarf/constants.py +1305 -0
- objutils/dwarf/encoding.py +654 -0
- objutils/dwarf/lineprog.py +72 -0
- objutils/dwarf/readers.py +192 -0
- objutils/dwarf/sm.py +2461 -0
- objutils/dwarf/traverser.py +1671 -0
- objutils/elf/__init__.py +2730 -0
- objutils/elf/arm/__init__.py +0 -0
- objutils/elf/arm/attributes.py +551 -0
- objutils/elf/defs.py +1464 -0
- objutils/elf/model.py +1445 -0
- objutils/emon52.py +147 -0
- objutils/etek.py +169 -0
- objutils/exceptions.py +39 -0
- objutils/extensions/__init__.py +0 -0
- objutils/extensions/ctre.hpp +5979 -0
- objutils/extensions/difflib.h +461 -0
- objutils/extensions/elf_parser.cpp +257 -0
- objutils/extensions/elf_parser.hpp +43 -0
- objutils/extensions/exceptions.cpp +21 -0
- objutils/extensions/exceptions.hpp +66 -0
- objutils/extensions/hexfile.cpp +180 -0
- objutils/extensions/wrapper.cpp +152 -0
- objutils/fpc.py +354 -0
- objutils/hexdump.py +101 -0
- objutils/hexfile.py +1684 -0
- objutils/hexfiles_ext.cp315-win_arm64.pyd +0 -0
- objutils/ieee695.py +931 -0
- objutils/ihex.py +227 -0
- objutils/image.py +1095 -0
- objutils/logger.py +85 -0
- objutils/mostec.py +198 -0
- objutils/objutils.code-workspace +76 -0
- objutils/oocdtxt.py +219 -0
- objutils/pecoff/__init__.py +797 -0
- objutils/pecoff/defs.py +307 -0
- objutils/pecoff/model.py +381 -0
- objutils/pecoff/pdb/__init__.py +1451 -0
- objutils/pickleif.py +49 -0
- objutils/rca.py +167 -0
- objutils/readers.py +128 -0
- objutils/registry.py +508 -0
- objutils/scripts/arduino_build_artifacts.py +87 -0
- objutils/scripts/oj_cgen.py +189 -0
- objutils/scripts/oj_coff_extract.py +103 -0
- objutils/scripts/oj_coff_import.py +92 -0
- objutils/scripts/oj_coff_info.py +84 -0
- objutils/scripts/oj_coff_syms.py +67 -0
- objutils/scripts/oj_dwarf_import.py +148 -0
- objutils/scripts/oj_dwarf_info.py +143 -0
- objutils/scripts/oj_elf_arm_attrs.py +60 -0
- objutils/scripts/oj_elf_extract.py +104 -0
- objutils/scripts/oj_elf_import.py +61 -0
- objutils/scripts/oj_elf_info.py +135 -0
- objutils/scripts/oj_elf_syms.py +127 -0
- objutils/scripts/oj_hex_info.py +99 -0
- objutils/scripts/oj_hex_merge.py +130 -0
- objutils/scripts/oj_hex_split.py +138 -0
- objutils/section.py +1674 -0
- objutils/shf.py +206 -0
- objutils/sig.py +240 -0
- objutils/srec.py +354 -0
- objutils/symbols.py +440 -0
- objutils/tek.py +144 -0
- objutils/tests/__init__.py +0 -0
- objutils/tests/test_arm_attributes.py +172 -0
- objutils/tests/test_asam_alternate_modes.py +956 -0
- objutils/tests/test_ash.py +97 -0
- objutils/tests/test_c_generator.py +192 -0
- objutils/tests/test_checksums.py +265 -0
- objutils/tests/test_cygpath.py +22 -0
- objutils/tests/test_diff_bin.py +44 -0
- objutils/tests/test_elf.py +464 -0
- objutils/tests/test_emon52.py +31 -0
- objutils/tests/test_etek.py +159 -0
- objutils/tests/test_examples_cgen.py +39 -0
- objutils/tests/test_extended.py +56 -0
- objutils/tests/test_fpc.py +48 -0
- objutils/tests/test_hexdump.py +140 -0
- objutils/tests/test_hexfile.py +136 -0
- objutils/tests/test_ihex.py +162 -0
- objutils/tests/test_image.py +1410 -0
- objutils/tests/test_mostec.py +32 -0
- objutils/tests/test_oocdtxt.py +310 -0
- objutils/tests/test_pdb_typeinfo_dump.py +126 -0
- objutils/tests/test_probe_uniqueness.py +71 -0
- objutils/tests/test_readers.py +161 -0
- objutils/tests/test_registry.py +50 -0
- objutils/tests/test_repr.py +21 -0
- objutils/tests/test_section.py +1107 -0
- objutils/tests/test_section_join.py +79 -0
- objutils/tests/test_shf.py +95 -0
- objutils/tests/test_sm.py +61 -0
- objutils/tests/test_srec.py +131 -0
- objutils/tests/test_tek.py +32 -0
- objutils/tests/test_titext.py +53 -0
- objutils/titxt.py +160 -0
- objutils/utils/__init__.py +191 -0
- objutils/utils/arduino.py +95 -0
- objutils/utils/diff.py +114 -0
- objutils/version.py +3 -0
- objutils-0.10.22.dist-info/DELVEWHEEL +2 -0
- objutils-0.10.22.dist-info/METADATA +493 -0
- objutils-0.10.22.dist-info/RECORD +120 -0
- objutils-0.10.22.dist-info/WHEEL +5 -0
- objutils-0.10.22.dist-info/entry_points.txt +17 -0
- objutils-0.10.22.dist-info/licenses/LICENSE +339 -0
- objutils.libs/msvcp140-9cb625fcbc2fbbd6fca1aee8b24b0ebe.dll +0 -0
objutils/.coveragerc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[run]
|
|
2
|
+
branch = True
|
|
3
|
+
omit =
|
|
4
|
+
objutils/tests/*
|
|
5
|
+
|
|
6
|
+
[report]
|
|
7
|
+
exclude_lines =
|
|
8
|
+
|
|
9
|
+
pragma: no cover
|
|
10
|
+
|
|
11
|
+
def __repr__
|
|
12
|
+
if self\.debug
|
|
13
|
+
|
|
14
|
+
except ImportError
|
|
15
|
+
|
|
16
|
+
raise AssertionError
|
|
17
|
+
|
|
18
|
+
if 0:
|
|
19
|
+
if __name__ == .__main__.:
|
|
20
|
+
|
|
21
|
+
ignore_errors = True
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files.associations": {
|
|
3
|
+
"xstring": "cpp",
|
|
4
|
+
"any": "cpp",
|
|
5
|
+
"array": "cpp",
|
|
6
|
+
"atomic": "cpp",
|
|
7
|
+
"bit": "cpp",
|
|
8
|
+
"cctype": "cpp",
|
|
9
|
+
"charconv": "cpp",
|
|
10
|
+
"clocale": "cpp",
|
|
11
|
+
"cmath": "cpp",
|
|
12
|
+
"compare": "cpp",
|
|
13
|
+
"concepts": "cpp",
|
|
14
|
+
"cstddef": "cpp",
|
|
15
|
+
"cstdint": "cpp",
|
|
16
|
+
"cstdio": "cpp",
|
|
17
|
+
"cstdlib": "cpp",
|
|
18
|
+
"cstring": "cpp",
|
|
19
|
+
"ctime": "cpp",
|
|
20
|
+
"cwchar": "cpp",
|
|
21
|
+
"exception": "cpp",
|
|
22
|
+
"format": "cpp",
|
|
23
|
+
"initializer_list": "cpp",
|
|
24
|
+
"ios": "cpp",
|
|
25
|
+
"iosfwd": "cpp",
|
|
26
|
+
"iostream": "cpp",
|
|
27
|
+
"istream": "cpp",
|
|
28
|
+
"iterator": "cpp",
|
|
29
|
+
"limits": "cpp",
|
|
30
|
+
"locale": "cpp",
|
|
31
|
+
"map": "cpp",
|
|
32
|
+
"memory": "cpp",
|
|
33
|
+
"mutex": "cpp",
|
|
34
|
+
"new": "cpp",
|
|
35
|
+
"optional": "cpp",
|
|
36
|
+
"ostream": "cpp",
|
|
37
|
+
"ratio": "cpp",
|
|
38
|
+
"stdexcept": "cpp",
|
|
39
|
+
"stop_token": "cpp",
|
|
40
|
+
"streambuf": "cpp",
|
|
41
|
+
"string": "cpp",
|
|
42
|
+
"system_error": "cpp",
|
|
43
|
+
"thread": "cpp",
|
|
44
|
+
"tuple": "cpp",
|
|
45
|
+
"type_traits": "cpp",
|
|
46
|
+
"typeinfo": "cpp",
|
|
47
|
+
"utility": "cpp",
|
|
48
|
+
"vector": "cpp",
|
|
49
|
+
"xfacet": "cpp",
|
|
50
|
+
"xiosbase": "cpp",
|
|
51
|
+
"xlocale": "cpp",
|
|
52
|
+
"xlocbuf": "cpp",
|
|
53
|
+
"xlocinfo": "cpp",
|
|
54
|
+
"xlocmes": "cpp",
|
|
55
|
+
"xlocmon": "cpp",
|
|
56
|
+
"xlocnum": "cpp",
|
|
57
|
+
"xloctime": "cpp",
|
|
58
|
+
"xmemory": "cpp",
|
|
59
|
+
"xtr1common": "cpp",
|
|
60
|
+
"xtree": "cpp",
|
|
61
|
+
"xutility": "cpp"
|
|
62
|
+
}
|
|
63
|
+
}
|
objutils/__init__.py
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""Package entry-point.
|
|
3
|
+
|
|
4
|
+
Registers CODECS and implements an interface to them.
|
|
5
|
+
|
|
6
|
+
- :func:`load`
|
|
7
|
+
- :func:`loads`
|
|
8
|
+
- :func:`probe`
|
|
9
|
+
- :func:`probes`
|
|
10
|
+
- :func:`dump`
|
|
11
|
+
- :func:`dumps`
|
|
12
|
+
|
|
13
|
+
The first parameter is always the codec name.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# start delvewheel patch
|
|
18
|
+
def _delvewheel_patch_1_13_2():
|
|
19
|
+
import os
|
|
20
|
+
if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'objutils.libs'))):
|
|
21
|
+
os.add_dll_directory(libs_dir)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_delvewheel_patch_1_13_2()
|
|
25
|
+
del _delvewheel_patch_1_13_2
|
|
26
|
+
# end delvewheel patch
|
|
27
|
+
|
|
28
|
+
__version__ = "0.10.22"
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"Image",
|
|
32
|
+
"InvalidAddressError",
|
|
33
|
+
"LazySection",
|
|
34
|
+
"Section",
|
|
35
|
+
"dump",
|
|
36
|
+
"dumps",
|
|
37
|
+
"load",
|
|
38
|
+
"loads",
|
|
39
|
+
"probe",
|
|
40
|
+
"probes",
|
|
41
|
+
"registry",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
__copyright__ = """
|
|
45
|
+
objutils - Object file library for Python.
|
|
46
|
+
|
|
47
|
+
(C) 2010-2024 by Christoph Schueler <cpu12.gems@googlemail.com>
|
|
48
|
+
|
|
49
|
+
All Rights Reserved
|
|
50
|
+
|
|
51
|
+
This program is free software; you can redistribute it and/or modify
|
|
52
|
+
it under the terms of the GNU General Public License as published by
|
|
53
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
54
|
+
(at your option) any later version.
|
|
55
|
+
|
|
56
|
+
This program is distributed in the hope that it will be useful,
|
|
57
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
58
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
59
|
+
GNU General Public License for more details.
|
|
60
|
+
|
|
61
|
+
You should have received a copy of the GNU General Public License along
|
|
62
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
63
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
import io
|
|
67
|
+
import os
|
|
68
|
+
import sys
|
|
69
|
+
from pathlib import Path
|
|
70
|
+
from typing import Any, BinaryIO, Optional
|
|
71
|
+
|
|
72
|
+
from rich import pretty
|
|
73
|
+
from rich.console import Console
|
|
74
|
+
from rich.traceback import install as tb_install
|
|
75
|
+
|
|
76
|
+
import objutils.ash
|
|
77
|
+
import objutils.binfile
|
|
78
|
+
import objutils.oocdtxt
|
|
79
|
+
import objutils.cosmac
|
|
80
|
+
import objutils.emon52
|
|
81
|
+
import objutils.etek
|
|
82
|
+
import objutils.fpc
|
|
83
|
+
import objutils.ihex
|
|
84
|
+
import objutils.mostec
|
|
85
|
+
import objutils.rca
|
|
86
|
+
import objutils.shf
|
|
87
|
+
import objutils.sig
|
|
88
|
+
import objutils.srec
|
|
89
|
+
import objutils.tek
|
|
90
|
+
import objutils.titxt
|
|
91
|
+
from objutils.image import Image, InvalidAddressError
|
|
92
|
+
from objutils.registry import registry
|
|
93
|
+
from objutils.section import Section, LazySection
|
|
94
|
+
|
|
95
|
+
# Optional developer-friendly console and tracebacks; disabled by default for library consumers.
|
|
96
|
+
_ENABLE_RICH = os.getenv("OBJUTILS_RICH", "0").lower() in {"1", "true", "yes"}
|
|
97
|
+
if _ENABLE_RICH and sys.stderr.isatty():
|
|
98
|
+
pretty.install()
|
|
99
|
+
tb_install(show_locals=True, max_frames=3)
|
|
100
|
+
console = Console()
|
|
101
|
+
else:
|
|
102
|
+
console = None # type: ignore[assignment]
|
|
103
|
+
|
|
104
|
+
registry.register("bin", objutils.binfile.Reader, objutils.binfile.Writer, "Plain binary format.")
|
|
105
|
+
registry.register(
|
|
106
|
+
"binzip",
|
|
107
|
+
objutils.binfile.BinZipReader,
|
|
108
|
+
objutils.binfile.BinZipWriter,
|
|
109
|
+
"Zipped binary format.",
|
|
110
|
+
)
|
|
111
|
+
registry.register("sig", objutils.sig.Reader, objutils.sig.Writer, "Signetics format.")
|
|
112
|
+
registry.register(
|
|
113
|
+
"srec",
|
|
114
|
+
objutils.srec.Reader,
|
|
115
|
+
objutils.srec.Writer,
|
|
116
|
+
"Motorola S-Records (a.k.a. S19).",
|
|
117
|
+
)
|
|
118
|
+
registry.register(
|
|
119
|
+
"titxt",
|
|
120
|
+
objutils.titxt.Reader,
|
|
121
|
+
objutils.titxt.Writer,
|
|
122
|
+
"Texas Instruments MSP430 text format.",
|
|
123
|
+
)
|
|
124
|
+
registry.register(
|
|
125
|
+
"emon52",
|
|
126
|
+
objutils.emon52.Reader,
|
|
127
|
+
objutils.emon52.Writer,
|
|
128
|
+
"Elektor Monitor (EMON52) file format.",
|
|
129
|
+
)
|
|
130
|
+
registry.register("etek", objutils.etek.Reader, objutils.etek.Writer, "Extended Tektonix format.")
|
|
131
|
+
registry.register("fpc", objutils.fpc.Reader, objutils.fpc.Writer, "Four packed code file format.")
|
|
132
|
+
registry.register("ihex", objutils.ihex.Reader, objutils.ihex.Writer, "Intel IHex format.")
|
|
133
|
+
registry.register("mostec", objutils.mostec.Reader, objutils.mostec.Writer, "MOSTech format.")
|
|
134
|
+
registry.register("rca", objutils.rca.Reader, objutils.rca.Writer, "RCA format.")
|
|
135
|
+
registry.register("tek", objutils.tek.Reader, objutils.tek.Writer, "Tektonix format.")
|
|
136
|
+
registry.register("cosmac", objutils.cosmac.Reader, objutils.cosmac.Writer, "RCA COSMAC format.")
|
|
137
|
+
registry.register("ash", objutils.ash.Reader, objutils.ash.Writer, "ASCII hex space formats.")
|
|
138
|
+
registry.register("shf", objutils.shf.Reader, objutils.shf.Writer, "S Hexdump Format (rfc4149).")
|
|
139
|
+
registry.register("oocdtxt", objutils.oocdtxt.Reader, objutils.oocdtxt.Writer, "OpenOCD flash mdb text format.")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def load(codec_name: str, fp: str | Path | BinaryIO, join: bool = True, **kws: Any) -> Image:
|
|
143
|
+
"""Load hex data from file.
|
|
144
|
+
|
|
145
|
+
Parameters
|
|
146
|
+
----------
|
|
147
|
+
codec_name: str
|
|
148
|
+
Name of a registered codec.
|
|
149
|
+
|
|
150
|
+
Returns
|
|
151
|
+
-------
|
|
152
|
+
class:`Image`
|
|
153
|
+
"""
|
|
154
|
+
return registry.get(codec_name).Reader().load(fp, join=join, **kws)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def loads(codec_name: str, data: str | bytes | bytearray, join: bool = True, **kws: Any) -> Image:
|
|
158
|
+
"""Load hex data from bytes.
|
|
159
|
+
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
codec_name: str
|
|
163
|
+
Name of a registered codec.
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
class:`Image`
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
return registry.get(codec_name).Reader().loads(data, join=join, **kws)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def probe(fp: BinaryIO, **kws: Any) -> str | None:
|
|
174
|
+
"""Try to guess codec from file.
|
|
175
|
+
|
|
176
|
+
Returns
|
|
177
|
+
-------
|
|
178
|
+
str | None
|
|
179
|
+
The detected codec name or None if undetected.
|
|
180
|
+
"""
|
|
181
|
+
# Priority order for probing.
|
|
182
|
+
# We prioritize formats with more unique/strict probing logic (like 'sig' vs 'ihex')
|
|
183
|
+
# to avoid false positives.
|
|
184
|
+
priority = ["sig", "srec", "titxt", "shf", "fpc", "ihex"]
|
|
185
|
+
codecs_to_test = []
|
|
186
|
+
|
|
187
|
+
# First, the high-priority ones
|
|
188
|
+
for name in priority:
|
|
189
|
+
try:
|
|
190
|
+
codec = registry.get(name)
|
|
191
|
+
codecs_to_test.append((name, codec))
|
|
192
|
+
except Exception:
|
|
193
|
+
pass
|
|
194
|
+
|
|
195
|
+
# Then all others
|
|
196
|
+
for name, codec in registry:
|
|
197
|
+
if name not in priority:
|
|
198
|
+
codecs_to_test.append((name, codec))
|
|
199
|
+
|
|
200
|
+
for name, codec in codecs_to_test:
|
|
201
|
+
try:
|
|
202
|
+
reader = codec.Reader()
|
|
203
|
+
if hasattr(reader, "probe") and reader.probe(fp, **kws):
|
|
204
|
+
return name
|
|
205
|
+
except Exception:
|
|
206
|
+
pass
|
|
207
|
+
return None
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def probes(data: str | bytes | bytearray, **kws: Any) -> str | None:
|
|
211
|
+
"""Try to guess codec from bytes.
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
str | None
|
|
216
|
+
The detected codec name or None if undetected.
|
|
217
|
+
"""
|
|
218
|
+
if isinstance(data, str):
|
|
219
|
+
buffer = io.BytesIO(data.encode("ascii", errors="ignore"))
|
|
220
|
+
else:
|
|
221
|
+
buffer = io.BytesIO(data)
|
|
222
|
+
|
|
223
|
+
return probe(buffer, **kws)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def dump(codec_name: str, fp: str | Path | BinaryIO, image: Image, **kws: Any) -> None:
|
|
227
|
+
"""Save hex data to file.
|
|
228
|
+
|
|
229
|
+
Parameters
|
|
230
|
+
----------
|
|
231
|
+
codec_name: str
|
|
232
|
+
Name of a registered codec.
|
|
233
|
+
|
|
234
|
+
Returns
|
|
235
|
+
-------
|
|
236
|
+
bytes
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
registry.get(codec_name).Writer().dump(fp, image, **kws)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def dumps(codec_name: str, image: Image, **kws: Any) -> bytearray:
|
|
243
|
+
"""Save hex data to bytearray.
|
|
244
|
+
|
|
245
|
+
Parameters
|
|
246
|
+
----------
|
|
247
|
+
codec_name: str
|
|
248
|
+
Name of a registered codec.
|
|
249
|
+
|
|
250
|
+
Returns
|
|
251
|
+
-------
|
|
252
|
+
bytes
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
return registry.get(codec_name).Writer().dumps(image, **kws)
|