Error Message "undefined symbol __sync_fetch_and_add_4"

Last edited on


When trying to test an application with a build from sources the startup via squishserver fails with the following error on the ARM platform:

/path/to/aut: symbol lookup error: /path/to/squish/lib/
   undefined symbol: __sync_fetch_and_add_4

Possible Cause and Suggested Solution

The symbol __sync_fetch_and_add (and others) are only implemented in the static libgcc library. When linking Squish's libraries against the shared gcc_s library these symbols will be missing. See for a discussion of the problem.

A quick workaround can be achieved by patching Squish's build scripts to have -lgcc added to the link commands for each library. A more convenient and permanent fix for this toolchain problem: replace the symlink with a linker script (plain text file) with the following content:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library.  */
GROUP ( libgcc.a )

This will make the linker pull in both the shared and static library when creating the binaries.