From 10993a32513b5d9fd1a67cbf932f24f4aadd2681 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 13 Jun 2021 16:17:04 +0900 Subject: [PATCH] Fix --relocatable --- relocatable.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/relocatable.cc b/relocatable.cc index 47ee80c5..5db6846c 100644 --- a/relocatable.cc +++ b/relocatable.cc @@ -174,8 +174,11 @@ void RSymtabSection::add_global_symbol(Context &ctx, RObjectFile &file, return; } - // TODO file.symidx[idx] = it->second; + + ElfSym &existing = syms[it->second]; + if (existing.is_undef() && !sym.is_undef()) + existing = sym; } template @@ -467,7 +470,7 @@ void combine_objects(Context &ctx, std::span file_args) { for (i64 i = 1; i < file->first_global; i++) symtab.add_local_symbol(ctx, *file, i); - symtab.out_shdr.sh_info = symtab.syms.size() + 1; + symtab.out_shdr.sh_info = symtab.syms.size(); for (std::unique_ptr> &file : files) for (i64 i = file->first_global; i < file->syms.size(); i++)