[Lldb-commits] [lldb] [LLDB][NFC] Calculate the region size of an in memory image if size isn't specified (PR #123148)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 16 12:58:30 PST 2025
================
@@ -2544,6 +2544,26 @@ ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec,
progress_up = std::make_unique<Progress>(
"Reading binary from memory", file_spec.GetFilename().GetString());
+ if (size_to_read == 0) {
+ // No size was provided, figure out the size of the memory region that
+ // contains "header_addr"
+ MemoryRegionInfo header_region_info;
+ Status error(GetMemoryRegionInfo(header_addr, header_region_info));
+ // Default to 512 in case we can't find a memory region.
+ size_to_read = 512;
+ if (error.Success()) {
+ // We found a memory region, set the range of bytes ro read to read to
+ // the end of the memory region. This should be enough to contain the
+ // file header and important bits.
+ const auto &range = header_region_info.GetRange();
----------------
Jlalond wrote:
Echoing what Pavel said a little bit, I do think an upper bound makes sense. I think we can be pretty heavy handed with that upper-bound. I'm not an expert on ELF files by any means, but I suspect something like 10MB or even 100 MB, will be a sane expectation for even the largest set of ELF headers.
https://github.com/llvm/llvm-project/pull/123148
More information about the lldb-commits
mailing list