-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[LLVM][AArch64] Build attributes: Support switching to a defined subsection by name only #154159
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,17 +153,24 @@ MCTargetStreamer *llvm::createAArch64NullTargetStreamer(MCStreamer &S) { | |
| return new AArch64TargetStreamer(S); | ||
| } | ||
|
|
||
| bool AArch64TargetStreamer::hasSubsection(StringRef SubSectionName) { | ||
|
||
| for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { | ||
| if (SubSection.VendorName == SubSectionName) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void AArch64TargetStreamer::emitAttributesSubsection( | ||
| StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional, | ||
| AArch64BuildAttributes::SubsectionType ParameterType) { | ||
|
|
||
| // If exists, return. | ||
| for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { | ||
| if (VendorName == SubSection.VendorName) { | ||
| activateAttributesSubsection(VendorName); | ||
| return; | ||
| } | ||
| // If exists, activate and return. | ||
| if (hasSubsection(VendorName)) { | ||
| activateAttributesSubsection(VendorName); | ||
| return; | ||
| } | ||
|
|
||
| // else, add the subsection | ||
| MCELFStreamer::AttributeSubSection AttSubSection; | ||
| AttSubSection.VendorName = VendorName; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM | ||
| // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF | ||
|
|
||
| // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
| // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 | ||
| // ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI | ||
| // ASM: .aeabi_attribute 2, 1 // Tag_PAuth_Schema | ||
| // ASM: .aeabi_attribute 1, 1 // Tag_PAuth_Platform | ||
| // ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS | ||
| // ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC | ||
| // ASM: .aeabi_attribute 7, 1 | ||
| // ASM: .aeabi_attribute 7, 0 | ||
|
|
||
| // ELF: Hex dump of section '.ARM.attributes': | ||
| // ELF-NEXT: 0x00000000 411b0000 00616561 62695f70 61757468 A....aeabi_pauth | ||
| // ELF-NEXT: 0x00000010 61626900 00000201 01010700 25000000 abi.........%... | ||
| // ELF-NEXT: 0x00000020 61656162 695f6665 61747572 655f616e aeabi_feature_an | ||
| // ELF-NEXT: 0x00000030 645f6269 74730001 00000102 01010007 d_bits.......... | ||
| // ELF-NEXT: 0x00000040 01 | ||
|
|
||
|
|
||
| .aeabi_subsection aeabi_pauthabi, required, uleb128 | ||
| .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 | ||
| .aeabi_attribute Tag_Feature_BTI, 1 | ||
| .aeabi_subsection aeabi_feature_and_bits | ||
| .aeabi_subsection aeabi_pauthabi | ||
| .aeabi_attribute Tag_PAuth_Schema, 1 | ||
| .aeabi_subsection aeabi_pauthabi | ||
| .aeabi_attribute Tag_PAuth_Platform, 1 | ||
| .aeabi_subsection aeabi_pauthabi | ||
| .aeabi_subsection aeabi_feature_and_bits | ||
| .aeabi_attribute Tag_Feature_GCS, 1 | ||
| .aeabi_subsection aeabi_pauthabi | ||
| .aeabi_subsection aeabi_feature_and_bits | ||
| .aeabi_attribute Tag_Feature_PAC, 0 | ||
| .aeabi_subsection aeabi_feature_and_bits | ||
| .aeabi_attribute 7, 1 | ||
| .aeabi_subsection aeabi_pauthabi | ||
| .aeabi_attribute 7, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can simplify the change by moving the call to SubsectionExists here. This can supply the parameters for
emitAttributesSubsectionso you wouldn't need to change anything in theAArch64TargetStreamer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, comment addressed.