Error when linking files in big-endian mode : libgcc_s.so.1: error adding symbols: file in wrong format

2026-05-24

Stack Overflow: View Question

Tags: gcc, linker, arm, ld

Score: 1 | Views: 82

The student is using arm-linux-gnueabi-gcc to assemble and link two ARM assembly files (memory.s and io.s) for a university course. Everything works in the default little-endian mode, but adding -mbig-endian — purely so that .data values display in big-endian order — breaks the link with:

libgcc_s.so.1: error adding symbols: file in wrong format

Why this is interesting: it exposes a misunderstanding that even experienced engineers occasionally hit. The -mbig-endian flag is not a cosmetic toggle on the data section — it switches the entire ABI/EABI variant the compiler targets. ARM EABI has two distinct, incompatible variants (armeb and arm), each with their own ELF EI_DATA byte, instruction encoding endianness for fetched words, and — critically — their own prebuilt system libraries. The toolchain prefix arm-linux-gnueabi- ships only the little-endian libgcc_s.so.1. When you flip to big-endian, the linker dutifully tries to pull in the same multilib path's libgcc and gets back an ELF whose e_ident[EI_DATA] says little-endian. Mixing endiannesses in one executable is forbidden, so ld rejects it with the famously cryptic "wrong format" error.

Direction toward a solution:

Gotchas:

The challenge: Endianness in a cross-toolchain isn't a display option — it's a full ABI variant that requires a parallel set of system libraries the standard gnueabi distribution simply doesn't ship.

All newsletters