mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibELF: Convert more string literals to StringView literals.
Most of these won't have perf impact, but the optimization is practically free, so no harm in fixing these up.
This commit is contained in:
parent
ce1775d81d
commit
069fd58381
4 changed files with 17 additions and 17 deletions
|
@ -161,19 +161,19 @@ static void initialize_libc(DynamicObject& libc)
|
|||
// we have to initialize libc just after it is loaded.
|
||||
// Also, we can't just mark `__libc_init` with "__attribute__((constructor))"
|
||||
// because it uses getenv() internally, so `environ` has to be initialized before we call `__libc_init`.
|
||||
auto res = libc.lookup_symbol("environ");
|
||||
auto res = libc.lookup_symbol("environ"sv);
|
||||
VERIFY(res.has_value());
|
||||
*((char***)res.value().address.as_ptr()) = g_envp;
|
||||
|
||||
res = libc.lookup_symbol("__environ_is_malloced");
|
||||
res = libc.lookup_symbol("__environ_is_malloced"sv);
|
||||
VERIFY(res.has_value());
|
||||
*((bool*)res.value().address.as_ptr()) = false;
|
||||
|
||||
res = libc.lookup_symbol("exit");
|
||||
res = libc.lookup_symbol("exit"sv);
|
||||
VERIFY(res.has_value());
|
||||
g_libc_exit = (LibCExitFunction)res.value().address.as_ptr();
|
||||
|
||||
res = libc.lookup_symbol("__libc_init");
|
||||
res = libc.lookup_symbol("__libc_init"sv);
|
||||
VERIFY(res.has_value());
|
||||
typedef void libc_init_func();
|
||||
((libc_init_func*)res.value().address.as_ptr())();
|
||||
|
|
|
@ -429,8 +429,8 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
|
|||
if (!res.has_value()) {
|
||||
// We do not support these
|
||||
// TODO: Can we tell gcc not to generate the piece of code that uses these?
|
||||
// (--disable-tm-clone-registry flag in gcc conifugraion?)
|
||||
if (symbol.name().is_one_of("__deregister_frame_info", "_ITM_registerTMCloneTable", "_ITM_deregisterTMCloneTable", "__register_frame_info"))
|
||||
// (--disable-tm-clone-registry flag in gcc configuration?)
|
||||
if (symbol.name().is_one_of("__deregister_frame_info"sv, "_ITM_registerTMCloneTable"sv, "_ITM_deregisterTMCloneTable"sv, "__register_frame_info"sv))
|
||||
break;
|
||||
|
||||
if (symbol.bind() == STB_WEAK)
|
||||
|
@ -446,7 +446,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
|
|||
}
|
||||
case R_386_RELATIVE: {
|
||||
// FIXME: According to the spec, R_386_relative ones must be done first.
|
||||
// We could explicitly do them first using m_number_of_relocatoins from DT_RELCOUNT
|
||||
// We could explicitly do them first using m_number_of_relocations from DT_RELCOUNT
|
||||
// However, our compiler is nice enough to put them at the front of the relocations for us :)
|
||||
*patch_ptr += (FlatPtr)m_dynamic_object->base_address().as_ptr(); // + addend for RelA (addend for Rel is stored at addr)
|
||||
break;
|
||||
|
|
|
@ -71,7 +71,7 @@ void DynamicObject::dump() const
|
|||
});
|
||||
|
||||
if (m_has_soname)
|
||||
builder.appendff("DT_SONAME: {}\n", soname()); // FIXME: Valdidate that this string is null terminated?
|
||||
builder.appendff("DT_SONAME: {}\n", soname()); // FIXME: Validate that this string is null terminated?
|
||||
|
||||
dbgln_if(DYNAMIC_LOAD_DEBUG, "Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections);
|
||||
dbgln_if(DYNAMIC_LOAD_DEBUG, "{}", builder.string_view());
|
||||
|
@ -215,32 +215,32 @@ DynamicObject::Symbol DynamicObject::symbol(unsigned index) const
|
|||
|
||||
DynamicObject::Section DynamicObject::init_section() const
|
||||
{
|
||||
return Section(*this, m_init_offset, sizeof(void (*)()), sizeof(void (*)()), "DT_INIT");
|
||||
return Section(*this, m_init_offset, sizeof(void (*)()), sizeof(void (*)()), "DT_INIT"sv);
|
||||
}
|
||||
|
||||
DynamicObject::Section DynamicObject::fini_section() const
|
||||
{
|
||||
return Section(*this, m_fini_offset, sizeof(void (*)()), sizeof(void (*)()), "DT_FINI");
|
||||
return Section(*this, m_fini_offset, sizeof(void (*)()), sizeof(void (*)()), "DT_FINI"sv);
|
||||
}
|
||||
|
||||
DynamicObject::Section DynamicObject::init_array_section() const
|
||||
{
|
||||
return Section(*this, m_init_array_offset, m_init_array_size, sizeof(void (*)()), "DT_INIT_ARRAY");
|
||||
return Section(*this, m_init_array_offset, m_init_array_size, sizeof(void (*)()), "DT_INIT_ARRAY"sv);
|
||||
}
|
||||
|
||||
DynamicObject::Section DynamicObject::fini_array_section() const
|
||||
{
|
||||
return Section(*this, m_fini_array_offset, m_fini_array_size, sizeof(void (*)()), "DT_FINI_ARRAY");
|
||||
return Section(*this, m_fini_array_offset, m_fini_array_size, sizeof(void (*)()), "DT_FINI_ARRAY"sv);
|
||||
}
|
||||
|
||||
DynamicObject::RelocationSection DynamicObject::relocation_section() const
|
||||
{
|
||||
return RelocationSection(Section(*this, m_relocation_table_offset, m_size_of_relocation_table, m_size_of_relocation_entry, "DT_REL"));
|
||||
return RelocationSection(Section(*this, m_relocation_table_offset, m_size_of_relocation_table, m_size_of_relocation_entry, "DT_REL"sv));
|
||||
}
|
||||
|
||||
DynamicObject::RelocationSection DynamicObject::plt_relocation_section() const
|
||||
{
|
||||
return RelocationSection(Section(*this, m_plt_relocation_offset_location, m_size_of_plt_relocation_entry_list, m_size_of_relocation_entry, "DT_JMPREL"));
|
||||
return RelocationSection(Section(*this, m_plt_relocation_offset_location, m_size_of_plt_relocation_entry_list, m_size_of_relocation_entry, "DT_JMPREL"sv));
|
||||
}
|
||||
|
||||
auto DynamicObject::HashSection::lookup_sysv_symbol(const StringView& name, u32 hash_value) const -> Optional<Symbol>
|
||||
|
|
|
@ -76,9 +76,9 @@ StringView Image::section_index_to_string(unsigned index) const
|
|||
{
|
||||
VERIFY(m_valid);
|
||||
if (index == SHN_UNDEF)
|
||||
return "Undefined";
|
||||
return "Undefined"sv;
|
||||
if (index >= SHN_LORESERVE)
|
||||
return "Reserved";
|
||||
return "Reserved"sv;
|
||||
return section(index).name();
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ Image::Relocation Image::RelocationSection::relocation(unsigned index) const
|
|||
Image::RelocationSection Image::Section::relocations() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(".rel");
|
||||
builder.append(".rel"sv);
|
||||
builder.append(name());
|
||||
|
||||
auto relocation_section = m_image.lookup_section(builder.to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue