-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lld][AArch64][Build Attributes] Add support for AArch64 Build Attributes #144082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sivan-shani
wants to merge
2
commits into
llvm:main
Choose a base branch
from
sivan-shani:BAlld_RefMerged
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// REQUIRES: aarch64 | ||
// RUN: llvm-mc -triple=aarch64_be %s -filetype=obj -o %t.o | ||
// RUN: ld.lld %t.o --shared -o %t.so | ||
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE | ||
|
||
// RUN: llvm-mc -triple=aarch64_be %s -filetype=obj -o %t.o | ||
// RUN: ld.lld %t.o --shared -o %t.so | ||
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE | ||
// RUN: ld.lld %t.o -o %t | ||
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE | ||
// RUN: ld.lld -r %t.o -o %t2.o | ||
// RUN: llvm-readelf -n %t.so | FileCheck %s --check-prefix=NOTE | ||
|
||
/// Test that lld can read big-endian build-attributes. | ||
|
||
// NOTE: Displaying notes found in: .note.gnu.property | ||
// NOTE-NEXT: Owner Data size Description | ||
// NOTE-NEXT: GNU 0x00000028 NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// NOTE-NEXT: Properties: aarch64 feature: BTI, PAC, GCS | ||
// NOTE-NEXT: AArch64 PAuth ABI core info: platform 0x89abcdef (unknown), version 0x89abcdef | ||
|
||
|
||
.aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
.aeabi_attribute Tag_PAuth_Platform, 0x123456789ABCDEF | ||
.aeabi_attribute Tag_PAuth_Schema, 0x123456789ABCDEF | ||
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 | ||
.aeabi_attribute Tag_Feature_BTI, 1 | ||
.aeabi_attribute Tag_Feature_PAC, 1 | ||
.aeabi_attribute Tag_Feature_GCS, 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: aarch64 | ||
|
||
// RUN: llvm-mc -triple=aarch64 %s -filetype=obj -o %t.o | ||
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR | ||
|
||
// ERR: Pauth Data mismatch: file contains both GNU properties and AArch64 build attributes sections with different Pauth data | ||
// ERR-NEXT: Features Data mismatch: file contains both GNU properties and AArch64 build attributes sections with different And Features data | ||
|
||
.aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
.aeabi_attribute Tag_PAuth_Platform, 5 | ||
.aeabi_attribute Tag_PAuth_Schema, 5 | ||
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 | ||
.aeabi_attribute Tag_Feature_BTI, 1 | ||
.aeabi_attribute Tag_Feature_PAC, 1 | ||
.aeabi_attribute Tag_Feature_GCS, 1 | ||
|
||
.section ".note.gnu.property", "a" | ||
.long 0x4 | ||
.long 0x10 | ||
.long 0x5 | ||
.asciz "GNU" | ||
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND | ||
.long 0x4 | ||
.long 0x2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC | ||
.long 0x0 | ||
|
||
.section ".note.gnu.property", "a" | ||
.long 0x4 | ||
.long 0x18 | ||
.long 0x5 | ||
.asciz "GNU" | ||
.long 0xc0000001 | ||
.long 0x10 | ||
.quad 0x12345678 // platform | ||
.quad 0x87654321 // version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// REQUIRES: aarch64 | ||
|
||
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t.o | ||
// RUN: ld.lld -r %t.o -o %t.invalid.o | ||
// RUN: llvm-readelf -n %t.invalid.o | FileCheck %s | ||
|
||
/// According to the BuildAttributes specification Build Attributes | ||
/// A (TagPlatform, TagSchema)of (0, 1) maps to an explicit PAuth property | ||
/// of platform = 0, version = 0 ('Invalid'). | ||
|
||
// CHECK: Displaying notes found in: .note.gnu.property | ||
// CHECK-NEXT: Owner Data size Description | ||
// CHECK-NEXT: GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// CHECK-NEXT: Properties: AArch64 PAuth ABI core info: platform 0x0 (invalid), version 0x0 | ||
|
||
.aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
.aeabi_attribute Tag_PAuth_Platform, 0 | ||
.aeabi_attribute Tag_PAuth_Schema, 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# REQUIRES: aarch64 | ||
|
||
# RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t.o | ||
smithp35 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# RUN: ld.lld %t.o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: (.ARM.attributes): unexpected end of data at offset 0x3f while reading [0x3d, 0x41) | ||
|
||
.section .ARM.attributes,"",%0x70000003 | ||
.byte 0x41 // Tag 'A' (format version) | ||
.long 0x00000019 // Subsection length | ||
.asciz "aeabi_pauthabi" // Subsection name | ||
.byte 0x00, 0x00 // Optionality and Type | ||
.byte 0x01, 0x01, 0x02, 0x01 // PAuth_Platform and PAuth_Schema | ||
.long 0x00000023 // Subsection length | ||
.asciz "aeabi_feature_and_bits" // Subsection name | ||
.byte 0x01, 0x00 // Optionality and Type | ||
.byte 0x00, 0x01, 0x01, 0x01, 0x02, 0x01 // BTI, PAC, GCS | ||
.byte 0x00, 0x00 // This is the malformation, data is too long. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// REQUIRES: aarch64 | ||
|
||
// RUN: rm -rf %t && split-file %s %t && cd %t | ||
smithp35 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t11.o | ||
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-property.s -o %t12.o | ||
// RUN: llvm-mc -triple=aarch64 -filetype=obj merged-property2.s -o %t13.o | ||
// RUN: ld.lld -r %t11.o %t12.o %t13.o -o %t.merged1.o | ||
// RUN: llvm-readelf -n %t.merged1.o | FileCheck %s --check-prefix=NOTE-MIXED | ||
|
||
smithp35 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// This test verifies merging of AArch64 build attributes and GNU property notes. | ||
/// Three object files are combined: one with build attributes (PAuth information, BTI, PAC, GCS), | ||
/// and two with GNU property notes encoding the same feature bits. | ||
/// PAuth ABI info is provided in one of the files and it is expected to be preserved in the merged output. | ||
|
||
// NOTE-MIXED: Displaying notes found in: .note.gnu.property | ||
// NOTE-MIXED-NEXT: Owner Data size Description | ||
// NOTE-MIXED-NEXT: GNU 0x00000028 NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// NOTE-MIXED-NEXT: Properties: aarch64 feature: BTI, PAC | ||
// NOTE-MIXED-NEXT: AArch64 PAuth ABI core info: platform 0x31 (unknown), version 0x13 | ||
|
||
// CHECK: .note.gnu.property | ||
// CHECK-NOT: .ARM.attributes | ||
|
||
.aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
.aeabi_attribute Tag_PAuth_Platform, 49 | ||
.aeabi_attribute Tag_PAuth_Schema, 19 | ||
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 | ||
.aeabi_attribute Tag_Feature_BTI, 1 | ||
.aeabi_attribute Tag_Feature_PAC, 1 | ||
.aeabi_attribute Tag_Feature_GCS, 1 | ||
|
||
|
||
//--- merged-property.s | ||
.section ".note.gnu.property", "a" | ||
.long 0x4 // Name length is always 4 ("GNU") | ||
.long end - begin // Data length | ||
.long 0x5 // Type: NT_GNU_PROPERTY_TYPE_0 | ||
.asciz "GNU" // Name | ||
.p2align 0x3 | ||
begin: | ||
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND | ||
.long 0x4 | ||
.long 0x7 // pr_data: BTI (1), PAC (2), GCS (4) = 0b111 = 7 | ||
.long 0x0 | ||
// PAuth ABI property note | ||
.long 0xc0000001 // GNU_PROPERTY_AARCH64_FEATURE_PAUTH | ||
.long 0x10 // Data length | ||
.quad 0x31 // PAuth ABI platform | ||
.quad 0x13 // PAuth ABI version | ||
.p2align 0x3 // Align to 8 byte for 64 bit | ||
end: | ||
|
||
//--- merged-property2.s | ||
.section .note.gnu.property, "a" | ||
.align 0x4 | ||
.long 0x4 // Name length is always 4 ("GNU") | ||
.long end2 - begin2 // Data length | ||
.long 0x5 // Type: NT_GNU_PROPERTY_TYPE_0 | ||
.asciz "GNU" // Name | ||
begin2: | ||
.align 0x4 | ||
.long 0xc0000000 // Type: GNU_PROPERTY_AARCH64_FEATURE_1_AND | ||
.long 0x4 // Data length | ||
.long 0x7 // pr_data: BTI (1), PAC (2), GCS (4) = 0b111 = 7 | ||
.long 0x0 | ||
end2: |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.