diff options
author | Greg Clayton <gclayton@fb.com> | 2025-09-25 14:06:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-25 14:06:48 -0700 |
commit | 4193a90b4263ff8c9599b921882cfbd7052b8571 (patch) | |
tree | 95887b176292601d0b53f30ec6b23bc5dae94807 /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | a85d3a53d306d6624f20b528cf783de778392347 (diff) | |
download | llvm-4193a90b4263ff8c9599b921882cfbd7052b8571.zip llvm-4193a90b4263ff8c9599b921882cfbd7052b8571.tar.gz llvm-4193a90b4263ff8c9599b921882cfbd7052b8571.tar.bz2 |
Modify ObjectFileELF so it can load notes from PT_NOTE segments. (#160652)
The ObjectFileELF parser was not able to load ELF notes from PT_NOTE
program headers. This patch fixes ObjectFileELF::GetUUID() to check the
program header and parse the notes in any PT_NOTE segments. This will
allow memory ELF files to extract the UUID from an in memory image that
has no section headers. Added a test that creates an ELF file, strips
all section headers, and then makes sure that LLDB can see the UUID
value.
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 931baf5..097c91b 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -826,6 +826,24 @@ bool ObjectFileELF::ParseHeader() { } UUID ObjectFileELF::GetUUID() { + if (m_uuid) + return m_uuid; + + // Try loading note info from any PT_NOTE program headers. This is more + // friendly to ELF files that have no section headers, like ELF files that + // are loaded from memory. + for (const ELFProgramHeader &H : ProgramHeaders()) { + if (H.p_type == llvm::ELF::PT_NOTE) { + DataExtractor note_data = GetSegmentData(H); + if (note_data.GetByteSize()) { + lldb_private::ArchSpec arch_spec; + RefineModuleDetailsFromNote(note_data, arch_spec, m_uuid); + if (m_uuid) + return m_uuid; + } + } + } + // Need to parse the section list to get the UUIDs, so make sure that's been // done. if (!ParseSectionHeaders() && GetType() != ObjectFile::eTypeCoreFile) |