aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.h
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2022-07-28 14:55:05 +0200
committerMichael Matz <matz@suse.de>2022-11-30 17:15:07 +0100
commit43ae96e94ab7e3d5dfdb0d7c1b6ba57814a43f1d (patch)
tree871b195db8aee37bf964239b6e27e2f2ed6a1686 /ld/ldlang.h
parentf978da64412f37228bba9f79b3c68b7c6917379c (diff)
downloadgdb-43ae96e94ab7e3d5dfdb0d7c1b6ba57814a43f1d.zip
gdb-43ae96e94ab7e3d5dfdb0d7c1b6ba57814a43f1d.tar.gz
gdb-43ae96e94ab7e3d5dfdb0d7c1b6ba57814a43f1d.tar.bz2
section-select: Lazily resolve section matches
and remember the results. Before this the order of section matching is basically: foreach script-wild-stmt S foreach pattern P of S foreach inputfile I foreach section S of I match S against P if match: do action for S And this process is done three or four times: for each top-level call to walk_wild() or wild(), that is: check_input_sections, lang_gc_sections, lang_find_relro_sections and of course map_input_to_output_sections. So we iterate over all sections of all files many many times (for each glob). Reality is a bit more complicated (some special glob types don't need the full iteration over all sections, only over all files), but that's the gist of it. For future work this shuffles the whole ordering a bit by lazily doing the matching process and memoizing results, trading a little memory for a 75% speedup of the overall section selection process. This lazy resolution introduces a problem with sections added late that's corrected in the next patch.
Diffstat (limited to 'ld/ldlang.h')
-rw-r--r--ld/ldlang.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 713c528..50ad64c 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -76,6 +76,7 @@ enum statement_enum
lang_fill_statement_enum,
lang_group_statement_enum,
lang_input_section_enum,
+ lang_input_matcher_enum,
lang_input_statement_enum,
lang_insert_statement_enum,
lang_output_section_statement_enum,
@@ -335,6 +336,14 @@ typedef struct
void *pattern;
} lang_input_section_type;
+typedef struct
+{
+ lang_statement_header_type header;
+ asection *section;
+ void *pattern;
+ lang_input_statement_type *input_stmt;
+} lang_input_matcher_type;
+
struct map_symbol_def {
struct bfd_link_hash_entry *entry;
struct map_symbol_def *next;
@@ -389,6 +398,8 @@ struct lang_wild_statement_struct
bool keep_sections;
lang_statement_list_type children;
struct name_list *exclude_name_list;
+ lang_statement_list_type matching_sections;
+ bool resolved;
walk_wild_section_handler_t walk_wild_section_handler;
struct wildcard_list *handler_data[4];
@@ -440,6 +451,7 @@ typedef union lang_statement_union
lang_fill_statement_type fill_statement;
lang_group_statement_type group_statement;
lang_input_section_type input_section;
+ lang_input_matcher_type input_matcher;
lang_input_statement_type input_statement;
lang_insert_statement_type insert_statement;
lang_output_section_statement_type output_section_statement;