Fundamentals 6 min read

Using addr2line and a Cross‑Compilation Toolchain for Efficient Crash Debugging in Embedded Development

The article explains how embedded developers can leverage cross‑compilation toolchains and the addr2line utility to quickly translate crash addresses into source file names and line numbers, dramatically improving debugging efficiency for native and kernel crashes.

Coolpad Technology Team
Coolpad Technology Team
Coolpad Technology Team
Using addr2line and a Cross‑Compilation Toolchain for Efficient Crash Debugging in Embedded Development

Embedded developers often face native or kernel crashes that are hard to locate using line‑by‑line logging; the addr2line tool can rapidly map an address to the exact source location.

Cross‑compilation means building binaries on a host machine for a different target platform, a common practice in mobile and other embedded projects. The host runs the compiler, linker, and other tools, while the target runs the resulting executable.

A typical cross‑toolchain includes the compiler ( arm-linux-gcc ), linker ( arm-linux-ld ), object copy utility ( arm-linux-objcopy ), ELF inspector ( arm-linux-readelf ), and disassembler ( arm-linux-objdump ). Example commands are: arm-linux-gcc test.c -o test arm-linux-ld -T led.lds led.o -o led.elf arm-linux-objcopy -O binary led.elf led.bin arm-linux-readelf -a led.elf arm-linux-objdump -D -S hello > dump

In practice, developers prepare the cross‑toolchain and the corresponding symbol table, compile and link the program, and then use addr2line (or aarch64-linux-android-addr2line ) to translate backtrace addresses to file names and line numbers. The article shows the three‑step build process (source setup, lunch configuration, make) and emphasizes matching the symbol table version with the binary.

A synthetic null‑pointer crash is created to demonstrate the workflow: after flashing the built library onto a phone, the crash log shows an address in ARCBeautyImpl.cpp . Running aarch64-linux-android-addr2line -e ARCBeautyImpl.cpp 0x... reveals that the fault occurs at line 581, allowing developers to pinpoint and fix the issue quickly.

ARMToolchainsymbol tableaddr2linecross compilationembedded debugging
Coolpad Technology Team
Written by

Coolpad Technology Team

Committed to advancing technology and supporting innovators. The Coolpad Technology Team regularly shares forward‑looking insights, product updates, and tech news. Tech experts are welcome to join; everyone is invited to follow us.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.