mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibELF: Don't build barely-used section lookup table in ELF::Image
The name-to-section lookup table was only used in a handful of places, and none of them were calling it nearly enough to justify building a cache for it in the first place. So let's get rid of it and reduce startup time by a little bit. :^)
This commit is contained in:
parent
06919d189b
commit
4ed85e9b9e
2 changed files with 6 additions and 12 deletions
|
@ -186,12 +186,6 @@ bool Image::parse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then create a name-to-index map.
|
|
||||||
for (unsigned i = 0; i < section_count(); ++i) {
|
|
||||||
auto section = this->section(i);
|
|
||||||
m_sections.set(section.name(), move(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_valid;
|
return m_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +292,11 @@ Image::RelocationSection Image::Section::relocations() const
|
||||||
Image::Section Image::lookup_section(const String& name) const
|
Image::Section Image::lookup_section(const String& name) const
|
||||||
{
|
{
|
||||||
ASSERT(m_valid);
|
ASSERT(m_valid);
|
||||||
if (auto it = m_sections.find(name); it != m_sections.end())
|
for (unsigned i = 0; i < section_count(); ++i) {
|
||||||
return section((*it).value);
|
auto section = this->section(i);
|
||||||
|
if (section.name() == name)
|
||||||
|
return section;
|
||||||
|
}
|
||||||
return section(0);
|
return section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/ByteBuffer.h>
|
|
||||||
#include <AK/HashMap.h>
|
|
||||||
#include <AK/OwnPtr.h>
|
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
#include <Kernel/VirtualAddress.h>
|
#include <Kernel/VirtualAddress.h>
|
||||||
#include <LibELF/exec_elf.h>
|
#include <LibELF/exec_elf.h>
|
||||||
|
|
||||||
|
@ -230,7 +228,6 @@ private:
|
||||||
const u8* m_buffer { nullptr };
|
const u8* m_buffer { nullptr };
|
||||||
size_t m_size { 0 };
|
size_t m_size { 0 };
|
||||||
bool m_verbose_logging { true };
|
bool m_verbose_logging { true };
|
||||||
HashMap<String, unsigned> m_sections;
|
|
||||||
bool m_valid { false };
|
bool m_valid { false };
|
||||||
unsigned m_symbol_table_section_index { 0 };
|
unsigned m_symbol_table_section_index { 0 };
|
||||||
unsigned m_string_table_section_index { 0 };
|
unsigned m_string_table_section_index { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue