assembly output

Tue May 23, 2017 2:16 pm
Hello,i’m using the arduino 1.16.13 (windows10) and would like to see the compiler output in assembly if possible.

Tue May 23, 2017 2:19 pm
Use the -S option to gcc (or g++).

You need to edit the platform.txt file and add the “-S” directive to C and/or CPP flags.

Tue May 23, 2017 2:53 pm
Every time i edit the file i get compilation errors.what line of the attached file needs to be changed?

Tue May 23, 2017 5:01 pm
What kind of errors do you get?
It may be that you have to remove some other compiler directive in order to get this work.

Sat May 27, 2017 3:01 pm
I edited this line:
compiler.cpp.flags=-c -g -Os -S {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib –param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}

and get this error message:
Arduino: 1.6.13 (Windows 10), Board: “Generic STM32F103C series, STM32F103CB (20k RAM. 128k Flash), Serial”

In file included from C:\Users\Octa\Documents\Arduino\OCTA5\OCTA5.ino:2:0:

C:\Users\Octa\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\FastLED-stm32f103/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.005

# pragma message “FastLED version 3.001.005”


c:/users/octa/appdata/local/arduino15/packages/rfduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe:sketch\OCTA5.ino.cpp.o: file format not recognized; treating as linker script

c:/users/octa/appdata/local/arduino15/packages/rfduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe:sketch\OCTA5.ino.cpp.o:1: syntax error

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Generic STM32F103C series.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

Rick Kimball
Sat May 27, 2017 3:05 pm
Why don’t you just use arm-none-eabi-objdump:

$ ~/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-objdump -CS /tmp/arduino_build_224002/BlinkWithoutDelay.ino.elf | less
that is the linux version .. change paths for windows

Sat May 27, 2017 3:28 pm
>Why don’t you just use arm-none-eabi-objdump:
because i have no idea.
i will try it later,when i know where are the paths for windows.

Rick Kimball
Sat May 27, 2017 3:43 pm
Probably for you:


Sat May 27, 2017 4:16 pm
appdata is a hidden directory,but i found the files and it works.

Sat May 27, 2017 9:24 pm
%APPDATA% gets you to your appdata folder on windows

Depending on your version of the Arduino IDE, its either in appdata local or appdata roaming.

I think you can use %APPDATA%\local\arduino15\ …..etc…etc. on the newer versions of Arduino

Sun Jul 02, 2017 6:27 am
When you add the -S option, gcc outputs the assembly file instead of the object file. So, the .o files are actually your program’s assembly code. When the linker tries to link these, it can’t recognize valid object files, so they are interpreted as linker scripts, but they are still invalid.
Objdump is a good solution, but you will lose valuable information, such as labels etc. If you decide to use objdump, remember to use the -d option with the elf file (you can find it at the build directory), or the -D -b binary options with the final firmware.
If I were you I would change the recipe.c.o.pattern and recipe.cpp.o.pattern variables to include 2 commands, one for generating the assembly and one for the object file. I think you can use the ‘&’ symbol to concat to commands in a single line under windows, so I believe you could do something like:
recipe.cpp.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} ... -o "{object_file}" & "{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -S ... -o "{object_file}.s"

Sun Jul 02, 2017 11:53 am
There are a number of other suggestions for command line switches you might like to try here -> … rce-in-gcc

Leave a Reply

Your email address will not be published. Required fields are marked *