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++)