summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibELF
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-25 11:33:03 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-25 18:57:06 +0100
commit98e4e2aae3c2e33e012d1895b31f80b5491284be (patch)
treebc2f0b12b98e3398c4c1456f132390eb8c879d74 /Userland/Libraries/LibELF
parente9fd81b9645383c72087d0a9b8a368b9608fa30e (diff)
downloadserenity-98e4e2aae3c2e33e012d1895b31f80b5491284be.zip
LibELF: Convert dbgprintf() in DynamicLinker class to dbgln()
Diffstat (limited to 'Userland/Libraries/LibELF')
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.cpp37
1 files changed, 14 insertions, 23 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp
index 932ade6482..ce09d4c552 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.cpp
+++ b/Userland/Libraries/LibELF/DynamicLinker.cpp
@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/HashTable.h>
#include <AK/LexicalPath.h>
@@ -46,15 +47,6 @@
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef DYNAMIC_LOAD_VERBOSE
-# define VERBOSE(fmt, ...) dbgprintf(fmt, ##__VA_ARGS__)
-#else
-# define VERBOSE(fmt, ...) \
- do { \
- } while (0)
-#endif
-#define TLS_VERBOSE(fmt, ...) dbgprintf(fmt, ##__VA_ARGS__)
-
namespace ELF {
namespace {
@@ -135,10 +127,10 @@ static Vector<String> get_dependencies(const String& name)
static void map_dependencies(const String& name)
{
- VERBOSE("mapping dependencies for: %s\n", name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("mapping dependencies for: {}", name);
for (const auto& needed_name : get_dependencies(name)) {
- VERBOSE("needed library: %s\n", needed_name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("needed library: {}", needed_name.characters());
String library_name = get_library_name(needed_name);
if (!g_loaders.contains(library_name)) {
@@ -146,19 +138,19 @@ static void map_dependencies(const String& name)
map_dependencies(library_name);
}
}
- VERBOSE("mapped dependencies for %s\n", name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("mapped dependencies for {}", name);
}
static void allocate_tls()
{
size_t total_tls_size = 0;
for (const auto& data : g_loaders) {
- VERBOSE("%s: TLS Size: %zu\n", data.key.characters(), data.value->tls_size());
+ dbgln<DYNAMIC_LOAD_DEBUG>("{}: TLS Size: {}", data.key, data.value->tls_size());
total_tls_size += data.value->tls_size();
}
if (total_tls_size) {
[[maybe_unused]] void* tls_address = ::allocate_tls(total_tls_size);
- VERBOSE("from userspace, tls_address: %p\n", tls_address);
+ dbgln<DYNAMIC_LOAD_DEBUG>("from userspace, tls_address: {:p}", tls_address);
}
g_total_tls_size = total_tls_size;
}
@@ -190,11 +182,10 @@ static void initialize_libc(DynamicObject& libc)
static void load_elf(const String& name)
{
- VERBOSE("load_elf: %s\n", name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("load_elf: {}", name);
auto loader = g_loaders.get(name).value();
- VERBOSE("a1\n");
for (const auto& needed_name : get_dependencies(name)) {
- VERBOSE("needed library: %s\n", needed_name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("needed library: {}", needed_name);
String library_name = get_library_name(needed_name);
if (!g_loaded_objects.contains(library_name)) {
load_elf(library_name);
@@ -207,7 +198,7 @@ static void load_elf(const String& name)
g_loaded_objects.set(name, *dynamic_object);
g_global_objects.append(*dynamic_object);
- VERBOSE("load_elf: done %s\n", name.characters());
+ dbgln<DYNAMIC_LOAD_DEBUG>("load_elf: done {}", name);
}
static NonnullRefPtr<DynamicLoader> commit_elf(const String& name)
@@ -249,9 +240,9 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
map_library(main_program_name, main_program_fd);
map_dependencies(main_program_name);
- VERBOSE("loaded all dependencies");
+ dbgln<DYNAMIC_LOAD_DEBUG>("loaded all dependencies");
for ([[maybe_unused]] auto& lib : g_loaders) {
- VERBOSE("%s - tls size: %zu, tls offset: %zu\n", lib.key.characters(), lib.value->tls_size(), lib.value->tls_offset());
+ dbgln<DYNAMIC_LOAD_DEBUG>("{} - tls size: {}, tls offset: {}", lib.key, lib.value->tls_size(), lib.value->tls_offset());
}
allocate_tls();
@@ -263,16 +254,16 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
if (main_program_lib->is_dynamic())
entry_point += reinterpret_cast<FlatPtr>(main_program_lib->text_segment_load_address().as_ptr());
- VERBOSE("entry point: %p\n", (void*)entry_point);
+ dbgln<DYNAMIC_LOAD_DEBUG>("entry point: {:p}", (void*)entry_point);
g_loaders.clear();
MainFunction main_function = (MainFunction)(entry_point);
- VERBOSE("jumping to main program entry point: %p\n", main_function);
+ dbgln<DYNAMIC_LOAD_DEBUG>("jumping to main program entry point: {:p}", main_function);
if (g_do_breakpoint_trap_before_entry) {
asm("int3");
}
int rc = main_function(argc, argv, envp);
- VERBOSE("rc: %d\n", rc);
+ dbgln<DYNAMIC_LOAD_DEBUG>("rc: {}", rc);
if (g_libc_exit != nullptr) {
g_libc_exit(rc);
} else {