Mark Yisri Mark Yisri - 1 year ago 85
C Question

Use `ld -r` and get compilation errors if symbols are missing

I've recently begun using a new ELF loader. The loader requires you to link your applications with

ld -r

The problem is that GCC no longer warns me of undefined functions, and then the loader (obviously) fails to find them.

How do I link with
ld -r
, and get the undefined symbols method.

I am using
ld -r
for relocation purposes, so a different way to include relocations will also work for me.

Answer Source

In your makefile, define an intermediate target where you link with all the options but the -r one, to a file in the temporary directory (so you're sure not to use it).

If this phase succeeds, then proceed to the real link with the -r option.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download