diff options
author | George Rimar <grimar@accesssoftek.com> | 2016-08-03 08:35:59 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2016-08-03 08:35:59 +0000 |
commit | 350ece4efb2aecfaf21b77fa89124337a9f367d5 (patch) | |
tree | 1c77c9c4098a85c9389245f658e58e622b4f77e9 /lld/test/ELF/linkerscript/linkerscript-sort-nested.s | |
parent | 1af98245f4400c96840fccb91fcfd704fedb9ff7 (diff) | |
download | bcm5719-llvm-350ece4efb2aecfaf21b77fa89124337a9f367d5.tar.gz bcm5719-llvm-350ece4efb2aecfaf21b77fa89124337a9f367d5.zip |
[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
Diffstat (limited to 'lld/test/ELF/linkerscript/linkerscript-sort-nested.s')
-rw-r--r-- | lld/test/ELF/linkerscript/linkerscript-sort-nested.s | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lld/test/ELF/linkerscript/linkerscript-sort-nested.s b/lld/test/ELF/linkerscript/linkerscript-sort-nested.s new file mode 100644 index 00000000000..eed573495fd --- /dev/null +++ b/lld/test/ELF/linkerscript/linkerscript-sort-nested.s @@ -0,0 +1,42 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ +# RUN: %p/Inputs/linkerscript-sort-nested.s -o %t2.o + +## Check sorting first by alignment and then by name. +# RUN: echo "SECTIONS { .aaa : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.aaa.*))) } }" > %t1.script +# RUN: ld.lld -o %t1 --script %t1.script %t1.o %t2.o +# RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=SORTED_AN %s +# SORTED_AN: Contents of section .aaa: +# SORTED_AN-NEXT: 0120 02000000 00000000 22000000 00000000 +# SORTED_AN-NEXT: 0130 11000000 00000000 00000000 00000000 +# SORTED_AN-NEXT: 0140 55000000 00000000 00000000 00000000 +# SORTED_AN-NEXT: 0150 00000000 00000000 00000000 00000000 +# SORTED_AN-NEXT: 0160 01000000 00000000 + +## Check sorting first by name and then by alignment. +# RUN: echo "SECTIONS { .aaa : { *(SORT_BY_NAME(SORT_BY_ALIGNMENT(.aaa.*))) } }" > %t2.script +# RUN: ld.lld -o %t2 --script %t2.script %t1.o %t2.o +# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=SORTED_NA %s +# SORTED_NA: Contents of section .aaa: +# SORTED_NA-NEXT: 0120 11000000 00000000 00000000 00000000 +# SORTED_NA-NEXT: 0130 00000000 00000000 00000000 00000000 +# SORTED_NA-NEXT: 0140 01000000 00000000 02000000 00000000 +# SORTED_NA-NEXT: 0150 22000000 00000000 00000000 00000000 +# SORTED_NA-NEXT: 0160 55000000 00000000 + +.global _start +_start: + nop + +.section .aaa.1, "a" +.align 32 +.quad 1 + +.section .aaa.2, "a" +.align 2 +.quad 2 + +.section .aaa.5, "a" +.align 16 +.quad 0x55 |