diff options
author | Nick Clifton <nickc@redhat.com> | 2023-11-01 13:51:17 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2023-11-01 13:51:17 +0000 |
commit | 85921e9a2588bf4820b827fc1630f5d7da22cb1c (patch) | |
tree | fb6aeb7e8af93f947d5930d90cfcc3e41812e4d7 /ld/ldgram.y | |
parent | f514e6e48061661cacfc980cd5272fd99887d38b (diff) | |
download | gdb-85921e9a2588bf4820b827fc1630f5d7da22cb1c.zip gdb-85921e9a2588bf4820b827fc1630f5d7da22cb1c.tar.gz gdb-85921e9a2588bf4820b827fc1630f5d7da22cb1c.tar.bz2 |
ld: Support input section description keyword: REVERSE
PR 27565
* ldlex.l: Add REVERSE.
* ldgram.y: Allow REVERSE to be used wherever a sorting command can be used.
* ld.h (struct wildcard_spec): Add 'reversed' field.
* ldlang.h (lang_wild_statement_struct): Add 'filenames_reversed' field.
* ldlang.c (compare_sections): Add reversed parameter. (wild_sort): Reverse the comparison if requested. (print_wild_statement): Handle the reversed field.
* ld.texi: Document the new feature.
* NEWS: Mention the new feature.
* testsuite/ld-scripts/sort-file-reversed-1.d: New test driver.
* testsuite/ld-scripts/sort-file-reversed-1.t: New test source.
* testsuite/ld-scripts/sort-file-reversed-2.t: New test source.
* testsuite/ld-scripts/sort-file-reversed-2.d: New test driver.
* testsuite/ld-scripts/sort-sections-reversed-1.d: New test driver.
* testsuite/ld-scripts/sort-sections-reversed-1.t: New test source.
* testsuite/ld-scripts/sort-sections-reversed-2.t: New test source.
* testsuite/ld-scripts/sort-sections-reversed-2.d: New test driver.
* testsuite/ld-scripts/sort-sections-reversed-3.d: New test driver.
* testsuite/ld-scripts/sort-sections-reversed-3.t: New test source.
Diffstat (limited to 'ld/ldgram.y')
-rw-r--r-- | ld/ldgram.y | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/ld/ldgram.y b/ld/ldgram.y index 2b4b507..7b7ae8a 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -102,7 +102,7 @@ static void yyerror (const char *); %type <flag_info> sect_flags %type <name> memspec_opt memspec_at_opt paren_script_name casesymlist %type <cname> wildcard_name -%type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude +%type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude wildcard_maybe_reverse %token <bigint> INT %token <name> NAME LNAME %type <integer> length @@ -132,7 +132,7 @@ static void yyerror (const char *); %token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE -%token SORT_BY_INIT_PRIORITY +%token SORT_BY_INIT_PRIORITY REVERSE %token '{' '}' %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION @@ -440,6 +440,7 @@ wildcard_maybe_exclude: $$.sorted = none; $$.exclude_name_list = NULL; $$.section_flag_list = NULL; + $$.reversed = false; } | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name { @@ -447,65 +448,95 @@ wildcard_maybe_exclude: $$.sorted = none; $$.exclude_name_list = $3; $$.section_flag_list = NULL; + $$.reversed = false; } ; -filename_spec: +wildcard_maybe_reverse: wildcard_maybe_exclude - | SORT_BY_NAME '(' wildcard_maybe_exclude ')' + | REVERSE '(' wildcard_maybe_exclude ')' { $$ = $3; + $$.reversed = true; $$.sorted = by_name; } - | SORT_NONE '(' wildcard_maybe_exclude ')' + ; + +filename_spec: + wildcard_maybe_reverse + | SORT_BY_NAME '(' wildcard_maybe_reverse ')' + { + $$ = $3; + $$.sorted = by_name; + } + | SORT_NONE '(' wildcard_maybe_reverse ')' { $$ = $3; $$.sorted = by_none; + $$.reversed = false; + } + | REVERSE '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')' + { + $$ = $5; + $$.sorted = by_name; + $$.reversed = true; } ; section_name_spec: - wildcard_maybe_exclude - | SORT_BY_NAME '(' wildcard_maybe_exclude ')' + wildcard_maybe_reverse + | SORT_BY_NAME '(' wildcard_maybe_reverse ')' { $$ = $3; $$.sorted = by_name; } - | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' + | SORT_BY_ALIGNMENT '(' wildcard_maybe_reverse ')' { $$ = $3; $$.sorted = by_alignment; } - | SORT_NONE '(' wildcard_maybe_exclude ')' + | SORT_NONE '(' wildcard_maybe_reverse ')' { $$ = $3; $$.sorted = by_none; } - | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')' + | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_reverse ')' ')' { $$ = $5; $$.sorted = by_name_alignment; } - | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')' + | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_reverse ')' ')' { $$ = $5; $$.sorted = by_name; } - | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')' + | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_reverse ')' ')' { $$ = $5; $$.sorted = by_alignment_name; } - | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')' + | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_reverse ')' ')' { $$ = $5; $$.sorted = by_alignment; } - | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')' + | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_reverse ')' { $$ = $3; $$.sorted = by_init_priority; } + | REVERSE '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')' + { + $$ = $5; + $$.sorted = by_name; + $$.reversed = true; + } + | REVERSE '(' SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')' ')' + { + $$ = $5; + $$.sorted = by_init_priority; + $$.reversed = true; + } ; sect_flag_list: NAME |