
Identify a Binary's Architecture and ABI With file and readelf
Read a Linux binary's CPU architecture, bit width, float ABI and loader with file, readelf -h, readelf -A and xxd, before you copy it to a board.
Tag
27 posts

Read a Linux binary's CPU architecture, bit width, float ABI and loader with file, readelf -h, readelf -A and xxd, before you copy it to a board.

Run an Autotools configure script for another architecture with --host, --build and a sysroot, and read the cross-compiling errors it prints when it goes wrong.

A sysroot is a directory that stands in for the target's root filesystem at build time. See what it holds, how GCC uses it, and how to confirm it is used.
Why GDB shows optimized out and jumps lines at -O2, how GCC -Og and variable tracking keep more values, and what to do when you must debug the real build.

Build and run OpenMP C programs with GCC 14 and Clang 19 on Linux, set the thread count, check that the pragma took effect, and fix the common link errors.

Install Clang on Linux, macOS or Windows, point Make, CMake or Meson at it, and fix the handful of warnings and flags that differ from GCC.

An assembly file without a .note.GNU-stack section makes the linker mark the whole program's stack executable. Add the section or pass -z noexecstack.

Write a shell script that uses readelf and nm to fail a build when an ELF binary lacks PIE, full RELRO, a non-executable stack, a stack canary or CET notes.

Define a default function with __attribute__((weak)) so another object file can replace it at link time, and check optional symbols with weak references.

Add stack protector, fortify, PIE, full RELRO and CET flags to a CMake 3.28 project with feature checks, per-target options and a verification step.

Use __attribute__((section)) to put functions and variables in named ELF sections, then walk the section with the linker's start and stop symbols.

A curated set of GCC and Clang warnings, from -Wformat=2 and -Wstringop-overflow to -Wvla and -Wconversion, that flag memory-safety bugs before they ship.