[LLDB] Support Auxiliary library in ELF format (#208905)
An ELF filter library (DT_FILTER) or auxiliary filter (DT_AUXILIARY)
delegates symbol resolution to its filtee: the dynamic linker looks up
each symbol in the filtee first, falling back to the filter library's
own definition. Filter libraries may export placeholder symbols whose
addresses are not the actual function entry points.
For example, FreeBSD's libc is split into libc and libsys, with libsys
serving as an auxiliary library for libc. As a result, some symbols are
defined in libsys rather than libc. The original LLDB symbol resolver
resolves symbols based on library load order, so it arbitrarily select
the wrong symbol when the same symbol exists in both libraries. This can
result in an unusable debugger.
To support this, we teach ObjectFileELF to parse the filtee and model
placeholder function definition in filter libraries as ReExported,
reusing the existing re-export machinery.
Notice that in ELF, we don't record the per-symbol target ReExported
library like Macho. Instead, it is a suggestion list from the libraries
that exposes this symbol. As a result, we need to pass the library
Module to read the suggestion list to correctly parse the file in
Resolver.
Fixes: https://github.com/llvm/llvm-project/issues/180444
Assisted-by: Claude Fable 5
GitOrigin-RevId: b2d8db043675b21ce5f2e789e4a44e4b8633a4c1
11 files changed