From b40add6092b6724f984dd2935e9d2ae72ffef681 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 5 Nov 2020 13:05:27 +0900 Subject: [PATCH] temporary --- mold.h | 5 +++-- object_file.cc | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mold.h b/mold.h index 78063609..c90969f1 100644 --- a/mold.h +++ b/mold.h @@ -151,8 +151,8 @@ class Symbol { public: Symbol(StringRef name, ObjectFile *file = nullptr) : name(name), file(file), needs_got(false), needs_gottp(false), - needs_plt(false), is_dso(false), is_weak(false), is_undef_weak(false), - traced(false) {} + needs_plt(false), is_placeholder(false), is_dso(false), is_weak(false), + is_undef_weak(false), traced(false) {} Symbol(const Symbol &other) : Symbol(other.name, other.file) {} @@ -178,6 +178,7 @@ public: u8 needs_got : 1; u8 needs_gottp : 1; u8 needs_plt : 1; + u8 is_placeholder : 1; u8 is_dso : 1; u8 is_weak : 1; u8 is_undef_weak : 1; diff --git a/object_file.cc b/object_file.cc index d7cbd92e..96cb8fa4 100644 --- a/object_file.cc +++ b/object_file.cc @@ -205,6 +205,18 @@ void ObjectFile::parse() { if (symtab_sec) initialize_symbols(); + + if (Counter::enabled) { + static Counter defined("defined_syms"); + static Counter undefined("undefined_syms"); + + for (const ELF64LE::Sym &esym : elf_syms) { + if (esym.isDefined()) + defined.inc(); + else + undefined.inc(); + } + } } void ObjectFile::resolve_symbols() { @@ -215,9 +227,6 @@ void ObjectFile::resolve_symbols() { Symbol &sym = *symbols[i]; - static Counter counter("defined_syms"); - counter.inc(); - InputSection *isec = nullptr; if (!esym.isAbsolute() && !esym.isCommon()) isec = sections[esym.st_shndx]; @@ -268,9 +277,6 @@ ObjectFile::mark_live_archive_members(tbb::parallel_do_feeder &fee sym.file->is_in_archive && !sym.file->is_alive) { feeder.add(sym.file); - static Counter counter("undefined_syms"); - counter.inc(); - if (UNLIKELY(sym.traced)) llvm::outs() << "trace: " << toString(this) << " keeps " << toString(sym.file) << " for " << sym.name << "\n";