1 // ---- precomp-a.obj - x86_64, hotpatch
2 RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force
3 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix BASE
5 RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /functionpadmin
6 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix PADDED
8 RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /functionpadmin:17
9 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix PADDED-MORE
11 // ---- Many arguments
12 RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /functionpadmin:17 /functionpadmin
13 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix PADDED
15 RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /functionpadmin /functionpadmin:17
16 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix PADDED-MORE
18 RUN: not lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /functionpadmin:zz 2>&1 | FileCheck %s --check-prefix FAIL
20 // ---- precomp-a.obj, precomp-b.obj - x86_64, hotpatch - Ensure several functions are properly padded
21 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /out:%t.exe /nodefaultlib /force
22 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix MULTI-BASE
24 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /out:%t.exe /nodefaultlib /force /functionpadmin
25 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix MULTI-BASE-PADDED
27 RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /out:%t.exe /nodefaultlib /force /functionpadmin:17
28 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix MULTI-BASE-PADDED-MORE
30 // ---- pdb-diff.obj - x86, no hotpatch - No padding is applied
31 RUN: lld-link %S/Inputs/pdb-diff.obj /out:%t.exe /nodefaultlib /force /functionpadmin
32 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix NO-HOTPATCH
34 // ---- hello64.obj - MASM, x86_64, no hotpatch - No padding is applied
35 RUN: lld-link %S/Inputs/hello64.obj /out:%t.exe /nodefaultlib /force /functionpadmin
36 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix HELLO
38 // ---- std64.lib - Import library, x86_64 - Ensure thunks are padded
39 RUN: lld-link %S/Inputs/std64.lib /entry:ExitProcess /out:%t.exe /nodefaultlib /force /subsystem:console
40 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix THUNKS-NO-PAD
41 RUN: llvm-readobj --file-headers %t.exe | FileCheck %s --check-prefix THUNKS-NO-PAD-ENTRY
43 RUN: lld-link %S/Inputs/std64.lib /entry:ExitProcess /out:%t.exe /nodefaultlib /force /functionpadmin /subsystem:console
44 RUN: llvm-objdump -s %t.exe | FileCheck %s --check-prefix THUNKS-PAD
45 RUN: llvm-readobj --file-headers %t.exe | FileCheck %s --check-prefix THUNKS-PAD-ENTRY
47 BASE: Contents of section .text:
48 BASE-NEXT: 140001000 4883ec28 b161e8f5 efffbf33 c04883c4 H..(.a.....3.H..
49 BASE-NEXT: 140001010 28c3 (.
50 BASE-NEXT: Contents of section .rdata:
51 BASE-NEXT: 140002000 01040100 04420000 .....B..
52 BASE-NEXT: Contents of section .pdata:
53 BASE-NEXT: 140003000 00100000 12100000 00200000 ......... ..
55 PADDED: Contents of section .text:
56 PADDED-NEXT: 140001000 cccccccc cccccccc cccccccc cccccccc ................
57 PADDED-NEXT: 140001010 4883ec28 b161e8e5 efffbf33 c04883c4 H..(.a.....3.H..
58 PADDED-NEXT: 140001020 28c3 (.
59 PADDED-NEXT: Contents of section .rdata:
60 PADDED-NEXT: 140002000 01040100 04420000 .....B..
61 PADDED-NEXT: Contents of section .pdata:
62 PADDED-NEXT: 140003000 10100000 22100000 00200000 ....".... ..
64 PADDED-MORE: Contents of section .text:
65 PADDED-MORE-NEXT: 140001000 cccccccc cccccccc cccccccc cccccccc ................
66 PADDED-MORE-NEXT: 140001010 cccccccc cccccccc cccccccc cccccccc ................
67 PADDED-MORE-NEXT: 140001020 4883ec28 b161e8d5 efffbf33 c04883c4 H..(.a.....3.H..
68 PADDED-MORE-NEXT: 140001030 28c3 (.
69 PADDED-MORE-NEXT: Contents of section .rdata:
70 PADDED-MORE-NEXT: 140002000 01040100 04420000 .....B..
71 PADDED-MORE-NEXT: Contents of section .pdata:
72 PADDED-MORE-NEXT: 140003000 20100000 32100000 00200000 ...2.... ..
74 FAIL: lld-link: error: /functionpadmin: invalid argument: zz
76 MULTI-BASE: Contents of section .text:
77 MULTI-BASE-NEXT: 140001000 4883ec28 b161e815 00000033 c04883c4 H..(.a.....3.H..
78 MULTI-BASE-NEXT: 140001010 28c3cccc cccccccc cccccccc cccccccc (...............
79 MULTI-BASE-NEXT: 140001020 884c2408 0fbe4424 08c3 .L$...D$..
80 MULTI-BASE-NEXT: Contents of section .rdata:
81 MULTI-BASE-NEXT: 140002000 01040100 04420000 .....B..
82 MULTI-BASE-NEXT: Contents of section .pdata:
83 MULTI-BASE-NEXT: 140004000 00100000 12100000 00200000 ......... ..
85 MULTI-BASE-PADDED: Contents of section .text:
86 MULTI-BASE-PADDED-NEXT: 140001000 cccccccc cccccccc cccccccc cccccccc ................
87 MULTI-BASE-PADDED-NEXT: 140001010 4883ec28 b161e815 00000033 c04883c4 H..(.a.....3.H..
88 MULTI-BASE-PADDED-NEXT: 140001020 28c3cccc cccccccc cccccccc cccccccc (...............
89 MULTI-BASE-PADDED-NEXT: 140001030 884c2408 0fbe4424 08c3 .L$...D$..
90 MULTI-BASE-PADDED-NEXT: Contents of section .rdata:
91 MULTI-BASE-PADDED-NEXT: 140002000 01040100 04420000 .....B..
92 MULTI-BASE-PADDED-NEXT: Contents of section .pdata:
93 MULTI-BASE-PADDED-NEXT: 140004000 10100000 22100000 00200000 ....".... ..
95 MULTI-BASE-PADDED-MORE: Contents of section .text:
96 MULTI-BASE-PADDED-MORE-NEXT: 140001000 cccccccc cccccccc cccccccc cccccccc ................
97 MULTI-BASE-PADDED-MORE-NEXT: 140001010 cccccccc cccccccc cccccccc cccccccc ................
98 MULTI-BASE-PADDED-MORE-NEXT: 140001020 4883ec28 b161e825 00000033 c04883c4 H..(.a.%...3.H..
99 MULTI-BASE-PADDED-MORE-NEXT: 140001030 28c3cccc cccccccc cccccccc cccccccc (...............
100 MULTI-BASE-PADDED-MORE-NEXT: 140001040 cccccccc cccccccc cccccccc cccccccc ................
101 MULTI-BASE-PADDED-MORE-NEXT: 140001050 884c2408 0fbe4424 08c3 .L$...D$..
102 MULTI-BASE-PADDED-MORE-NEXT: Contents of section .rdata:
103 MULTI-BASE-PADDED-MORE-NEXT: 140002000 01040100 04420000 .....B..
104 MULTI-BASE-PADDED-MORE-NEXT: Contents of section .pdata:
105 MULTI-BASE-PADDED-MORE-NEXT: 140004000 20100000 32100000 00200000 ...2.... ..
108 NO-HOTPATCH: Contents of section .text:
109 NO-HOTPATCH-NEXT: 401000 558becb8 2a000000 5dc3 U...*...].
111 HELLO: Contents of section .text:
112 HELLO-NEXT: 140001000 4883ec28 48c7c100 00000048 8d15f40f H..(H......H....
113 HELLO-NEXT: 140001010 00004c8d 05e70f00 0041b900 000000e8 ..L......A......
114 HELLO-NEXT: 140001020 dcefffbf b9000000 00e8d2ef ffbfe8cd ................
115 HELLO-NEXT: 140001030 efffbf ...
116 HELLO-NEXT: Contents of section .data:
117 HELLO-NEXT: 140002000 48656c6c 6f004865 6c6c6f20 576f726c Hello.Hello Worl
118 HELLO-NEXT: 140002010 642100 d!.
120 THUNKS-NO-PAD: Contents of section .text:
121 THUNKS-NO-PAD-NEXT: 140001000 ff253210 0000 .%2...
122 THUNKS-NO-PAD-NEXT: Contents of section .rdata:
123 THUNKS-NO-PAD-NEXT: 140002000 28200000 00000000 00000000 56200000 ( ..........V ..
124 THUNKS-NO-PAD-NEXT: 140002010 38200000 00000000 00000000 00000000 8 ..............
125 THUNKS-NO-PAD-NEXT: 140002020 00000000 00000000 48200000 00000000 ........H ......
126 THUNKS-NO-PAD-NEXT: 140002030 00000000 00000000 48200000 00000000 ........H ......
127 THUNKS-NO-PAD-NEXT: 140002040 00000000 00000000 00004578 69745072 ..........ExitPr
128 THUNKS-NO-PAD-NEXT: 140002050 6f636573 73007374 6436342e 646c6c00 ocess.std64.dll.
130 THUNKS-NO-PAD-ENTRY-LABEL: ImageOptionalHeader {
131 THUNKS-NO-PAD-ENTRY: AddressOfEntryPoint: 0x1000
132 THUNKS-NO-PAD-ENTRY-NEXT: BaseOfCode: 0x1000
134 THUNKS-PAD: Contents of section .text:
135 THUNKS-PAD-NEXT: 140001000 cccccccc cccccccc cccccccc cccccccc ................
136 THUNKS-PAD-NEXT: 140001010 ff252210 0000 .%"...
137 THUNKS-PAD-NEXT: Contents of section .rdata:
138 THUNKS-PAD-NEXT: 140002000 28200000 00000000 00000000 56200000 ( ..........V ..
139 THUNKS-PAD-NEXT: 140002010 38200000 00000000 00000000 00000000 8 ..............
140 THUNKS-PAD-NEXT: 140002020 00000000 00000000 48200000 00000000 ........H ......
141 THUNKS-PAD-NEXT: 140002030 00000000 00000000 48200000 00000000 ........H ......
142 THUNKS-PAD-NEXT: 140002040 00000000 00000000 00004578 69745072 ..........ExitPr
143 THUNKS-PAD-NEXT: 140002050 6f636573 73007374 6436342e 646c6c00 ocess.std64.dll.
145 THUNKS-PAD-ENTRY-LABEL: ImageOptionalHeader {
146 THUNKS-PAD-ENTRY: AddressOfEntryPoint: 0x1010
147 THUNKS-PAD-ENTRY-NEXT: BaseOfCode: 0x1000