[lldb] Don't crash on a PE image read from memory that llvm::object rejects (#241902)

ObjectFilePECOFF::CreateMemoryInstance builds an object file from the
512 bytes lldb reads at a module's header address. ParseHeader can parse
the headers and section table from that, but
llvm::object::COFFObjectFile often can't; the export table and other
data directories point past the end of the buffer. CreateInstance
rejects a file whose binary can't be created, but CreateMemoryInstance
keeps the object, and m_binary stays null.

ParseSymtab, GetSectionDataSize and GetTlsIndexAddress dereference
m_binary without checking it. Loading such a module makes lldb look for
its symbol file, which parses the symbol table and crashes in
AppendFromExportTable. Check the binary there, as GetUUID and
ParseDependentModules already do.

Meta hit this with a Linux core of a .NET process. .NET assemblies are
PE files, the process maps them as plain files, and the core saved the
first page of one of them. Creating a module from that memory with
SBModule(process, address), or with a dynamic loader that loads every
mapped file, crashed lldb.

assisted with: claude

GitOrigin-RevId: 25e383913aa5c0b862456e490c1e46814e43a904
3 files changed