[ELF] Fix inclusion of weak symbols in the dynamic symbol table

This commit implements in the X86_64 ELF lld backend yet another feature that
was only available in the MIPS backend. However, this patch changes generic ELF
classes to make it trivial for other ELF backends to use this logic too. When
creating a dynamic executable that has dynamic relocations against weak
undefined symbols, these symbols must be exported to the dynamic symbol table
to seek a possible resolution at run time.

A common use case is the __gmon_start__ weak glibc undefined symbol.

Reviewer: shankarke

http://reviews.llvm.org/D5571