cmd/ld: handle duplicate static symbols in COFF and Mach-O files.
Fixes issue 5740.

R=iant, rsc, luisbebop
CC=gobot, golang-dev
https://codereview.appspot.com/10345046