Link libgcc.a before shared libraries (especially libc.so).

[cherry-picked from internal master]

Change-Id: I53d19754d0d40e9ca2f3d043001cc77e39e5d795
Duplicate libgcc.a in front of *so

Also see 6c7bc550adb917157a9f53ebf8898110e37294b2

Change-Id: Iade6cd6b40cd4840a148098e1d8fc7a0c97e2f66
Clean up