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/ld.texi | |
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/ld.texi')
-rw-r--r-- | ld/ld.texi | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -5263,6 +5263,35 @@ the init_priority. In @code{.ctors.NNNNN} and @code{.dtors.NNNNN}, @cindex SORT @code{SORT} is an alias for @code{SORT_BY_NAME}. +@cindex REVERSE +@code{REVERSE} indicates that the sorting should be reversed. If used +on its own then @code{REVERSE} implies @code{SORT_BY_NAME}, otherwise +it reverses the enclosed @code{SORT..} command. Note - reverse +sorting of alignment is not currently supported. + +Note - the sorting commands only accept a single wildcard pattern. So +for example the following will not work: +@smallexample + *(REVERSE(.text* .init*)) +@end smallexample +To resolve this problem list the patterns individually, like this: +@smallexample + *(REVERSE(.text*)) + *(REVERSE(.init*)) +@end smallexample + +Note - you can put the @code{EXCLUDE_FILE} command inside a sorting +command, but not the other way around. So for example: +@smallexample + *(SORT_BY_NAME(EXCLUDE_FILE(foo) .text*)) +@end smallexample +will work, but: +@smallexample + *(EXCLUDE_FILE(foo) SORT_BY_NAME(.text*)) +@end smallexample +will not. + + When there are nested section sorting commands in linker script, there can be at most 1 level of nesting for section sorting commands. @@ -5282,6 +5311,15 @@ treated the same as @code{SORT_BY_NAME} (wildcard section pattern). @code{SORT_BY_ALIGNMENT} (@code{SORT_BY_ALIGNMENT} (wildcard section pattern)) is treated the same as @code{SORT_BY_ALIGNMENT} (wildcard section pattern). @item +@code{SORT_BY_NAME} (@code{REVERSE} (wildcard section pattern)) +reverse sorts by name. +@item +@code{REVERSE} (@code{SORT_BY_NAME} (wildcard section pattern)) +reverse sorts by name. +@item +@code{SORT_BY_INIT_PRIORITY} (@code{REVERSE} (wildcard section pattern)) +reverse sorts by init priority. +@item All other nested section sorting commands are invalid. @end enumerate |