Skip to content

Commit 179a24c

Browse files
committed
[lld][test][RISCV] Don't use incorrectly normalised arch string in riscv-attributes-place.s
Per the psABI, the arch string should be normalised to (amongest other things) always include the full version of each extension in form zfoo1p0. riscv-attributes-place.s didn't conform to this, which is not a problem for the current parsing logic, but this behaviour would change with a patch I'm about to propose. This makes riscv-sttributes-place.s feature a valid arch string, and maintains test coverage for this particular form of invalid arch string by adding it to riscv-attributes.s.
1 parent fd4d298 commit 179a24c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lld/test/ELF/riscv-attributes-place.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.byte 1 # Tag_File
2323
.long .Lend-.Lbegin
2424
.byte 5 # Tag_RISCV_arch
25-
.asciz "rv64i2"
25+
.asciz "rv64i2p0"
2626
.Lend:
2727

2828
.section .riscv.b,""

lld/test/ELF/riscv-attributes.s

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
# RUN: not ld.lld unrecognized_version.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNRECOGNIZED_VERSION --implicit-check-not=error:
2727
# UNRECOGNIZED_VERSION: error: unrecognized_version.o:(.riscv.attributes): rv64i99p0: unsupported version number 99.0 for extension 'i'
2828

29+
# RUN: llvm-mc -filetype=obj -triple=riscv64 invalid_arch1.s -o invalid_arch1.o
30+
# RUN: ld.lld -e 0 invalid_arch1.o -o invalid_arch1
31+
# RUN: llvm-readobj --arch-specific invalid_arch1 | FileCheck %s --check-prefix=INVALID_ARCH1
32+
2933
## A zero value attribute is not printed.
3034
# RUN: llvm-mc -filetype=obj -triple=riscv64 unaligned_access_0.s -o unaligned_access_0.o
3135
# RUN: ld.lld -e 0 --fatal-warnings a.o unaligned_access_0.o -o unaligned_access_0
@@ -171,6 +175,34 @@
171175
.asciz "rv64i99p0"
172176
.Lend:
173177

178+
#--- invalid_arch1.s
179+
# INVALID_ARCH1: BuildAttributes {
180+
# INVALID_ARCH1-NEXT: FormatVersion: 0x41
181+
# INVALID_ARCH1-NEXT: Section 1 {
182+
# INVALID_ARCH1-NEXT: SectionLength: 25
183+
# INVALID_ARCH1-NEXT: Vendor: riscv
184+
# INVALID_ARCH1-NEXT: Tag: Tag_File (0x1)
185+
# INVALID_ARCH1-NEXT: Size: 15
186+
# INVALID_ARCH1-NEXT: FileAttributes {
187+
# INVALID_ARCH1-NEXT: Attribute {
188+
# INVALID_ARCH1-NEXT: Tag: 5
189+
# INVALID_ARCH1-NEXT: TagName: arch
190+
# INVALID_ARCH1-NEXT: Value: rv64i2p0
191+
# INVALID_ARCH1-NEXT: }
192+
# INVALID_ARCH1-NEXT: }
193+
# INVALID_ARCH1-NEXT: }
194+
# INVALID_ARCH1-NEXT: }
195+
.section .riscv.attributes,"",@0x70000003
196+
.byte 0x41
197+
.long .Lend-.riscv.attributes-1
198+
.asciz "riscv" # vendor
199+
.Lbegin:
200+
.byte 1 # Tag_File
201+
.long .Lend-.Lbegin
202+
.byte 5 # Tag_RISCV_arch
203+
.asciz "rv64i2"
204+
.Lend:
205+
174206
#--- unaligned_access_0.s
175207
.attribute unaligned_access, 0
176208

0 commit comments

Comments
 (0)