Merge in symbols from Mach-O dyld trie to the symbol table
authorJason Molenda <jason@molenda.com>
Sat, 28 Mar 2020 05:35:19 +0000 (22:35 -0700)
committerJason Molenda <jason@molenda.com>
Sat, 28 Mar 2020 05:53:15 +0000 (22:53 -0700)
commitf0a5af906b41b654ef0c71dee5f81bf7496524b2
tree9b7bc60755886a3cc69780e3fcb88ad6418c4457
parentf398739152948377b81d9ce393d62c18e105699c
Merge in symbols from Mach-O dyld trie to the symbol table

In ObjectFileMachO we construct the symbol table from multiple
sources -- primarily the binary's nlist records, but when the nlist
symbols have been stripped, we would augment those with function
start address from the LC_FUNCTION_STARTS or eh_frame.  This patch
adds another source of symbols - the exported symbols that the
dynamic linker, dyld, uses at runtime from its trie structure.  This
provides us names and addresses for these functions/data.

This patch removes the code from ParseSymtab that would reject an
empty symbol table / nlist source.  It adds a new symbols_added
set which tracks the address of every symbol we've added to the
symtab.  We add symbols in most-information-ful order, and before
adding a symbol from less-informational-ful source (e.g.
LC_FUNCTION_STARTS with no function name), we check if that symbol
has already been added.

On targets with thumb code generation, instead of using the 0th bit
in these addresses in FunctionStarts (or now the trie entries), we
use the data field of FunctionStarts (formerly used to track if the
func_start should be added) and a flag for the trie entries to
encode this, and only store the actual addresses in the symbols_seen
and these vectors.

<rdar://problem/50791451>

Differential revision: https://reviews.llvm.org/D76758
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/test/API/macosx/dyld-trie-symbols/Makefile [new file with mode: 0644]
lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py [new file with mode: 0644]
lldb/test/API/macosx/dyld-trie-symbols/main.cpp [new file with mode: 0644]