From fea866d910e8551c8528c248b71e0ad596755466 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 15 Sep 2024 19:17:24 +0900 Subject: [PATCH] Refactor --- src/main.cc | 3 --- src/mold.h | 1 - src/passes.cc | 24 +++++++++--------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main.cc b/src/main.cc index 0115c596c3..ca01218bbd 100644 --- a/src/main.cc +++ b/src/main.cc @@ -422,9 +422,6 @@ int mold_main(int argc, char **argv) { // put together in a single phase. resolve_symbols(ctx); - // "Kill" .eh_frame input sections after symbol resolution. - kill_eh_frame_sections(ctx); - // Split mergeable section contents into section pieces. create_merged_sections(ctx); diff --git a/src/mold.h b/src/mold.h index 26a49a4281..2c3aba4824 100644 --- a/src/mold.h +++ b/src/mold.h @@ -1569,7 +1569,6 @@ template void apply_exclude_libs(Context &); template void create_synthetic_sections(Context &); template void set_file_priority(Context &); template void resolve_symbols(Context &); -template void kill_eh_frame_sections(Context &); template void create_merged_sections(Context &); template void convert_common_symbols(Context &); template void create_output_sections(Context &); diff --git a/src/passes.cc b/src/passes.cc index 71c8e00016..9533f53283 100644 --- a/src/passes.cc +++ b/src/passes.cc @@ -358,21 +358,16 @@ void resolve_symbols(Context &ctx) { do_resolve_symbols(ctx); } -} - -// .eh_frame sections are parsed and regenerated by the linker for the purpose -// of deduplication and garbage collection. As such, the input sections should -// not be copied over. -// -// However, in very rare cases (e.g. GCC CRT compiled with LTO) we might need -// to resolve cross-object .eh_frame section references (they only point to -// begin or end and don't depend on the actual section contents). -// Therefore, the sections are "killed" after symbol resolution as a separate -// pass. -template -void kill_eh_frame_sections(Context &ctx) { - Timer t(ctx, "kill_eh_frame_sections"); + // .eh_frame sections are parsed and regenerated by the linker for + // the purpose of deduplication and garbage collection. As such, the + // input sections should not be copied over. + // + // However, in very rare cases (e.g. GCC CRT compiled with LTO) we + // might need to resolve cross-object .eh_frame section references + // (they only point to begin or end and don't depend on the actual + // section contents). Therefore, we kept the sections until symbol + // resolution is done. for (ObjectFile *file : ctx.objs) for (InputSection *sec : file->eh_frame_sections) sec->is_alive = false; @@ -3229,7 +3224,6 @@ template void create_internal_file(Context &); template void apply_exclude_libs(Context &); template void create_synthetic_sections(Context &); template void resolve_symbols(Context &); -template void kill_eh_frame_sections(Context &); template void create_merged_sections(Context &); template void convert_common_symbols(Context &); template void create_output_sections(Context &);