mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:57:42 +00:00
UserspaceEmulator: Don't scan text segment for malloc leaks
There will be no (true positive) malloc addresses in the text segment.
This commit is contained in:
parent
3dc1c80958
commit
e50874621a
3 changed files with 8 additions and 0 deletions
|
@ -108,6 +108,8 @@ bool Emulator::load_elf()
|
|||
m_elf->image().for_each_program_header([&](const ELF::Image::ProgramHeader& program_header) {
|
||||
if (program_header.type() == PT_LOAD) {
|
||||
auto region = make<SimpleRegion>(program_header.vaddr().get(), program_header.size_in_memory());
|
||||
if (program_header.is_executable() && !program_header.is_writable())
|
||||
region->set_text(true);
|
||||
memcpy(region->data(), program_header.raw_data(), program_header.size_in_image());
|
||||
mmu().add_region(move(region));
|
||||
return;
|
||||
|
|
|
@ -163,6 +163,8 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
|
|||
// Skip the stack
|
||||
if (region.is_stack())
|
||||
return IterationDecision::Continue;
|
||||
if (region.is_text())
|
||||
return IterationDecision::Continue;
|
||||
// Skip malloc blocks
|
||||
if (region.is_mmap() && static_cast<const MmapRegion&>(region).is_malloc_block())
|
||||
return IterationDecision::Continue;
|
||||
|
|
|
@ -63,6 +63,9 @@ public:
|
|||
bool is_stack() const { return m_stack; }
|
||||
void set_stack(bool b) { m_stack = b; }
|
||||
|
||||
bool is_text() const { return m_text; }
|
||||
void set_text(bool b) { m_text = b; }
|
||||
|
||||
protected:
|
||||
Region(u32 base, u32 size)
|
||||
: m_base(base)
|
||||
|
@ -75,6 +78,7 @@ public:
|
|||
u32 m_size { 0 };
|
||||
|
||||
bool m_stack { false };
|
||||
bool m_text { false };
|
||||
};
|
||||
|
||||
u8 read8(X86::LogicalAddress);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue