1// REQUIRES: x86-registered-target
2// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t
3// RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU
4// RUN: llvm-readobj --elf-output-style LLVM --notes %t | FileCheck %s --check-prefix=LLVM
5
6// GNU:      Displaying notes found in: .note.gnu.property
7// GNU-NEXT:   Owner                 Data size       Description
8// GNU-NEXT:   GNU                   0x000000e8      NT_GNU_PROPERTY_TYPE_0 (property note)
9// GNU-NEXT:     Properties:  stack size: 0x100
10// GNU-NEXT:     stack size: 0x100
11// GNU-NEXT:     no copy on protected
12// GNU-NEXT:     x86 feature: SHSTK
13// GNU-NEXT:     x86 feature: IBT, SHSTK
14// GNU-NEXT:     x86 feature: <None>
15// GNU-NEXT:     x86 feature needed: x86, x87, MMX, XMM, YMM
16// GNU-NEXT:     x86 feature used: ZMM, FXSR, XSAVE, XSAVEOPT, XSAVEC
17// GNU-NEXT:     x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
18// GNU-NEXT:     x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
19// GNU-NEXT:     <application-specific type 0xfefefefe>
20// GNU-NEXT:     stack size: <corrupt length: 0x0>
21// GNU-NEXT:     stack size: <corrupt length: 0x4>
22// GNU-NEXT:     no copy on protected <corrupt length: 0x1>
23// GNU-NEXT:     x86 feature: <corrupt length: 0x0>
24// GNU-NEXT:     x86 feature: IBT, <unknown flags: 0xf000f000>
25// GNU-NEXT:     <corrupt type (0x2) datasz: 0x1>
26
27// LLVM:      Notes [
28// LLVM-NEXT:   NoteSection {
29// LLVM-NEXT:     Name: .note.gnu.property
30// LLVM-NEXT:     Offset: 0x40
31// LLVM-NEXT:     Size: 0xF8
32// LLVM-NEXT:     Note {
33// LLVM-NEXT:       Owner: GNU
34// LLVM-NEXT:       Data size: 0xE8
35// LLVM-NEXT:       Type: NT_GNU_PROPERTY_TYPE_0 (property note)
36// LLVM-NEXT:       Property [
37// LLVM-NEXT:         stack size: 0x100
38// LLVM-NEXT:         stack size: 0x100
39// LLVM-NEXT:         no copy on protected
40// LLVM-NEXT:         x86 feature: SHSTK
41// LLVM-NEXT:         x86 feature: IBT, SHSTK
42// LLVM-NEXT:         x86 feature: <None>
43// LLVM-NEXT:         x86 feature needed: x86, x87, MMX, XMM, YMM
44// LLVM-NEXT:         x86 feature used: ZMM, FXSR, XSAVE, XSAVEOPT, XSAVEC
45// LLVM-NEXT:         x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
46// LLVM-NEXT:         x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4
47// LLVM-NEXT:         <application-specific type 0xfefefefe>
48// LLVM-NEXT:         stack size: <corrupt length: 0x0>
49// LLVM-NEXT:         stack size: <corrupt length: 0x4>
50// LLVM-NEXT:         no copy on protected <corrupt length: 0x1>
51// LLVM-NEXT:         x86 feature: <corrupt length: 0x0>
52// LLVM-NEXT:         x86 feature: IBT, <unknown flags: 0xf000f000>
53// LLVM-NEXT:         <corrupt type (0x2) datasz: 0x1>
54// LLVM-NEXT:       ]
55// LLVM-NEXT:     }
56// LLVM-NEXT:   }
57// LLVM-NEXT: ]
58
59.section ".note.gnu.property", "a"
60.align 4
61  .long 4           /* Name length is always 4 ("GNU") */
62  .long end - begin /* Data length */
63  .long 5           /* Type: NT_GNU_PROPERTY_TYPE_0 */
64  .asciz "GNU"      /* Name */
65  .p2align 3
66begin:
67  .long 1           /* Type: GNU_PROPERTY_STACK_SIZE */
68  .long 8           /* Data size */
69  .quad 0x100       /* Data (stack size) */
70  .p2align 3        /* Align to 8 byte for 64 bit */
71
72  /* Test we handle alignment properly */
73  .long 1           /* Type: GNU_PROPERTY_STACK_SIZE */
74  .long 8           /* Data size */
75  .long 0x100       /* Data (stack size) */
76  .p2align 3        /* Align to 8 byte for 64 bit */
77
78  .long 2           /* Type: GNU_PROPERTY_NO_COPY_ON_PROTECTED */
79  .long 0           /* Data size */
80  .p2align 3        /* Align to 8 byte for 64 bit */
81
82  /* CET property note */
83  .long 0xc0000002  /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
84  .long 4           /* Data size */
85  .long 2           /* GNU_PROPERTY_X86_FEATURE_1_SHSTK */
86  .p2align 3        /* Align to 8 byte for 64 bit */
87
88  /* CET property note with padding */
89  .long 0xc0000002  /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
90  .long 4           /* Data size */
91  .long 3           /* Full CET support */
92  .p2align 3        /* Align to 8 byte for 64 bit */
93
94  .long 0xc0000002  /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
95  .long 4           /* Data size */
96  .long 0           /* Empty flags, not an error */
97  .p2align 3        /* Align to 8 byte for 64 bit */
98
99  .long 0xc0008001         /* Type: GNU_PROPERTY_X86_FEATURE_2_NEEDED */
100  .long 4                  /* Data size */
101  .long 0x0000001f         /* X86, ... */
102  .p2align 3               /* Align to 8 byte for 64 bit */
103
104  .long 0xc0010001         /* Type: GNU_PROPERTY_X86_FEATURE_2_USED */
105  .long 4                  /* Data size */
106  .long 0x000003e0         /* ZMM, ... */
107  .p2align 3               /* Align to 8 byte for 64 bit */
108
109  .long 0xc0008002         /* Type: GNU_PROPERTY_X86_ISA_1_NEEDED */
110  .long 4                  /* Data size */
111  .long 0x0000000f         /* x86-64-baseline, ... */
112  .p2align 3               /* Align to 8 byte for 64 bit */
113
114  .long 0xc0010002         /* Type: GNU_PROPERTY_X86_ISA_1_USED */
115  .long 4                  /* Data size */
116  .long 0x0000000f         /* x86-64-baseline, ... */
117  .p2align 3               /* Align to 8 byte for 64 bit */
118
119  /* All notes below are broken. Test we are able to report them. */
120
121  /* Broken note type */
122  .long 0xfefefefe  /* Invalid type for testing */
123  .long 0           /* Data size */
124  .p2align 3        /* Align to 8 byte for 64 bit */
125
126  /* GNU_PROPERTY_STACK_SIZE with zero stack size */
127  .long 1           /* Type: GNU_PROPERTY_STACK_SIZE */
128  .long 0           /* Data size */
129  .p2align 3        /* Align to 8 byte for 64 bit */
130
131  /* GNU_PROPERTY_STACK_SIZE with data size 4 (should be 8) */
132  .long 1           /* Type: GNU_PROPERTY_STACK_SIZE */
133  .long 4           /* Data size */
134  .long 0x100       /* Data (stack size) */
135  .p2align 3        /* Align to 8 byte for 64 bit */
136
137  /* GNU_PROPERTY_NO_COPY_ON_PROTECTED with pr_datasz and some data */
138  .long 2           /* Type: GNU_PROPERTY_NO_COPY_ON_PROTECTED */
139  .long 1           /* Data size (corrupted) */
140  .byte 1           /* Data */
141  .p2align 3        /* Align to 8 byte for 64 bit */
142
143  /* CET note with size zero */
144  .long 0xc0000002  /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
145  .long 0           /* Data size */
146  .p2align 3        /* Align to 8 byte for 64 bit */
147
148  /* CET note with bad flags */
149  .long 0xc0000002         /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
150  .long 4                  /* Data size */
151  .long 0xf000f001         /* GNU_PROPERTY_X86_FEATURE_1_IBT and bad bits */
152  .p2align 3               /* Align to 8 byte for 64 bit */
153
154  /* GNU_PROPERTY_NO_COPY_ON_PROTECTED with pr_datasz and without data */
155  .long 2           /* Type: GNU_PROPERTY_NO_COPY_ON_PROTECTED */
156  .long 1           /* Data size (corrupted) */
157  .p2align 3        /* Align to 8 byte for 64 bit */
158end:
159