[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


git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@219349 91177308-0d34-0410-b5e6-96231b3b80d8