130 lines · plain
1RUN: yaml2obj %p/Inputs/sectionlayout.yaml -o %t.obj2 3## Error on non-exist input layout file4RUN: not lld-link /entry:main /sectionlayout:doesnotexist.txt %t.obj5 6## Order in 1 -> 3 -> 27RUN: echo ".text1" > %t.layout.txt8RUN: echo ".text3" >> %t.layout.txt9RUN: echo ".text2" >> %t.layout.txt10RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj11RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK1 %s12 13## While /sectionlayout:abc is valid, /sectionlayout:@abc is also accepted (to align with MS link.exe)14RUN: lld-link /out:%t.exe /entry:main /sectionlayout:@%t.layout.txt %t.obj15RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK1 %s16 17## Ensure tokens after section name is ignored (for now, to align with MS link.exe)18RUN: echo ".text1 ALIGN=1" > %t.layout.txt19RUN: echo ".text3" >> %t.layout.txt20RUN: echo ".text2" >> %t.layout.txt21RUN: lld-link /out:%t.exe /entry:main /sectionlayout:@%t.layout.txt %t.obj22RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK1 %s23 24CHECK1: Sections [25CHECK1: Section {26CHECK1: Number: 127CHECK1: Name: .text128CHECK1: }29CHECK1: Section {30CHECK1: Number: 231CHECK1: Name: .text332CHECK1: }33CHECK1: Section {34CHECK1: Number: 335CHECK1: Name: .text236CHECK1: }37CHECK1: ]38 39## Order in 3 -> 2 -> 140RUN: echo ".text3" > %t.layout.txt41RUN: echo ".text2" >> %t.layout.txt42RUN: echo ".text1" >> %t.layout.txt43RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj44RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK2 %s45 46CHECK2: Sections [47CHECK2: Section {48CHECK2: Number: 149CHECK2: Name: .text350CHECK2: }51CHECK2: Section {52CHECK2: Number: 253CHECK2: Name: .text254CHECK2: }55CHECK2: Section {56CHECK2: Number: 357CHECK2: Name: .text158CHECK2: }59CHECK2: ]60 61## Put non-exisist section in layout file has no effect; original order is respected62RUN: echo "notexist" > %t.layout.txt63RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj64RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK3 %s65 66## Empty layout file has no effect67RUN: echo "" > %t.layout.txt68RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj69RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK3 %s70 71## Empty layout file has no effect72RUN: echo " " > %t.layout.txt73RUN: echo " " >> %t.layout.txt74RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj75RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK3 %s76 77CHECK3: Sections [78CHECK3: Section {79CHECK3: Number: 180CHECK3: Name: .text181CHECK3: }82CHECK3: Section {83CHECK3: Number: 284CHECK3: Name: .text285CHECK3: }86CHECK3: Section {87CHECK3: Number: 388CHECK3: Name: .text389CHECK3: }90CHECK3: ]91 92## Order in 3 -> 1, but 2 remains unspecified93RUN: echo ".text3" > %t.layout.txt94RUN: echo ".text1" >> %t.layout.txt95RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj96RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK4 %s97 98CHECK4: Sections [99CHECK4: Section {100CHECK4: Number: 1101CHECK4: Name: .text3102CHECK4: }103CHECK4: Section {104CHECK4: Number: 2105CHECK4: Name: .text1106CHECK4: }107CHECK4: Section {108CHECK4: Number: 3109CHECK4: Name: .text2110CHECK4: }111CHECK4: ]112 113## Order in 3 -> 2, but 1 remains unspecified.114## 1 should be the first, as the original order (1 -> 2 -> 3) is respected115RUN: echo ".text3" > %t.layout.txt116RUN: echo ".text2" >> %t.layout.txt117RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj118RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK2 %s119 120## Order in 3 -> 2 -> 1, multiple specification has no effect (the first one is used)121RUN: echo ".text3" > %t.layout.txt122RUN: echo ".text3" >> %t.layout.txt123RUN: echo ".text3" >> %t.layout.txt124RUN: echo ".text2" >> %t.layout.txt125RUN: echo ".text2" >> %t.layout.txt126RUN: echo ".text1" >> %t.layout.txt127RUN: echo ".text3" >> %t.layout.txt128RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj129RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK2 %s130