pencil and rubber

Logo of Triple-A Level WCAG-1 Conformance, W3C-WAI Web Content Accessibility Guidelines 1.0

XHTML 1.0 Conformance Validation CSS 3 Conformance Validation
Logo of Department of Mathematics and Computer Science, Course on Dedicated systems, link to Forum

Program analysis tools and examples of their use

Tutorial 08 on Dedicated systems

Teacher: Giuseppe Scollo

University of Catania
Department of Mathematics and Computer Science
Graduate Course in Computer Science, 2019-20

Table of Contents

  1. Program analysis tools and examples of their use
  2. tutorial outline
  3. GNU cross-compilers and binutils
  4. examples for VisUAL ARM emulator
  5. VisUAL emulation of an example
  6. execution with debugger for ARM Cortex-A9 processor
  7. execution with debugger for Nios II processor
  8. low-level analysis of ARM executables
  9. low-level analysis of Nios II executables
  10. lab experience
  11. references

tutorial outline

this tutorial deals with:

GNU cross-compilers and binutils

program development for dedicated systems often takes place on machines that are based on a different processor than the target one, viz. that which is meant for their execution

the cross-compilers and utilities here considered are GNU free software, that typically have names <target>–gcc for the compiler, where <target> indicates the target architecture, and <target>–<util> for the utility <util>, such as for example

examples for VisUAL ARM emulator

a first example showcases the use of the VisUAL v. 1.27 ARM emulator, for the simulation of the execution of a program for GCD computation with Euclid's algorithm (Listing 7.11 in Schaumont, with modified main because of the different simulation target)

a second example, illustrated by the next figure, presents a software implementation of the Collatz delay calculation, similar in functionality to the hardware implementations produced in the previous lab experiences

the program seen at the end of the previous lecture (Listing 7.4 in Schaumont), with an initialization of the array contents, forms the third example

the emulator accepts an ARM source assembly program coded in a subset of the instruction set defined by the UAL (Unified Assembly Language) syntax

in these examples, the assembly program is obtained from the C source by means of the arm-linux-gcc cross-compiler, for ISA ARMv4, implemented in the StrongARM processor

however, the assembly program so obtained does not meet the restrictions posed by the emulator, e.g. it contains assembler directives and other syntactic sugar that are not accepted by VisUAL

folder arm_visual in the provided archive contains the C sources of the three examples, together with the c2visual script for the cross-compilation and aforementioned editing of the produced assembly code (script c02visual only differs in the compilation without optimization, for the analysis of the problem mentioned in the previous lecture

VisUAL emulation of an example

a snapshot of VisUAL emulation of the delay_collatz.s ARM assembly program

a snapshot of VisUAL emulation of the delay_collatz.s ARM assembly program

execution with debugger for ARM Cortex-A9 processor

the figure shows an execution snapshot of program delay_collatz.c on the DE1-SoC ARM processor

cross-compilation, loading and execution take place by means of the altera-monitor-program, under control of its GNU debugger GDB

execution snapshot of an ARM program under control of the GDB debugger within the Monitor Program

execution snapshot of an ARM program under control of the GDB debugger within the Monitor Program

execution with debugger for Nios II processor

the same C source from the previous example may be cross-compiled and executed by a Nios II softcore on the FPGA of the DE1-SoC system

execution snapshot of a Nios II program under control of the GDB debugger within the Monitor Program

execution snapshot of a Nios II program under control of the GDB debugger within the Monitor Program

low-level analysis of ARM executables

execution of the delay_collatz example on the ARM processor by means of the monitor program produces two files in the project directory that are relevant to low-level analysis:

in order to carry out low-level analysis even further, it helps one to know where the binary utilities are located, for the gcc cross-compiler used by the monitor program

N.B. actually, the monitor program makes use of specialized versions of some of these tools, that are placed elsewhere; however, for general use, independent of any execution in the contest of the monitor program, the aforementioned tool collection is the proper one

low-level analysis of Nios II executables

processing the C sources by the monitor program for execution on the Nios II processor produces the .elf executable in the project directory, but not its disassembly

hre is a simple example of use of the size utility: comparing the sizes of the executables produced by the three cross-compilers of interest here, for the C sources of two of the examples proposed and with the same compilation options; in particular, optimization level O2

the following table presents the outcome of this exercise

C source cross-compiler text data bss total
gcd arm-linux 820 260 4 1084
  arm-altera-eabi 492 16 28 536
  nios2-elf 1056 1068 0 2124
delay_collatz arm-linux 864 260 4 1128
  arm-altera-eabi 628 16 28 672
  nios2-elf 1196 1068 0 2264

lab experience

run the examples provided with this tutorial and produce documentation of any difficulties met and of the solutions found to overcome them

in particular, the VisUAL emulation of example accumulate requires further editing of the code produced by the compilation + editing script, both with and without optimization, in order to solve the following problems:

with respect to the last mentioned problem, it is proposed to:

references

recommended readings:

readings for further consultation:

useful materials for the proposed lab experience: