[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92078)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue May 14 11:36:16 PDT 2024


================
@@ -983,6 +995,44 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(const NT_FILE_Entry entry) {
+  const uint8_t elf_header[4] = {0x7f, 0x45, 0x4c,
+                                 0x46}; // ELF file begin with this 4 bytes
----------------
clayborg wrote:

We have a ELF.h file you can get the magic bytes from:
```
#include "llvm/BinaryFormat/ELF.h"
```
Then you can use `llvm::ELF::ElfMagic`. They use it here:
```
bool ELFHeader::MagicBytesMatch(const uint8_t *magic) {
  return memcmp(magic, ElfMagic, strlen(ElfMagic)) == 0;
}
```


https://github.com/llvm/llvm-project/pull/92078


More information about the lldb-commits mailing list