[ELF] - Linkerscript: support all kinds of sorting (including nested).
authorGeorge Rimar <grimar@accesssoftek.com>
Wed, 3 Aug 2016 08:35:59 +0000 (08:35 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Wed, 3 Aug 2016 08:35:59 +0000 (08:35 +0000)
commit350ece4efb2aecfaf21b77fa89124337a9f367d5
tree1c77c9c4098a85c9389245f658e58e622b4f77e9
parent1af98245f4400c96840fccb91fcfd704fedb9ff7
[ELF] - Linkerscript: support all kinds of sorting (including nested).

Previously we supported only sorting by name.

When there are nested section sorting commands in linker script, there can be at most 1
level of nesting for section sorting commands.

SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It will sort the input
sections by name first, then by alignment if 2 sections have the same name.

SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It will sort the input
sections by alignment first, then by name if 2 sections have the same alignment.

SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated the same as SORT_
BY_NAME (wildcard section pattern).

SORT_BY_ALIGNMENT (SORT_BY_ALIGNMENT (wildcard section pattern)) is treated the
same as SORT_BY_ALIGNMENT (wildcard section pattern).

All other nested section sorting commands are invalid.

Patch implements that all above.

Differential revision: https://reviews.llvm.org/D23019

llvm-svn: 277583
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
lld/test/ELF/linkerscript/Inputs/linkerscript-sort-nested.s [new file with mode: 0644]
lld/test/ELF/linkerscript/Inputs/linkerscript-sort.s
lld/test/ELF/linkerscript/linkerscript-sort-nested.s [new file with mode: 0644]
lld/test/ELF/linkerscript/linkerscript-sort.s