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
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

c2mpt_test003.target.bin:     file format elf64-littleriscv


Disassembly of section microprobe.text:

0000000010030000 <c2mpt_function>:
    10030000:	10040637          	lui	a2,0x10040
    10030004:	00060613          	mv	a2,a2
    10030008:	00863783          	ld	a5,8(a2) # 10040008 <linkedlist+0x8>
    1003000c:	05063703          	ld	a4,80(a2)
    10030010:	00078a63          	beqz	a5,10030024 <c2mpt_function+0x24>
    10030014:	0007b683          	ld	a3,0(a5)
    10030018:	0087b783          	ld	a5,8(a5)
    1003001c:	00d70733          	add	a4,a4,a3
    10030020:	fe079ae3          	bnez	a5,10030014 <c2mpt_function+0x14>
    10030024:	00171713          	slli	a4,a4,0x1
    10030028:	04e63823          	sd	a4,80(a2)
    1003002c:	00008067          	ret

0000000010030030 <my_subroutine>:
    10030030:	00151513          	slli	a0,a0,0x1
    10030034:	100407b7          	lui	a5,0x10040
    10030038:	04a7b823          	sd	a0,80(a5) # 10040050 <count>
    1003003c:	00008067          	ret

Disassembly of section microprobe.data:

0000000010040000 <linkedlist>:
    10040000:	0000                	unimp
    10040002:	0000                	unimp
    10040004:	0000                	unimp
    10040006:	0000                	unimp
    10040008:	0000                	unimp
    1004000a:	0000                	unimp
    1004000c:	0000                	unimp
    1004000e:	0000                	unimp
    10040010:	0000                	unimp
    10040012:	0000                	unimp
    10040014:	0000                	unimp
    10040016:	0000                	unimp
    10040018:	0000                	unimp
    1004001a:	0000                	unimp
    1004001c:	0000                	unimp
    1004001e:	0000                	unimp
    10040020:	0000                	unimp
    10040022:	0000                	unimp
    10040024:	0000                	unimp
    10040026:	0000                	unimp
    10040028:	0000                	unimp
    1004002a:	0000                	unimp
    1004002c:	0000                	unimp
    1004002e:	0000                	unimp
    10040030:	0000                	unimp
    10040032:	0000                	unimp
    10040034:	0000                	unimp
    10040036:	0000                	unimp
    10040038:	0000                	unimp
    1004003a:	0000                	unimp
    1004003c:	0000                	unimp
    1004003e:	0000                	unimp
    10040040:	0000                	unimp
    10040042:	0000                	unimp
    10040044:	0000                	unimp
    10040046:	0000                	unimp
    10040048:	0000                	unimp
    1004004a:	0000                	unimp
    1004004c:	0000                	unimp
    1004004e:	0000                	unimp

0000000010040050 <count>:
    10040050:	cafe                	sw	t6,84(sp)
    10040052:	cafe                	sw	t6,84(sp)
    10040054:	0000                	unimp
    10040056:	0000                	unimp

Output file output.dma:

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