diff --git a/input_files.cc b/input_files.cc index b8cb3b12..b3b2e5c8 100644 --- a/input_files.cc +++ b/input_files.cc @@ -344,22 +344,6 @@ void ObjectFile::convert_common_symbols() { } } -std::tuple ObjectFile::scan_relocations() { - i32 num_got = 0; - i32 num_gotplt = 0; - i32 num_plt = 0; - - for (InputSection *isec : sections) { - if (isec) { - auto [got, gotplt, plt] = isec->scan_relocations(); - num_got += got; - num_gotplt += gotplt; - num_plt += plt; - } - } - return {num_got, num_gotplt, num_plt}; -} - void ObjectFile::fix_sym_addrs() { for (Symbol *sym : symbols) { if (sym->file != this) diff --git a/input_sections.cc b/input_sections.cc index 4f5f6537..273e6ef7 100644 --- a/input_sections.cc +++ b/input_sections.cc @@ -26,11 +26,7 @@ void InputSection::copy_to(u8 *buf) { memcpy_nontemporal(buf, &data[0], data.size()); } -std::tuple InputSection::scan_relocations() { - i32 num_got = 0; - i32 num_gotplt = 0; - i32 num_plt = 0; - +void InputSection::scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt) { for (const ELF64LE::Rela &rel : rels) { Symbol *sym = file->get_symbol(rel.getSymbol(false)); if (!sym || !sym->file) @@ -84,8 +80,6 @@ std::tuple InputSection::scan_relocations() { } } } - - return {num_got, num_gotplt, num_plt}; } void InputSection::relocate(u8 *buf) { diff --git a/main.cc b/main.cc index b1f52c8a..e7c3df32 100644 --- a/main.cc +++ b/main.cc @@ -533,7 +533,12 @@ int main(int argc, char **argv) { std::atomic_int32_t num_plt = 0; for_each(files, [&](ObjectFile *file) { - auto [got, gotplt, plt] = file->scan_relocations(); + i32 got = 0, gotplt = 0, plt = 0; + + for (InputSection *isec : file->sections) + if (isec) + isec->scan_relocations(got, gotplt, plt); + num_got += got; num_gotplt += gotplt; num_plt += plt; diff --git a/mold.h b/mold.h index 8054ae2f..eb69f7fe 100644 --- a/mold.h +++ b/mold.h @@ -210,7 +210,7 @@ public: void copy_to(u8 *buf); void relocate(u8 *buf); - std::tuple scan_relocations(); + void scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt); ObjectFile *file; OutputSection *output_section; @@ -514,7 +514,6 @@ public: void hanlde_undefined_weak_symbols(); void eliminate_duplicate_comdat_groups(); void convert_common_symbols(); - std::tuple scan_relocations(); void fix_sym_addrs(); void compute_symtab();