Tool: mp_objdump2dma

Overview

Objdump to DMA tool provides a command-line interface (CLI) to interpret objdump outputs and generate the corresponding DMA file. DMA file format is a simple format that specifies contents for each address of memory. E.g. each line of the file contains D <address> <contents>. This format is used during early stages of bring-up and characterization to set up the contents of the processors cache directly, without requiring a fully operational system.

Basic usage

> mp_objdump2dma -i OBJDUMP_FILE -O DMA_OUTPUT_FILE

where:

Flag/Argument

Description

-i OBJDUMP_FILE, --input-objdump-file OBJDUMP_FILE

Objdump file generated with Objdump (see details in the following section)

-O DMA_OUTPUT_FILE, --dma-output-file DMA_OUTPUT_FILE

Output file name

How to obtain an objdump file?

objdump (part of the GNU Binutils) is a program for displaying various information about object files. An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. There are various formats for object files, and the same object code can be packaged in different object files. In addition to the object code itself, object files may contain metadata used for linking or debugging, including: information to resolve symbolic cross-references between different modules, relocation information, stack unwinding information, comments, program symbols, debugging or profiling information. Consequently, objdump can be used as a disassembler to view an executable in assembly form. More details on the wikipedia webpage.

The command to get an dump of a binary using objdump is the following:

> objdump -D -z your_binary_file > mydump.dump

the -D flag forces the tool to dump also the data sections (not only the executable ones) and the -z flag instructs the tool to dump everything (long regions of zero values are typically excluded).

Note

Only dumps from GNU Binutils objdump and dumps generated by Microprobe itself are currently supported.

Full usage

usage: mp_objdump2dma.py [-h] [-P SEARCH_PATH [SEARCH_PATH ...]] [-V] [-v]
                         [-d] [-c CONFIG_FILE [CONFIG_FILE ...]]
                         [-C FORCE_CONFIG_FILE]
                         [--dump-configuration-file OUTPUT_CONFIG_FILE]
                         [--dump-full-configuration-file OUTPUT_CONFIG_FILE]
                         [-A ARCHITECTURE_PATHS] [-M MICROARCHITECTURE_PATHS]
                         [-E ENVIRONMENT_PATHS] [-T TARGET]
                         [--list-architectures] [--list-microarchitectures]
                         [--list-environments] [--traceback]
                         [--profile PROFILE_OUTPUT] -i INPUT_OBJDUMP_FILE -O
                         OUTPUT_DMA_FILE

Microprobe Objdump to DMA tool

optional arguments:
  -h, --help            show this help message and exit
  -P SEARCH_PATH [SEARCH_PATH ...], --default_paths SEARCH_PATH [SEARCH_PATH ...]
                        Default search paths for microprobe target definitions
  -V, --version         Show Microprobe version and exit
  -v, --verbosity       Verbosity level (Values: [0,1,2,3,4]). Each time this
                        argument is specified the verbosity level is
                        increased. By default, no logging messages are shown.
                        These are the four levels available:
                        
                          -v (1): critical messages
                          -v -v (2): critical and error messages
                          -v -v -v (3): critical, error and warning messages
                          -v -v -v -v (4): critical, error, warning and info messages
                        
                        Specifying more than four verbosity flags, will
                        default to the maximum of four. If you need extra
                        information, enable the debug mode (--debug or -d
                        flags).
  -d, --debug           Enable debug mode in Microprobe framework. Lots of
                        output messages will be generated

Configuration arguments:

  Command arguments related to configuration file handling

  -c CONFIG_FILE [CONFIG_FILE ...], --configuration CONFIG_FILE [CONFIG_FILE ...]
                        Configuration file. The configuration files will be
                        readed in order of appearance. Values are reset by the
                        last configuration file in case of non-list values.
                        List values will be appended (not reset)
  -C FORCE_CONFIG_FILE, --force-configuration FORCE_CONFIG_FILE
                        Force configuration file. Use this configuration file
                        as the default start configuration. This disables any
                        system-wide, or user-provided configuration.
  --dump-configuration-file OUTPUT_CONFIG_FILE
                        Dump a configuration file with the actual
                        configuration used
  --dump-full-configuration-file OUTPUT_CONFIG_FILE
                        Dump a configuration file with the actual
                        configuration used plus all the configuration options
                        not set

Target path arguments:

  Command arguments related to target paths

  -A ARCHITECTURE_PATHS, --architecture-paths ARCHITECTURE_PATHS
                        Search path for architecture definitions. Microprobe
                        will search in these paths for architecture
                        definitions
  -M MICROARCHITECTURE_PATHS, --microarchitecture-paths MICROARCHITECTURE_PATHS
                        Search path for microarchitecture definitions.
                        Microprobe will search in these paths for
                        microarchitecture definitions
  -E ENVIRONMENT_PATHS, --environment-paths ENVIRONMENT_PATHS
                        Search path for environment definitions. Microprobe
                        will search in these paths for environment definitions

Target arguments:

  Command arguments related to target specification and queries

  -T TARGET, --target TARGET
                        Target tuple. Microprobe follows a GCC-like target
                        definition scheme, where a target is defined by a
                        tuple as following:
                        
                          <arch-name>-<uarch-name>-<env-name>
                        
                        where:
                        
                          <arch-name>: is the name of the architecture
                          <uarch-name>: is the name of the microarchitecture
                          <env-name>: is the name of the environment
                        
                        One can use --list-* options to get the list of
                        definitions available in the default search paths or
                        the paths specified by the different --*-paths options
  --list-architectures  Generate a list of architectures available in the
                        defined search paths and exit
  --list-microarchitectures
                        Generate a list of microarchitectures available in the
                        defined search paths and exit
  --list-environments   Generate a list of environments available in the
                        defined search paths and exit

Debug arguments:

  Command arguments related to debugging facilities

  --traceback           show a traceback and starts a python debugger (pdb)
                        when an error occurs. 'pdb' is an interactive python
                        shell that facilitates the debugging of errors
  --profile PROFILE_OUTPUT
                        dump profiling information into given file (see
                        'pstats' module)

Objdump to DMA arguments:

  Command arguments related to Objdump to DMA tool

  -i INPUT_OBJDUMP_FILE, --input-objdump-file INPUT_OBJDUMP_FILE
                        Objdump file to process
  -O OUTPUT_DMA_FILE, --output-dma-file OUTPUT_DMA_FILE
                        Output DMA file

Environment variables:

  MICROPROBETEMPLATES    Default path for microprobe templates
  MICROPROBEDEBUG        If set, enable debug
  MICROPROBEDEBUGPASSES  If set, enable debug during passes
  MICROPROBEASMHEXFMT    Assembly hexadecimal format. Options:
                         'all' -> All immediates in hex format
                         'address' -> Address immediates in hex format (default)
                         'none' -> All immediate in integer format

Example outputs

Example 1:

Command:

> mp_objdump2dma.py -O output.dma -i input.objdump

Input file input.objdump:

 1
 2c2mpt_test003.target.bin:     file format elf64-littleriscv
 3
 4
 5Disassembly of section microprobe.text:
 6
 70000000010030000 <c2mpt_function>:
 8    10030000:	10040637          	lui	a2,0x10040
 9    10030004:	00060613          	mv	a2,a2
10    10030008:	00863783          	ld	a5,8(a2) # 10040008 <linkedlist+0x8>
11    1003000c:	05063703          	ld	a4,80(a2)
12    10030010:	00078a63          	beqz	a5,10030024 <c2mpt_function+0x24>
13    10030014:	0007b683          	ld	a3,0(a5)
14    10030018:	0087b783          	ld	a5,8(a5)
15    1003001c:	00d70733          	add	a4,a4,a3
16    10030020:	fe079ae3          	bnez	a5,10030014 <c2mpt_function+0x14>
17    10030024:	00171713          	slli	a4,a4,0x1
18    10030028:	04e63823          	sd	a4,80(a2)
19    1003002c:	00008067          	ret
20
210000000010030030 <my_subroutine>:
22    10030030:	00151513          	slli	a0,a0,0x1
23    10030034:	100407b7          	lui	a5,0x10040
24    10030038:	04a7b823          	sd	a0,80(a5) # 10040050 <count>
25    1003003c:	00008067          	ret
26
27Disassembly of section microprobe.data:
28
290000000010040000 <linkedlist>:
30    10040000:	0000                	unimp
31    10040002:	0000                	unimp
32    10040004:	0000                	unimp
33    10040006:	0000                	unimp
34    10040008:	0000                	unimp
35    1004000a:	0000                	unimp
36    1004000c:	0000                	unimp
37    1004000e:	0000                	unimp
38    10040010:	0000                	unimp
39    10040012:	0000                	unimp
40    10040014:	0000                	unimp
41    10040016:	0000                	unimp
42    10040018:	0000                	unimp
43    1004001a:	0000                	unimp
44    1004001c:	0000                	unimp
45    1004001e:	0000                	unimp
46    10040020:	0000                	unimp
47    10040022:	0000                	unimp
48    10040024:	0000                	unimp
49    10040026:	0000                	unimp
50    10040028:	0000                	unimp
51    1004002a:	0000                	unimp
52    1004002c:	0000                	unimp
53    1004002e:	0000                	unimp
54    10040030:	0000                	unimp
55    10040032:	0000                	unimp
56    10040034:	0000                	unimp
57    10040036:	0000                	unimp
58    10040038:	0000                	unimp
59    1004003a:	0000                	unimp
60    1004003c:	0000                	unimp
61    1004003e:	0000                	unimp
62    10040040:	0000                	unimp
63    10040042:	0000                	unimp
64    10040044:	0000                	unimp
65    10040046:	0000                	unimp
66    10040048:	0000                	unimp
67    1004004a:	0000                	unimp
68    1004004c:	0000                	unimp
69    1004004e:	0000                	unimp
70
710000000010040050 <count>:
72    10040050:	cafe                	sw	t6,84(sp)
73    10040052:	cafe                	sw	t6,84(sp)
74    10040054:	0000                	unimp
75    10040056:	0000                	unimp

Output file output.dma:

 1D 0000000010030000 1004063700060613
 2D 0000000010030008 0086378305063703
 3D 0000000010030010 00078a630007b683
 4D 0000000010030018 0087b78300d70733
 5D 0000000010030020 fe079ae300171713
 6D 0000000010030028 04e6382300008067
 7D 0000000010030030 00151513100407b7
 8D 0000000010030038 04a7b82300008067
 9D 0000000010040000 0000000000000000
10D 0000000010040008 0000000000000000
11D 0000000010040010 0000000000000000
12D 0000000010040018 0000000000000000
13D 0000000010040020 0000000000000000
14D 0000000010040028 0000000000000000
15D 0000000010040030 0000000000000000
16D 0000000010040038 0000000000000000
17D 0000000010040040 0000000000000000
18D 0000000010040048 0000000000000000
19D 0000000010040050 cafecafe00000000