2026-05-24
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:
arm-linux-gnueabihf built with --with-multilib-list=... including be, or the dedicated armeb-linux-gnueabi- cross compiler.-nostdlib -nostartfiles and provide their own _start. This sidesteps the libgcc dependency entirely..byte directives to lay bytes out manually, or post-process with objcopy --reverse-bytes=4 on the section.Gotchas:
qemu-armeb, not qemu-arm.-mbig-endian flag must be passed to both compile and link steps; passing it only to one produces this same error.gnueabi distribution simply doesn't ship.
