Fix library ordering
Fix library ordering

Adding elf and pthread libraries to AM_LDFLAGS puts them at the start of
the link command line, so they are discarded before the libraries that
depend on them are processed.

Move the libraries to LIBS / per-program LDFLAGS so they are processed
after their dependants.

Signed-off-by: Robert Walker <e837e0f9a6356ae8fdf0aed487a7f4a3a8dd8d0a@arm.com>

google/autofdo,google/autofdo,google/autofdo