Creating Disassembly Listings with GNU Tools and Eclipse

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:

Disassembly View

Disassembly View

But this requires a debug session. An easier way is to use 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 which I usually use the following:

-Wa,-adhlns="$@.lst"

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:

Disassembly Options

Disassembly 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

Generated Listing File

Then I can open it with a text editor:

Open with text editor

Open with text editor

which opens a text view in Eclipse:

disassembly Listing

disassembly Listing

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

Which writes the disassembly listing to a file:

Listing file created with objdump

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 which I can use on an object (or ELF/Dwarf) file:

Disassemble menu action in MCUXpresso IDE

Disassemble menu action in MCUXpresso IDE

This again calls the objdump utility and creates the listing file:

Disassembly File Created

Disassembly File Created

In summary, there are many ways to create the assembly listing file :-).

Happy Disassembling 🙂

Links

2 thoughts on “Creating Disassembly Listings with GNU Tools and Eclipse

  1. Pingback: Execute-Only-Code with GNU and gcc | MCU on Eclipse

  2. Pingback: Disassembling in MPLABX & MCUXpresso | James Andrew Smith

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.