Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 15, 2024
1 parent 3b3bc7b commit fea866d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion src/mold.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,6 @@ template <typename E> void apply_exclude_libs(Context<E> &);
template <typename E> void create_synthetic_sections(Context<E> &);
template <typename E> void set_file_priority(Context<E> &);
template <typename E> void resolve_symbols(Context<E> &);
template <typename E> void kill_eh_frame_sections(Context<E> &);
template <typename E> void create_merged_sections(Context<E> &);
template <typename E> void convert_common_symbols(Context<E> &);
template <typename E> void create_output_sections(Context<E> &);
Expand Down
24 changes: 9 additions & 15 deletions src/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,16 @@ void resolve_symbols(Context<E> &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 <typename E>
void kill_eh_frame_sections(Context<E> &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<E> *file : ctx.objs)
for (InputSection<E> *sec : file->eh_frame_sections)
sec->is_alive = false;
Expand Down Expand Up @@ -3229,7 +3224,6 @@ template void create_internal_file(Context<E> &);
template void apply_exclude_libs(Context<E> &);
template void create_synthetic_sections(Context<E> &);
template void resolve_symbols(Context<E> &);
template void kill_eh_frame_sections(Context<E> &);
template void create_merged_sections(Context<E> &);
template void convert_common_symbols(Context<E> &);
template void create_output_sections(Context<E> &);
Expand Down

0 comments on commit fea866d

Please sign in to comment.