From cc00df0f0f4a236424f3f5984040691dbae409d2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Feb 2021 18:52:27 +0100 Subject: [PATCH] LibELF: Avoid calling strlen() in DynamicObject::hash_section() The long-term fix here is to make StringView recognize compile-time string literals and do the right thing automatically. --- Userland/Libraries/LibELF/DynamicObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index 47ff8606b0..7e8774dc2a 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -235,7 +235,9 @@ DynamicObject::Section DynamicObject::fini_array_section() const DynamicObject::HashSection DynamicObject::hash_section() const { - const char* section_name = m_hash_type == HashType::SYSV ? "DT_HASH" : "DT_GNU_HASH"; + auto section_name = m_hash_type == HashType::SYSV + ? StringView { "DT_HASH", 7 } + : StringView { "DT_GNU_HASH", 11 }; return HashSection(Section(*this, m_hash_table_offset, 0, 0, section_name), m_hash_type); }