[lldb] In symtab serialization, make Section-relative addrs file-offset (#234809)
On Darwin systems, a dynamic library is usually virtual address 0 based
when it is linked, destined to be slid to a random virtual address at
runtime via ASLR. Darwin systems link all system libraries into a single
Shared Cache collection, and in the process of being added to the shared
cache, the virtual address (file address) of the binary is changed to be
non-zero -- to be a part of the shared cache which has a file address
(and also slides at boot-time). The binaries -- before Shared Cache
creation, and after -- both have the same filepath and UUID, but the
file addresses in them are different.
When lldb creates a DataFileCache symtab serialization of the symbol
table based on a 0-offset linked binary, and then reuses that symtab for
a Shared Cache non-0-offset file address binary (same filepath, same
UUID), when we try to find the correct Section for a Symbol having a
Section+offset, it fails because none of the Sections have 0-based file
addresses.
To address this, when serializing Symbols with section-relative
addresses, serialize them as section-id + section-offset. When
deserializing, find the same section-id and add the offset to its file
address.
This change required bumping the DataFileCache symtab version.
rdar://190169369
Assisted-By: Claude