Skip to content

Commit cbc512f

Browse files
committed
Addressed review comments on test files
1 parent d9ec4f9 commit cbc512f

8 files changed

+61
-245
lines changed

lld/test/ELF/Inputs/aarch64-func3-pac-replace.s

Lines changed: 0 additions & 10 deletions
This file was deleted.

lld/test/ELF/Inputs/aarch64-pac1-replace.s

Lines changed: 0 additions & 13 deletions
This file was deleted.

lld/test/ELF/aarch64-build-attributes-be.s

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
// RUN: ld.lld %t.o --shared -o %t.so
44
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
55

6-
/// The Build attributes section appearing in the output of
7-
/// llvm-mc should not appear in the output of lld, because
8-
/// AArch64 build attributes are being transformed into .gnu.properties.
9-
10-
/// Test mc -> big endian, lld -> little endian
116
// RUN: llvm-mc -triple=aarch64_be %s -filetype=obj -o %t.o
127
// RUN: ld.lld %t.o --shared -o %t.so
138
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
@@ -16,23 +11,7 @@
1611
// RUN: ld.lld -r %t.o -o %t2.o
1712
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
1813

19-
/// Test mc -> little endian, lld -> big endian
20-
// RUN: llvm-mc -triple=aarch64 %s -filetype=obj -o %t.o
21-
// RUN: ld.lld --EB %t.o --shared -o %t.so
22-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
23-
// RUN: ld.lld --EB %t.o -o %t
24-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
25-
// RUN: ld.lld --EB -r %t.o -o %t2.o
26-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
27-
28-
/// Test mc -> big endian, lld -> big endian
29-
// RUN: llvm-mc -triple=aarch64_be %s -filetype=obj -o %t.o
30-
// RUN: ld.lld --EB %t.o --shared -o %t.so
31-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
32-
// RUN: ld.lld --EB %t.o -o %t
33-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
34-
// RUN: ld.lld --EB -r %t.o -o %t2.o
35-
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE
14+
/// Test that lld can read big-endian build-attributes.
3615

3716
// NOTE: Displaying notes found in: .note.gnu.property
3817
// NOTE-NEXT: Owner Data size Description
@@ -42,8 +21,8 @@
4221

4322

4423
.aeabi_subsection aeabi_pauthabi, required, uleb128
45-
.aeabi_attribute Tag_PAuth_Platform, 81985529216486895
46-
.aeabi_attribute Tag_PAuth_Schema, 81985529216486895
24+
.aeabi_attribute Tag_PAuth_Platform, 0x123456789ABCDEF
25+
.aeabi_attribute Tag_PAuth_Schema, 0x123456789ABCDEF
4726
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
4827
.aeabi_attribute Tag_Feature_BTI, 1
4928
.aeabi_attribute Tag_Feature_PAC, 1

lld/test/ELF/aarch64-build-attributes-err.s

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
.aeabi_attribute Tag_Feature_GCS, 1
1616

1717
.section ".note.gnu.property", "a"
18-
.long 4
18+
.long 0x4
1919
.long 0x10
2020
.long 0x5
2121
.asciz "GNU"
2222
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
23-
.long 4
24-
.long 2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC
25-
.long 0
23+
.long 0x4
24+
.long 0x2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC
25+
.long 0x0
2626

2727
.section ".note.gnu.property", "a"
28-
.long 4
29-
.long 24
30-
.long 5
28+
.long 0x4
29+
.long 0x18
30+
.long 0x5
3131
.asciz "GNU"
3232
.long 0xc0000001
33-
.long 16
34-
.quad 305419896 // platform
35-
.quad 2271560481 // version
33+
.long 0x10
34+
.quad 0x12345678 // platform
35+
.quad 0x87654321 // version

lld/test/ELF/aarch64-build-attributes-malformed.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# REQUIRES: aarch64
2+
13
# RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t.o
24
# RUN: ld.lld %t.o /dev/null 2>&1 | FileCheck %s
35

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
// REQUIRES: aarch64
2+
13
// RUN: rm -rf %t && split-file %s %t && cd %t
24

35
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t11.o
4-
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-mixed-2.s -o %t12.o
5-
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-mixed-3.s -o %t13.o
6+
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-property.s -o %t12.o
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-property2.s -o %t13.o
68
// RUN: ld.lld -r %t11.o %t12.o %t13.o -o %t.merged1.o
79
// RUN: llvm-readelf -n %t.merged1.o | FileCheck %s --check-prefix=NOTE-MIXED
810

11+
/// This test verifies merging of AArch64 build attributes and GNU property notes.
12+
/// Three object files are combined: one with build attributes (PAuth information, BTI, PAC, GCS),
13+
/// and two with GNU property notes encoding the same feature bits.
14+
/// PAuth ABI info is provided in one of the files and it is expected to be preserved in the merged output.
15+
916
// NOTE-MIXED: Displaying notes found in: .note.gnu.property
1017
// NOTE-MIXED-NEXT: Owner Data size Description
1118
// NOTE-MIXED-NEXT: GNU 0x00000028 NT_GNU_PROPERTY_TYPE_0 (property note)
1219
// NOTE-MIXED-NEXT: Properties: aarch64 feature: BTI, PAC
1320
// NOTE-MIXED-NEXT: AArch64 PAuth ABI core info: platform 0x31 (unknown), version 0x13
1421

15-
/// The Build attributes section appearing in the output of
16-
/// llvm-mc should not appear in the output of lld, because
17-
/// AArch64 build attributes are being transformed into .gnu.properties.
18-
1922
// CHECK: .note.gnu.property
2023
// CHECK-NOT: .ARM.attributes
2124

@@ -28,35 +31,37 @@
2831
.aeabi_attribute Tag_Feature_GCS, 1
2932

3033

31-
//--- merged-mixed-2.s
34+
//--- merged-property.s
3235
.section ".note.gnu.property", "a"
33-
.long 4 // Name length is always 4 ("GNU")
34-
.long end - begin // Data length
35-
.long 5 // Type: NT_GNU_PROPERTY_TYPE_0
36-
.asciz "GNU" // Name
37-
.p2align 3
36+
.long 0x4 // Name length is always 4 ("GNU")
37+
.long end - begin // Data length
38+
.long 0x5 // Type: NT_GNU_PROPERTY_TYPE_0
39+
.asciz "GNU" // Name
40+
.p2align 0x3
3841
begin:
39-
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
40-
.long 4
41-
.long 7 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI, PAC and GCS
42-
.long 0
42+
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
43+
.long 0x4
44+
.long 0x7 // pr_data: BTI (1), PAC (2), GCS (4) = 0b111 = 7
45+
.long 0x0
4346
// PAuth ABI property note
44-
.long 0xc0000001 // Type: GNU_PROPERTY_AARCH64_FEATURE_PAUTH
45-
.long 16 // Data size
46-
.quad 49 // PAuth ABI platform
47-
.quad 19 // PAuth ABI version
48-
.p2align 3 // Align to 8 byte for 64 bit
47+
.long 0xc0000001 // GNU_PROPERTY_AARCH64_FEATURE_PAUTH
48+
.long 0x10 // Data length
49+
.quad 0x31 // PAuth ABI platform
50+
.quad 0x13 // PAuth ABI version
51+
.p2align 0x3 // Align to 8 byte for 64 bit
4952
end:
5053

51-
//--- merged-mixed-3.s
54+
//--- merged-property2.s
5255
.section .note.gnu.property, "a"
53-
.align 4
54-
.long 4 // namesz
55-
.long 0x10 // descsz
56-
.long 5 // type (NT_GNU_PROPERTY_TYPE_0)
57-
.asciz "GNU" // name (null-terminated)
58-
.align 4
59-
.long 0xc0000000 // pr_type (GNU_PROPERTY_AARCH64_FEATURE_1_AND)
60-
.long 4 // pr_datasz
61-
.long 7 // pr_data: BTI (1), PAC (2), GCS (4) = 0b111 = 7
62-
.long 0 // padding or next property
56+
.align 0x4
57+
.long 0x4 // Name length is always 4 ("GNU")
58+
.long end2 - begin2 // Data length
59+
.long 0x5 // Type: NT_GNU_PROPERTY_TYPE_0
60+
.asciz "GNU" // Name
61+
begin2:
62+
.align 0x4
63+
.long 0xc0000000 // Type: GNU_PROPERTY_AARCH64_FEATURE_1_AND
64+
.long 0x4 // Data length
65+
.long 0x7 // pr_data: BTI (1), PAC (2), GCS (4) = 0b111 = 7
66+
.long 0x0
67+
end2:

lld/test/ELF/aarch64-build-attributes.s

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
// RUN: rm -rf %t && split-file %s %t && cd %t
33

44
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t1.o
5-
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-2.s -o %t2.o
6-
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-3.s -o %t3.o
5+
// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-gcs.s -o %t2.o
6+
// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-pac.s -o %t3.o
77
// RUN: ld.lld -r %t1.o %t2.o %t3.o -o %t.merged.o
88
// RUN: llvm-readelf -n %t.merged.o | FileCheck %s --check-prefix=NOTE
99

10+
/// This test merges three object files with AArch64 build attributes.
11+
/// All contain identical PAuth ABI info (platform/version), which must be preserved.
12+
/// Only BTI is common across all three in the AND feature set, so the merged output
13+
/// must show BTI only. PAC and GCS are present in subsets and should not appear.
14+
1015
// NOTE: Displaying notes found in: .note.gnu.property
1116
// NOTE-NEXT: Owner Data size Description
1217
// NOTE-NEXT: GNU 0x00000028 NT_GNU_PROPERTY_TYPE_0 (property note)
1318
// NOTE-NEXT: Properties: aarch64 feature: BTI
1419
// NOTE-NEXT: AArch64 PAuth ABI core info: platform 0x31 (unknown), version 0x13
1520

16-
/// The Build attributes section appearing in the output of
17-
/// llvm-mc should not appear in the output of lld, because
18-
/// AArch64 build attributes are being transformed into .gnu.properties.
19-
2021
// CHECK: .note.gnu.property
2122
// CHECK-NOT: .ARM.attributes
2223

@@ -29,7 +30,7 @@
2930
.aeabi_attribute Tag_Feature_GCS, 1
3031

3132

32-
//--- merged-2.s
33+
//--- pauth-bti-gcs.s
3334
.aeabi_subsection aeabi_pauthabi, required, uleb128
3435
.aeabi_attribute Tag_PAuth_Platform, 49
3536
.aeabi_attribute Tag_PAuth_Schema, 19
@@ -39,7 +40,7 @@
3940
.aeabi_attribute Tag_Feature_GCS, 1
4041

4142

42-
//--- merged-3.s
43+
//--- pauth-bti-pac.s
4344
.aeabi_subsection aeabi_pauthabi, required, uleb128
4445
.aeabi_attribute Tag_PAuth_Platform, 49
4546
.aeabi_attribute Tag_PAuth_Schema, 19

0 commit comments

Comments
 (0)