Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Creating Disassembly Listings With GNU Tools and Eclipse

DZone's Guide to

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.

· IoT Zone ·
Free Resource

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 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:

-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

Then, this 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


Then, this 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 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 CreatedDisassembly File Created

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

Happy Disassembling!

Some Helpful Links

Topics:
compiler ,assembly ,ide ,how-to ,listing ,iot ,dissambly ,mcuxpresso

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}