Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LdScript: support SORT keyword #3743

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-ldscript.r/sort.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--extras=+r
--fields=+r
27 changes: 27 additions & 0 deletions Units/parser-ldscript.r/sort.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.discard input.lds /^ *(.discard)$/;" i roles:discarded
.discard. input.lds /^ *(.discard.*)$/;" i roles:discarded
__ksymtab input.lds /^ __ksymtab 0 : { *(SORT(___ksymtab+*)) }$/;" S roles:def
___ksymtab input.lds /^ __ksymtab 0 : { *(SORT(___ksymtab+*)) }$/;" i section:__ksymtab roles:mapped
__ksymtab_gpl input.lds /^ __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }$/;" S roles:def
___ksymtab_gpl input.lds /^ __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }$/;" i section:__ksymtab_gpl roles:mapped
__ksymtab_unused input.lds /^ __ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }$/;" S roles:def
___ksymtab_unused input.lds /^ __ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }$/;" i section:__ksymtab_unused roles:mapped
__ksymtab_unused_gpl input.lds /^ __ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }$/;" S roles:def
___ksymtab_unused_gpl input.lds /^ __ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }$/;" i section:__ksymtab_unused_gpl roles:mapped
__ksymtab_gpl_future input.lds /^ __ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }$/;" S roles:def
___ksymtab_gpl_future input.lds /^ __ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }$/;" i section:__ksymtab_gpl_future roles:mapped
__kcrctab input.lds /^ __kcrctab 0 : { *(SORT(___kcrctab+*)) }$/;" S roles:def
___kcrctab input.lds /^ __kcrctab 0 : { *(SORT(___kcrctab+*)) }$/;" i section:__kcrctab roles:mapped
__kcrctab_gpl input.lds /^ __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }$/;" S roles:def
___kcrctab_gpl input.lds /^ __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }$/;" i section:__kcrctab_gpl roles:mapped
__kcrctab_unused input.lds /^ __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }$/;" S roles:def
___kcrctab_unused input.lds /^ __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }$/;" i section:__kcrctab_unused roles:mapped
__kcrctab_unused_gpl input.lds /^ __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }$/;" S roles:def
___kcrctab_unused_gpl input.lds /^ __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }$/;" i section:__kcrctab_unused_gpl roles:mapped
__kcrctab_gpl_future input.lds /^ __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }$/;" S roles:def
___kcrctab_gpl_future input.lds /^ __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }$/;" i section:__kcrctab_gpl_future roles:mapped
.init_array input.lds /^ .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }$/;" S roles:def
.init_array. input.lds /^ .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }$/;" i section:.init_array roles:mapped
.init_array input.lds /^ .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }$/;" i section:.init_array roles:mapped
__jump_table input.lds /^ __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }$/;" S roles:def
__jump_table input.lds /^ __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }$/;" i section:__jump_table roles:mapped
27 changes: 27 additions & 0 deletions Units/parser-ldscript.r/sort.d/input.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Taken from linux/scripts/module-common.lds */
/*
* Common module linker script, always used when linking a module.
* Archs are free to supply their own linker scripts. ld will
* combine them automatically.
*/
SECTIONS {
/DISCARD/ : {
*(.discard)
*(.discard.*)
}

__ksymtab 0 : { *(SORT(___ksymtab+*)) }
__ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
__ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }
__ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }
__ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }
__kcrctab 0 : { *(SORT(___kcrctab+*)) }
__kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
__kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }
__kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }
__kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }

.init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }

__jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }
}
1 change: 1 addition & 0 deletions parsers/ldscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static const keywordTable LdScriptKeywordTable[] = {
{ "INPUT_SECTION_FLAGS", KEYWORD_INPUT_SECTION_FLAGS },
{ "COMMON", KEYWORD_COMMON },
{ "KEEP", KEYWORD_KEEP },
{ "SORT", KEYWORD_KEEP },
{ "BYTE", KEYWORD_DATA },
{ "SHORT", KEYWORD_DATA },
{ "LONG", KEYWORD_DATA },
Expand Down