[elfabi] Add support for reading dynamic symbols from binaries

This patch adds initial support for reading dynamic symbols from ELF binaries. Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are explicitly supported. Other symbol types are mapped to ELFSymbolType::Unknown to improve signal/noise ratio.

Symbols must meet two criteria to be read into in an ELFStub:

 - The symbol's binding must be STB_GLOBAL or STB_WEAK.
 - The symbol's visibility must be STV_DEFAULT or STV_PROTECTED.

This filters out symbols that aren't of interest during compile-time linking against a shared object.

This change uses DT_HASH and DT_GNU_HASH to determine the size of .dynsym. Using hash tables to determine the number of symbols in .dynsym allows llvm-elfabi to work on binaries without relying on section headers.

Differential Revision: https://reviews.llvm.org/D56031

llvm-svn: 352121
diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
index 5dc96df..03d453c 100644
--- a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
+++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
@@ -18,12 +18,13 @@
     Flags:           [ SHF_ALLOC ]
     Address:         0x1008
     AddressAlign:    8
-    Content:         "0e0000000000000000000000000000000a0000000000000001000000000000000500000000000000600200000000000000000000000000000000000000000000"
+    Content:         "0e0000000000000000000000000000000a000000000000000100000000000000050000000000000060020000000000000600000000000000001000000000000000000000000000000000000000000000"
       # DT_SONAME     0
       # DT_STRSZ      1
       # DT_STRTAB     0x0260 # Bad vaddr (no PT_LOAD for 0x0000 to 0x0FFF)
+      # DT_SYMTAB     0x1000
       # DT_NULL       0x0
-    Size:            64
+    Size:            80
     Link:            .dynstr
 ProgramHeaders:
   - Type: PT_LOAD