Miscellaneous Notes

  1. Common options when building with GCC + EWL.

    compile: -nostdinc -nostdinc++ -include {ewl prefix} -ffunction- sections -fdata-sections

    link: -nostartfiles -nostdlib -nodefaultlib --gc-sections -T{lcf file} --start-group -lc -lc++ -lgcc -lhosted -lrt -lsupc++ --end- group

  2. Pick the following default libraries and paths.

    If you use the linker tool, (for example powerpc-eabi-ld) then pass the library paths, start-up files and the libraries manually.

    Therefor the recommended option is to use the compiler driver (for example powerpc-eabi-gcc) for linking the required object files and libraries to generate the executable. The compiler driver will search and pick the required libraries ( libc.a, libgcc.a) automatically.

  3. C++ default libraries are not picked automatically even after using the compiler driver.

    Check if the user is using the correct driver (for example powerpc-eabi-gcc for C programs and powerpc-eabi-g++ for C++ programs)

  4. Error: Multiple definition error of start up file symbols [ `__init', `__fini' etc].

    By default when linking with the compiler driver, it picks the default start-up code. To avoid using the default start up file, pass ' -nostartfiles' option to the compiler driver while linking.

  5. Error: Skipping incompatible '<library>' when searching for '<lib.a>'.
    • Check if the user is compiling/linking with correct compiler options to pick the proper 32bit/64bit/soft-float bit libraries.
    • Check if the user is using proper 32/64bit linker description file (*.ld/*.lcf).
  6. How to resolve inter-dependency between libraries.

    By default, the linker usually resolves the symbols from left to right. So if any library/object (e.g libA) is dependent on another library/object (e.g libB) then we should pass libA first. And if there is inter-dependency between these libraries, then pass these libraries between '-start-group' and '--end- group'.

  7. To strip the unused symbols while generating the executable, use the following options.
    • Compiler option: -fdata-sections -ffunction-sections [also, set compiler optimization levels]
    • Linker option: -Wl, --gc-sections -Wl, --strip-all
  8. Pass the appropriate library linking option "-static" (required for bare metal applications) or "-shared".
  9. Pass explicit driver option "-std=c99" for linking and building C99 applications.