Skip to content

Commit

Permalink
Merge pull request #3743 from masatake/ldscript--sort-keyword
Browse files Browse the repository at this point in the history
LdScript: support SORT keyword
  • Loading branch information
masatake authored May 31, 2023
2 parents 100a7c2 + 49820f4 commit 7eec51e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
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

0 comments on commit 7eec51e

Please sign in to comment.