1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
# REQUIRES: riscv
# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=riscv64 a.s -o a.o
# RUN: ld.lld -e 0 a.o -o out 2>&1 | count 0
# RUN: llvm-readelf -S -l --arch-specific out | FileCheck %s --check-prefixes=HDR,CHECK
# RUN: ld.lld -e 0 a.o a.o -o out1 2>&1 | count 0
# RUN: llvm-readobj --arch-specific out1 | FileCheck %s
# RUN: ld.lld -r a.o a.o -o out1 2>&1 | count 0
# RUN: llvm-readobj --arch-specific out1 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 b.s -o b.o
# RUN: llvm-mc -filetype=obj -triple=riscv64 c.s -o c.o
# RUN: ld.lld a.o b.o c.o -o out2
# RUN: llvm-readobj --arch-specific out2 | FileCheck %s --check-prefix=CHECK2
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_ext1.s -o unrecognized_ext1.o
# RUN: ld.lld -e 0 unrecognized_ext1.o -o unrecognized_ext1 2>&1 | count 0
# RUN: llvm-readobj --arch-specific unrecognized_ext1 | FileCheck %s --check-prefix=UNRECOGNIZED_EXT1
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_ext2.s -o unrecognized_ext2.o
# RUN: ld.lld -e 0 unrecognized_ext2.o -o unrecognized_ext2 2>&1 | count 0
# RUN: llvm-readobj --arch-specific unrecognized_ext2 | FileCheck %s --check-prefix=UNRECOGNIZED_EXT2
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_version.s -o unrecognized_version.o
# RUN: ld.lld -e 0 unrecognized_version.o -o unrecognized_version 2>&1 | count 0
# RUN: llvm-readobj --arch-specific unrecognized_version | FileCheck %s --check-prefix=UNRECOGNIZED_VERSION
# RUN: llvm-mc -filetype=obj -triple=riscv64 merge_version_test_input.s -o merge_version_test_input.o
# RUN: ld.lld -e 0 unrecognized_version.o merge_version_test_input.o -o out3 2>&1 | count 0
# RUN: llvm-readobj --arch-specific out3 | FileCheck %s --check-prefix=CHECK3
# RUN: llvm-mc -filetype=obj -triple=riscv64 invalid_arch1.s -o invalid_arch1.o
# RUN: not ld.lld invalid_arch1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=INVALID_ARCH1 --implicit-check-not=error:
# INVALID_ARCH1: error: invalid_arch1.o:(.riscv.attributes): rv64i2: extension lacks version in expected format
## A zero value attribute is not printed.
# RUN: llvm-mc -filetype=obj -triple=riscv64 unaligned_access_0.s -o unaligned_access_0.o
# RUN: ld.lld -e 0 --fatal-warnings a.o unaligned_access_0.o -o unaligned_access_0
# RUN: llvm-readobj -A unaligned_access_0 | FileCheck /dev/null --implicit-check-not='TagName: unaligned_access'
## Differing stack_align values lead to an error.
# RUN: llvm-mc -filetype=obj -triple=riscv64 diff_stack_align.s -o diff_stack_align.o
# RUN: not ld.lld a.o b.o c.o diff_stack_align.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=STACK_ALIGN --implicit-check-not=error:
# STACK_ALIGN: error: diff_stack_align.o:(.riscv.attributes) has stack_align=32 but a.o:(.riscv.attributes) has stack_align=16
## The deprecated priv_spec is not handled as GNU ld does.
## Differing priv_spec attributes lead to an absent attribute.
# RUN: llvm-mc -filetype=obj -triple=riscv64 diff_priv_spec.s -o diff_priv_spec.o
# RUN: ld.lld -e 0 --fatal-warnings a.o b.o c.o diff_priv_spec.o -o diff_priv_spec
# RUN: llvm-readobj -A diff_priv_spec | FileCheck /dev/null --implicit-check-not='TagName: priv_spec'
## Unknown tags currently lead to warnings.
# RUN: llvm-mc -filetype=obj -triple=riscv64 unknown13.s -o unknown13.o
# RUN: llvm-mc -filetype=obj -triple=riscv64 unknown13a.s -o unknown13a.o
# RUN: ld.lld -e 0 unknown13.o unknown13.o unknown13a.o -o unknown13 2>&1 | FileCheck %s --check-prefix=UNKNOWN13 --implicit-check-not=warning:
# UNKNOWN13-COUNT-2: warning: unknown13.o:(.riscv.attributes): invalid tag 0xd at offset 0x10
# UNKNOWN13: warning: unknown13a.o:(.riscv.attributes): invalid tag 0xd at offset 0x10
# RUN: llvm-mc -filetype=obj -triple=riscv64 unknown22.s -o unknown22.o
# RUN: llvm-mc -filetype=obj -triple=riscv64 unknown22a.s -o unknown22a.o
# RUN: ld.lld -e 0 unknown22.o unknown22.o unknown22a.o -o unknown22 2>&1 | FileCheck %s --check-prefix=UNKNOWN22 --implicit-check-not=warning:
# UNKNOWN22-COUNT-2: warning: unknown22.o:(.riscv.attributes): invalid tag 0x16 at offset 0x10
# UNKNOWN22: warning: unknown22a.o:(.riscv.attributes): invalid tag 0x16 at offset 0x10
# HDR: Name Type Address Off Size ES Flg Lk Inf Al
# HDR: .riscv.attributes RISCV_ATTRIBUTES 0000000000000000 000158 00003e 00 0 0 1{{$}}
# HDR: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
# HDR: LOAD 0x000000 0x0000000000010000 0x0000000000010000 0x000158 0x000158 R 0x1000
# HDR-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0
# HDR-NEXT: ATTRIBUTES 0x000158 0x0000000000000000 0x0000000000000000 0x00003e 0x00003e R 0x1{{$}}
# CHECK: BuildAttributes {
# CHECK-NEXT: FormatVersion: 0x41
# CHECK-NEXT: Section 1 {
# CHECK-NEXT: SectionLength: 61
# CHECK-NEXT: Vendor: riscv
# CHECK-NEXT: Tag: Tag_File (0x1)
# CHECK-NEXT: Size: 51
# CHECK-NEXT: FileAttributes {
# CHECK-NEXT: Attribute {
# CHECK-NEXT: Tag: 4
# CHECK-NEXT: Value: 16
# CHECK-NEXT: TagName: stack_align
# CHECK-NEXT: Description: Stack alignment is 16-bytes
# CHECK-NEXT: }
# CHECK-NEXT: Attribute {
# CHECK-NEXT: Tag: 5
# CHECK-NEXT: TagName: arch
# CHECK-NEXT: Value: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0{{$}}
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK2: BuildAttributes {
# CHECK2-NEXT: FormatVersion: 0x41
# CHECK2-NEXT: Section 1 {
# CHECK2-NEXT: SectionLength: 104
# CHECK2-NEXT: Vendor: riscv
# CHECK2-NEXT: Tag: Tag_File (0x1)
# CHECK2-NEXT: Size: 94
# CHECK2-NEXT: FileAttributes {
# CHECK2-NEXT: Attribute {
# CHECK2-NEXT: Tag: 4
# CHECK2-NEXT: Value: 16
# CHECK2-NEXT: TagName: stack_align
# CHECK2-NEXT: Description: Stack alignment is 16-bytes
# CHECK2-NEXT: }
# CHECK2-NEXT: Attribute {
# CHECK2-NEXT: Tag: 6
# CHECK2-NEXT: Value: 1
# CHECK2-NEXT: TagName: unaligned_access
# CHECK2-NEXT: Description: Unaligned access
# CHECK2-NEXT: }
# CHECK2-NEXT: Attribute {
# CHECK2-NEXT: Tag: 8
# CHECK2-NEXT: TagName: priv_spec
# CHECK2-NEXT: Value: 2
# CHECK2-NEXT: }
# CHECK2-NEXT: Attribute {
# CHECK2-NEXT: Tag: 10
# CHECK2-NEXT: TagName: priv_spec_minor
# CHECK2-NEXT: Value: 2
# CHECK2-NEXT: }
# CHECK2-NEXT: Attribute {
# CHECK2-NEXT: Tag: 5
# CHECK2-NEXT: TagName: arch
# CHECK2-NEXT: Value: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0{{$}}
# CHECK2-NEXT: }
# CHECK2-NEXT: }
# CHECK2-NEXT: }
# CHECK2-NEXT: }
# CHECK3: BuildAttributes {
# CHECK3-NEXT: FormatVersion: 0x41
# CHECK3-NEXT: Section 1 {
# CHECK3-NEXT: SectionLength: 26
# CHECK3-NEXT: Vendor: riscv
# CHECK3-NEXT: Tag: Tag_File (0x1)
# CHECK3-NEXT: Size: 16
# CHECK3-NEXT: FileAttributes {
# CHECK3-NEXT: Attribute {
# CHECK3-NEXT: Tag: 5
# CHECK3-NEXT: TagName: arch
# CHECK3-NEXT: Value: rv64i99p0{{$}}
# CHECK3-NEXT: }
# CHECK3-NEXT: }
# CHECK3-NEXT: }
# CHECK3-NEXT: }
#--- a.s
.attribute stack_align, 16
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0"
.attribute unaligned_access, 0
#--- b.s
.attribute stack_align, 16
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0"
.attribute priv_spec, 2
.attribute priv_spec_minor, 2
#--- c.s
.attribute stack_align, 16
.attribute arch, "rv64i2p1_f2p2_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
.attribute unaligned_access, 1
.attribute priv_spec, 2
.attribute priv_spec_minor, 2
#--- unrecognized_ext1.s
# UNRECOGNIZED_EXT1: BuildAttributes {
# UNRECOGNIZED_EXT1-NEXT: FormatVersion: 0x41
# UNRECOGNIZED_EXT1-NEXT: Section 1 {
# UNRECOGNIZED_EXT1-NEXT: SectionLength: 30
# UNRECOGNIZED_EXT1-NEXT: Vendor: riscv
# UNRECOGNIZED_EXT1-NEXT: Tag: Tag_File (0x1)
# UNRECOGNIZED_EXT1-NEXT: Size: 20
# UNRECOGNIZED_EXT1-NEXT: FileAttributes {
# UNRECOGNIZED_EXT1-NEXT: Attribute {
# UNRECOGNIZED_EXT1-NEXT: Tag: 5
# UNRECOGNIZED_EXT1-NEXT: TagName: arch
# UNRECOGNIZED_EXT1-NEXT: Value: rv64i2p1_y2p0{{$}}
# UNRECOGNIZED_EXT1-NEXT: }
# UNRECOGNIZED_EXT1-NEXT: }
# UNRECOGNIZED_EXT1-NEXT: }
# UNRECOGNIZED_EXT1-NEXT: }
.section .riscv.attributes,"",@0x70000003
.byte 0x41
.long .Lend-.riscv.attributes-1
.asciz "riscv" # vendor
.Lbegin:
.byte 1 # Tag_File
.long .Lend-.Lbegin
.byte 5 # Tag_RISCV_arch
.asciz "rv64i2p1_y2p0"
.Lend:
#--- unrecognized_ext2.s
# UNRECOGNIZED_EXT2: BuildAttributes {
# UNRECOGNIZED_EXT2-NEXT: FormatVersion: 0x41
# UNRECOGNIZED_EXT2-NEXT: Section 1 {
# UNRECOGNIZED_EXT2-NEXT: SectionLength: 36
# UNRECOGNIZED_EXT2-NEXT: Vendor: riscv
# UNRECOGNIZED_EXT2-NEXT: Tag: Tag_File (0x1)
# UNRECOGNIZED_EXT2-NEXT: Size: 26
# UNRECOGNIZED_EXT2-NEXT: FileAttributes {
# UNRECOGNIZED_EXT2-NEXT: Attribute {
# UNRECOGNIZED_EXT2-NEXT: Tag: 5
# UNRECOGNIZED_EXT2-NEXT: TagName: arch
# UNRECOGNIZED_EXT2-NEXT: Value: rv64i2p1_zmadeup1p0{{$}}
# UNRECOGNIZED_EXT2-NEXT: }
# UNRECOGNIZED_EXT2-NEXT: }
# UNRECOGNIZED_EXT2-NEXT: }
# UNRECOGNIZED_EXT2-NEXT: }
.section .riscv.attributes,"",@0x70000003
.byte 0x41
.long .Lend-.riscv.attributes-1
.asciz "riscv" # vendor
.Lbegin:
.byte 1 # Tag_File
.long .Lend-.Lbegin
.byte 5 # Tag_RISCV_arch
.asciz "rv64i2p1_zmadeup1p0"
.Lend:
#--- unrecognized_version.s
# UNRECOGNIZED_VERSION: BuildAttributes {
# UNRECOGNIZED_VERSION-NEXT: FormatVersion: 0x41
# UNRECOGNIZED_VERSION-NEXT: Section 1 {
# UNRECOGNIZED_VERSION-NEXT: SectionLength: 26
# UNRECOGNIZED_VERSION-NEXT: Vendor: riscv
# UNRECOGNIZED_VERSION-NEXT: Tag: Tag_File (0x1)
# UNRECOGNIZED_VERSION-NEXT: Size: 16
# UNRECOGNIZED_VERSION-NEXT: FileAttributes {
# UNRECOGNIZED_VERSION-NEXT: Attribute {
# UNRECOGNIZED_VERSION-NEXT: Tag: 5
# UNRECOGNIZED_VERSION-NEXT: TagName: arch
# UNRECOGNIZED_VERSION-NEXT: Value: rv64i99p0
# UNRECOGNIZED_VERSION-NEXT: }
# UNRECOGNIZED_VERSION-NEXT: }
# UNRECOGNIZED_VERSION-NEXT: }
# UNRECOGNIZED_VERSION-NEXT: }
.section .riscv.attributes,"",@0x70000003
.byte 0x41
.long .Lend-.riscv.attributes-1
.asciz "riscv" # vendor
.Lbegin:
.byte 1 # Tag_File
.long .Lend-.Lbegin
.byte 5 # Tag_RISCV_arch
.asciz "rv64i99p0"
.Lend:
#--- merge_version_test_input.s
.section .riscv.attributes,"",@0x70000003
.byte 0x41
.long .Lend-.riscv.attributes-1
.asciz "riscv" # vendor
.Lbegin:
.byte 1 # Tag_File
.long .Lend-.Lbegin
.byte 5 # Tag_RISCV_arch
.asciz "rv64i2p1"
.Lend:
#--- invalid_arch1.s
.section .riscv.attributes,"",@0x70000003
.byte 0x41
.long .Lend-.riscv.attributes-1
.asciz "riscv" # vendor
.Lbegin:
.byte 1 # Tag_File
.long .Lend-.Lbegin
.byte 5 # Tag_RISCV_arch
.asciz "rv64i2"
.Lend:
#--- unaligned_access_0.s
.attribute unaligned_access, 0
#--- diff_stack_align.s
.attribute stack_align, 32
#--- diff_priv_spec.s
.attribute priv_spec, 3
.attribute priv_spec_minor, 3
#--- unknown13.s
.attribute 13, "0"
#--- unknown13a.s
.attribute 13, "1"
#--- unknown22.s
.attribute 22, 1
#--- unknown22a.s
.attribute 22, 2
|