From c5e52be5d4500e69e512dd3418b9aee142e348d8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 25 Jan 2021 11:56:08 +0100 Subject: [PATCH] LibELF: Convert dbgprintf() in DynamicObject class to dbgln() --- Userland/Libraries/LibELF/DynamicObject.cpp | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index de0eab9388b..9189c68c942 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -25,6 +25,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -33,14 +34,6 @@ #include #include -#ifdef DYNAMIC_OBJECT_VERBOSE -# define VERBOSE(fmt, ...) dbgprintf(fmt, ##__VA_ARGS__) -#else -# define VERBOSE(fmt, ...) \ - do { \ - } while (0) -#endif - namespace ELF { static const char* name_for_dtag(Elf32_Sword d_tag); @@ -80,8 +73,8 @@ void DynamicObject::dump() const if (m_has_soname) builder.appendf("DT_SONAME: %s\n", soname()); // FIXME: Valdidate that this string is null terminated? - VERBOSE("Dynamic section at address %p contains %zu entries:\n", m_dynamic_address.as_ptr(), num_dynamic_sections); - VERBOSE("%s", builder.to_string().characters()); + dbgln("Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections); + dbgln("{}", builder.string_view()); } void DynamicObject::parse() @@ -175,8 +168,7 @@ void DynamicObject::parse() // We handle these in for_each_needed_library break; default: - dbgprintf("DynamicObject: DYNAMIC tag handling not implemented for DT_%s\n", name_for_dtag(entry.tag())); - printf("DynamicObject: DYNAMIC tag handling not implemented for DT_%s\n", name_for_dtag(entry.tag())); + dbgln("DynamicObject: DYNAMIC tag handling not implemented for DT_{}", name_for_dtag(entry.tag())); ASSERT_NOT_REACHED(); // FIXME: Maybe just break out here and return false? break; } @@ -311,7 +303,7 @@ const DynamicObject::Symbol DynamicObject::HashSection::lookup_elf_symbol(const for (u32 i = buckets[hash_value % num_buckets]; i; i = chains[i]) { auto symbol = m_dynamic.symbol(i); if (strcmp(name, symbol.name()) == 0) { - VERBOSE("Returning SYSV dynamic symbol with index %u for %s: %p\n", i, symbol.name(), symbol.address().as_ptr()); + dbgln("Returning SYSV dynamic symbol with index {} for {}: {}", i, symbol.name(), symbol.address().as_ptr()); return symbol; } } @@ -356,7 +348,7 @@ const DynamicObject::Symbol DynamicObject::HashSection::lookup_gnu_symbol(const hash2 = *(current_chain++); const auto symbol = m_dynamic.symbol(current_sym); if ((hash1 == (hash2 & ~1)) && strcmp(name, symbol.name()) == 0) { - VERBOSE("Returning GNU dynamic symbol with index %zu for %s: %p\n", current_sym, symbol.name(), symbol.address().as_ptr()); + dbgln("Returning GNU dynamic symbol with index {} for {}: {}", current_sym, symbol.name(), symbol.address().as_ptr()); return symbol; } if (hash2 & 1) { @@ -502,7 +494,7 @@ Elf32_Addr DynamicObject::patch_plt_entry(u32 relocation_offset) u32 symbol_location = res.address; - VERBOSE("DynamicLoader: Jump slot relocation: putting %s (%p) into PLT at %p\n", sym.name(), (void*)symbol_location, (void*)relocation_address); + dbgln("DynamicLoader: Jump slot relocation: putting {} ({:p}) into PLT at {}", sym.name(), symbol_location, (void*)relocation_address); *(u32*)relocation_address = symbol_location; @@ -511,12 +503,12 @@ Elf32_Addr DynamicObject::patch_plt_entry(u32 relocation_offset) DynamicObject::SymbolLookupResult DynamicObject::lookup_symbol(const ELF::DynamicObject::Symbol& symbol) const { - VERBOSE("looking up symbol: %s\n", symbol.name()); + dbgln("looking up symbol: {}", symbol.name()); if (symbol.is_undefined() || symbol.bind() == STB_WEAK) return DynamicLinker::lookup_global_symbol(symbol.name()); if (!symbol.is_undefined()) { - VERBOSE("symbol is defined in its object\n"); + dbgln("symbol is defined in its object"); return { true, symbol.value(), (FlatPtr)symbol.address().as_ptr(), symbol.bind(), &symbol.object() }; } return DynamicLinker::lookup_global_symbol(symbol.name());