Skip to content

Commit 4193a90

Browse files
authored
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.
1 parent a85d3a5 commit 4193a90

File tree

2 files changed

+724
-0
lines changed

2 files changed

+724
-0
lines changed

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,24 @@ bool ObjectFileELF::ParseHeader() {
826826
}
827827

828828
UUID ObjectFileELF::GetUUID() {
829+
if (m_uuid)
830+
return m_uuid;
831+
832+
// Try loading note info from any PT_NOTE program headers. This is more
833+
// friendly to ELF files that have no section headers, like ELF files that
834+
// are loaded from memory.
835+
for (const ELFProgramHeader &H : ProgramHeaders()) {
836+
if (H.p_type == llvm::ELF::PT_NOTE) {
837+
DataExtractor note_data = GetSegmentData(H);
838+
if (note_data.GetByteSize()) {
839+
lldb_private::ArchSpec arch_spec;
840+
RefineModuleDetailsFromNote(note_data, arch_spec, m_uuid);
841+
if (m_uuid)
842+
return m_uuid;
843+
}
844+
}
845+
}
846+
829847
// Need to parse the section list to get the UUIDs, so make sure that's been
830848
// done.
831849
if (!ParseSectionHeaders() && GetType() != ObjectFile::eTypeCoreFile)

0 commit comments

Comments
 (0)