Creating Disassembly Listings With GNU Tools and Eclipse
Let's take a look at how to use the assembly code generated by a compiler for IoT applications in MCUXpresso.
Join the DZone community and get the full member experience.Join For Free
In many cases, it is very useful to see the generated assembly code produced by the compiler. One obvious way to see the assembly code is to use the Disassembly view in Eclipse:
But, this requires a debug session. An easier way is to use the command line options to generate the listing file(s).
-a: Generating an Assembly Listing File for Each File Compiled/Assembled
One way is to add the following to the GCC compiler command line. For this, I usually use the following:
The -Wa is an option for the assembler (which is staged after the compiler). The options passed to the assembler follow right after with the comma (,). For a description of the assembler -a option, see https://sourceware.org/binutils/docs/as/a.html#a.
In MCUXpresso IDE 10.2, I add it to the ‘Miscellaneous’ compiler options:
With this, for every source file compiled, it will place the listing file into the same output folder as the object file:
Generated Listing File
Then, I can open it with a text editor:
Open with text editor
Then, this opens a text view in Eclipse:
Objdump: Generating an Assembly Listing From the Object File
Another way is to generate the listing file from the compiler output object file. For this, I can use the GNU objdump utility:
arm-none-eabi-objdump -d test.o >test.o.lst
Then, this writes the disassembly listing to a file:
Listing file created with objdump
MCUXpresso IDE: Binary Utilities
With the MCUXpresso IDE 10.2 (Eclipse Oxygen based), NXP has added an extension with the ‘Binary Utilities’ menu that I can use on an object (or ELF/Dwarf) file:
Disassemble menu action in MCUXpresso IDE
This again calls the objdump utility and creates the listing file:
Disassembly File Created
In summary, there are many ways to create the assembly listing file.
Some Helpful Links
- GNU assembler (as) options: https://sourceware.org/binutils/docs/as/Invoking.html#Invoking
- GNU objdump options: https://sourceware.org/binutils/docs/binutils/objdump.html
- MCUXpresso IDE download: http://www.nxp.com/mcuxpresso/ide
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.