diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index f1f25b65fc53f..c7de0a6d2ca51 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -482,10 +482,10 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags, AArch64BuildAttrs::SubsectionType::ULEB128); TS->emitAttribute( AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI), - AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false); + AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, ""); TS->emitAttribute( AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI), - AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false); + AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, ""); } unsigned BTIValue = (Flags & AArch64BuildAttrs::Feature_BTI_Flag) ? 1 : 0; @@ -499,13 +499,13 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags, AArch64BuildAttrs::SubsectionType::ULEB128); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, ""); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, ""); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, ""); } } diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 335b46b76688f..e46e7b38010a4 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7870,8 +7870,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { IsOptional = AArch64BuildAttrs::getOptionalID(Optionality); if (AArch64BuildAttrs::OPTIONAL_NOT_FOUND == IsOptional) { Error(Parser.getTok().getLoc(), - AArch64BuildAttrs::getSubsectionOptionalUnknownError() + ": " + - Optionality); + AArch64BuildAttrs::getSubsectionOptionalUnknownError()); return true; } if (SubsectionExists) { @@ -7919,7 +7918,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { Type = AArch64BuildAttrs::getTypeID(Name); if (AArch64BuildAttrs::TYPE_NOT_FOUND == Type) { Error(Parser.getTok().getLoc(), - AArch64BuildAttrs::getSubsectionTypeUnknownError() + ": " + Name); + AArch64BuildAttrs::getSubsectionTypeUnknownError()); return true; } if (SubsectionExists) { @@ -7948,6 +7947,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { } } Parser.Lex(); + // Parsing finished, check for trailing tokens. if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build " @@ -7986,14 +7986,18 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { StringRef TagStr = ""; unsigned Tag; - if (Parser.getTok().is(AsmToken::Identifier)) { + if (Parser.getTok().is(AsmToken::Integer)) { + Tag = getTok().getIntVal(); + } else if (Parser.getTok().is(AsmToken::Identifier)) { TagStr = Parser.getTok().getIdentifier(); switch (ActiveSubsectionID) { - default: - assert(0 && "Subsection name error"); - break; case AArch64BuildAttrs::VENDOR_UNKNOWN: - // Private subsection, accept any tag. + // Tag was provided as an unrecognized string instead of an unsigned + // integer + Error(Parser.getTok().getLoc(), "unrecognized Tag: '" + TagStr + + "' \nExcept for public subsections, " + "tags have to be an unsigned int."); + return true; break; case AArch64BuildAttrs::AEABI_PAUTHABI: Tag = AArch64BuildAttrs::getPauthABITagsID(TagStr); @@ -8014,8 +8018,6 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } break; } - } else if (Parser.getTok().is(AsmToken::Integer)) { - Tag = getTok().getIntVal(); } else { Error(Parser.getTok().getLoc(), "AArch64 build attributes tag not found"); return true; @@ -8059,10 +8061,9 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { Error(Parser.getTok().getLoc(), "AArch64 build attributes value not found"); return true; } - // Check for possible unaccepted values for known tags (AEABI_PAUTHABI, - // AEABI_FEATURE_AND_BITS) - if (!(ActiveSubsectionID == AArch64BuildAttrs::VENDOR_UNKNOWN) && - TagStr != "") { // TagStr was a recognized string + // Check for possible unaccepted values for known tags + // (AEABI_FEATURE_AND_BITS) + if (ActiveSubsectionID == AArch64BuildAttrs::AEABI_FEATURE_AND_BITS) { if (0 != ValueInt && 1 != ValueInt) { Error(Parser.getTok().getLoc(), "unknown AArch64 build attributes Value for Tag '" + TagStr + @@ -8071,7 +8072,8 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } } Parser.Lex(); - // Parsing finished, check for trailing tokens. + + // Parsing finished. Check for trailing tokens. if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build attributes tag and value " @@ -8080,13 +8082,11 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } if (unsigned(-1) != ValueInt) { - getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, "", - false); + getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, ""); } - if ("" != ValueStr) { getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, unsigned(-1), - ValueStr, false); + ValueStr); } return false; } diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 6b5c5f36cbd4b..4ed2424d77b90 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -151,7 +151,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { } void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override) override { + std::string String) override { // AArch64 build attributes for assembly attribute form: // .aeabi_attribute tag, value @@ -163,19 +163,15 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { unsigned VendorID = AArch64BuildAttrs::getVendorID(VendorName); switch (VendorID) { - default: - assert(0 && "Subsection name error"); - break; case AArch64BuildAttrs::VENDOR_UNKNOWN: if (unsigned(-1) != Value) { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); } if ("" != String) { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << String; AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), - String, Override); + String); } break; // Note: AEABI_FEATURE_AND_BITS takes only unsigned values @@ -185,16 +181,14 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; // Keep the data structure consistent with the case of ELF emission // (important for llvm-mc asm parsing) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; case AArch64BuildAttrs::TAG_FEATURE_BTI: case AArch64BuildAttrs::TAG_FEATURE_GCS: case AArch64BuildAttrs::TAG_FEATURE_PAC: - OS << "\t.aeabi_attribute" << "\t" - << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag) << ", " << Value; - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " + << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; } break; @@ -205,15 +199,13 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; // Keep the data structure consistent with the case of ELF emission // (important for llvm-mc asm parsing) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; case AArch64BuildAttrs::TAG_PAUTH_PLATFORM: case AArch64BuildAttrs::TAG_PAUTH_SCHEMA: - OS << "\t.aeabi_attribute" << "\t" - << AArch64BuildAttrs::getPauthABITagsStr(Tag) << ", " << Value; - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " + << AArch64BuildAttrs::getPauthABITagsStr(Tag); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; } break; @@ -240,8 +232,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { StringRef ParameterStr = getTypeStr(ParameterType); switch (SubsectionID) { - default: { - // Treated as a private subsection + case AArch64BuildAttrs::VENDOR_UNKNOWN: { + // Private subsection break; } case AArch64BuildAttrs::AEABI_PAUTHABI: { @@ -426,13 +418,12 @@ void AArch64TargetELFStreamer::emitAtributesSubsection( } void AArch64TargetELFStreamer::emitAttribute(StringRef VendorName, unsigned Tag, - unsigned Value, std::string String, - bool Override) { + unsigned Value, + std::string String) { if (unsigned(-1) != Value) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); if ("" != String) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String, - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String); } void AArch64TargetELFStreamer::emitInst(uint32_t Inst) { diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp index 1ed4a81a97673..028d9196613cb 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp @@ -15,6 +15,7 @@ #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/ConstantPools.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCELFStreamer.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSubtargetInfo.h" @@ -193,8 +194,7 @@ AArch64TargetStreamer::getAtributesSubsectionByName(StringRef Name) { } void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, - unsigned Value, std::string String, - bool Override) { + unsigned Value, std::string String) { if (unsigned(-1) == Value && "" == String) { assert(0 && "Arguments error"); @@ -214,22 +214,14 @@ void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, return; } for (MCELFStreamer::AttributeItem &Item : SubSection.Content) { + // Tag already exists if (Item.Tag == Tag) { - if (!Override) { - if ((unsigned(-1) != Value && Item.IntValue != Value) || - ("" != String && Item.StringValue != String)) { - assert(0 && - "Can not add AArch64 build attribute: An attribute with " - "the same tag and a different value already exists"); - return; - } else { - // Case Item.IntValue == Value, no need to emit twice - assert(0 && - "AArch64 build attribute: An attribute with the same tag " - "and a same value already exists"); - return; - } - } + Item.Type = unsigned(-1) != Value + ? MCELFStreamer::AttributeItem::NumericAttribute + : MCELFStreamer::AttributeItem::TextAttribute; + Item.IntValue = unsigned(-1) != Value ? Value : unsigned(-1); + Item.StringValue = unsigned(-1) != Value ? "" : String; + return; } } if (unsigned(-1) != Value) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h index 9183fb4cc5f56..9cbb104c0eb9e 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h @@ -100,7 +100,7 @@ class AArch64TargetStreamer : public MCTargetStreamer { AArch64BuildAttrs::SubsectionOptional IsOptional, AArch64BuildAttrs::SubsectionType ParameterType); virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override); + std::string String); void activateAtributesSubsection(StringRef VendorName); std::unique_ptr getActiveAtributesSubsection(); @@ -127,7 +127,7 @@ class AArch64TargetELFStreamer : public AArch64TargetStreamer { StringRef VendorName, AArch64BuildAttrs::SubsectionOptional IsOptional, AArch64BuildAttrs::SubsectionType ParameterType) override; void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override = false) override; + std::string String) override; void emitInst(uint32_t Inst) override; void emitDirectiveVariantPCS(MCSymbol *Symbol) override; void finish() override; diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll b/llvm/test/CodeGen/AArch64/build-attributes-all.ll similarity index 81% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll rename to llvm/test/CodeGen/AArch64/build-attributes-all.ll index aecc74b2ce46d..e2e1e0a384867 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll +++ b/llvm/test/CodeGen/AArch64/build-attributes-all.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1 +; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll b/llvm/test/CodeGen/AArch64/build-attributes-bti.ll similarity index 78% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll rename to llvm/test/CodeGen/AArch64/build-attributes-bti.ll index 8ec78df13be28..92ce2abb795d9 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll +++ b/llvm/test/CodeGen/AArch64/build-attributes-bti.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0 +; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll b/llvm/test/CodeGen/AArch64/build-attributes-gcs.ll similarity index 78% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll rename to llvm/test/CodeGen/AArch64/build-attributes-gcs.ll index be528779e8228..faa77d657aa2e 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll +++ b/llvm/test/CodeGen/AArch64/build-attributes-gcs.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1 +; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll b/llvm/test/CodeGen/AArch64/build-attributes-pac.ll similarity index 78% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll rename to llvm/test/CodeGen/AArch64/build-attributes-pac.ll index e3e5933105426..0358927ad10f5 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll +++ b/llvm/test/CodeGen/AArch64/build-attributes-pac.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0 +; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll b/llvm/test/CodeGen/AArch64/build-attributes-pauthabi.ll similarity index 83% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll rename to llvm/test/CodeGen/AArch64/build-attributes-pauthabi.ll index 35ad514c943a5..1c2a72524d5de 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll +++ b/llvm/test/CodeGen/AArch64/build-attributes-pauthabi.ll @@ -2,8 +2,8 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_PAuth_Platform, 2 -; ASM-NEXT: .aeabi_attribute Tag_PAuth_Schema, 31 +; ASM-NEXT: .aeabi_attribute 1, 2 // Tag_PAuth_Platform +; ASM-NEXT: .aeabi_attribute 2, 31 // Tag_PAuth_Schema ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s deleted file mode 100644 index acbd0101e13fa..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s +++ /dev/null @@ -1,25 +0,0 @@ -// 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_attribute Tag_PAuth_Platform, 1 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth -// ELF-NEXT: 0x00000010 61626900 00000101 02012300 00006165 abi.......#...ae -// ELF-NEXT: 0x00000020 6162695f 66656174 7572655f 616e645f abi_feature_and_ -// ELF-NEXT: 0x00000030 62697473 00010000 01010102 01 - - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 1 -.aeabi_attribute Tag_PAuth_Schema, 1 -.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 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s deleted file mode 100644 index 229033a9f6b70..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s +++ /dev/null @@ -1,51 +0,0 @@ -// 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 private_subsection_1, optional, uleb128 -// ASM: .aeabi_attribute 12, 257 -// ASM: .aeabi_subsection private_subsection_2, required, uleb128 -// ASM: .aeabi_attribute 76, 257 -// ASM: .aeabi_subsection private_subsection_3, optional, ntbs -// ASM: .aeabi_attribute 34, hello_llvm -// ASM: .aeabi_subsection private_subsection_4, required, ntbs -// ASM: .aeabi_attribute 777, "hello_llvm" -// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 -// ASM: .aeabi_attribute 876, 257 -// ASM: .aeabi_subsection private_subsection_2, required, uleb128 -// ASM: .aeabi_attribute 876, 257 -// ASM: .aeabi_subsection private_subsection_3, optional, ntbs -// ASM: .aeabi_attribute 876, "hello_llvm" -// ASM: .aeabi_subsection private_subsection_4, required, ntbs -// ASM: .aeabi_attribute 876, hello_llvm - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41220000 00707269 76617465 5f737562 A"...private_sub -// ELF-NEXT: 0x00000010 73656374 696f6e5f 31000100 0c8102ec section_1....... -// ELF-NEXT: 0x00000020 06810222 00000070 72697661 74655f73 ..."...private_s -// ELF-NEXT: 0x00000030 75627365 6374696f 6e5f3200 00004c81 ubsection_2...L. -// ELF-NEXT: 0x00000040 02ec0681 02360000 00707269 76617465 .....6...private -// ELF-NEXT: 0x00000050 5f737562 73656374 696f6e5f 33000101 _subsection_3... -// ELF-NEXT: 0x00000060 2268656c 6c6f5f6c 6c766d00 ec062268 "hello_llvm..."h -// ELF-NEXT: 0x00000070 656c6c6f 5f6c6c76 6d220037 00000070 ello_llvm".7...p -// ELF-NEXT: 0x00000080 72697661 74655f73 75627365 6374696f rivate_subsectio -// ELF-NEXT: 0x00000090 6e5f3400 00018906 2268656c 6c6f5f6c n_4....."hello_l -// ELF-NEXT: 0x000000a0 6c766d22 00ec0668 656c6c6f 5f6c6c76 lvm"...hello_llv -// ELF-NEXT: 0x000000b0 6d00 m. - - -.aeabi_subsection private_subsection_1, optional, uleb128 -.aeabi_attribute 12, 257 -.aeabi_subsection private_subsection_2, required, uleb128 -.aeabi_attribute 76, 257 -.aeabi_subsection private_subsection_3, optional, ntbs -.aeabi_attribute 34, hello_llvm -.aeabi_subsection private_subsection_4, required, ntbs -.aeabi_attribute 777, "hello_llvm" -.aeabi_subsection private_subsection_1, optional, uleb128 -.aeabi_attribute 876, 257 -.aeabi_subsection private_subsection_2, required, uleb128 -.aeabi_attribute 876, 257 -.aeabi_subsection private_subsection_3, optional, ntbs -.aeabi_attribute 876, "hello_llvm" -.aeabi_subsection private_subsection_4, required, ntbs -.aeabi_attribute 876, hello_llvm diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s new file mode 100644 index 0000000000000..ecd7581e2a136 --- /dev/null +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s @@ -0,0 +1,43 @@ +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth +// ELF-NEXT: 0x00000010 61626900 00000107 02890623 00000061 abi........#...a +// ELF-NEXT: 0x00000020 65616269 5f666561 74757265 5f616e64 eabi_feature_and +// ELF-NEXT: 0x00000030 5f626974 73000100 00010101 0201 _bits......... + + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 7 +.aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_attribute Tag_PAuth_Schema, 777 +.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 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute 1, 7 // Tag_PAuth_Platform +.aeabi_attribute 2, 777 // Tag_PAuth_Schema +.aeabi_attribute 2, 777 // Tag_PAuth_Schema +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute 0, 1 // Tag_Feature_BTI +.aeabi_attribute 1, 1 // Tag_Feature_PAC +.aeabi_attribute 2, 1 // Tag_Feature_GCS diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s similarity index 58% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s index 3897fee99c3ee..3e97acf5a3de4 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s @@ -1,10 +1,10 @@ -// 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 +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-attrs.s similarity index 93% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-attrs.s index ddf8feb9428d2..d509974f508d0 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-attrs.s @@ -1,5 +1,6 @@ // RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s +// Test logic and type mismatch .aeabi_attribute Tag_Feature_BTI, 1 // ERR: error: no active subsection, build attribute can not be added // ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 @@ -9,10 +10,6 @@ // ERR: error: unknown AArch64 build attribute 'Tag_Feature_BTI' for subsection 'aeabi_pauthabi' // ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 -.aeabi_attribute Tag_PAuth_Platform, 4 -// ERR: error: unknown AArch64 build attributes Value for Tag 'Tag_PAuth_Platform' options are 0|1 -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, 4 - .aeabi_attribute a, 1 // ERR: error: unknown AArch64 build attribute 'a' for subsection 'aeabi_pauthabi' // ERR-NEXT: .aeabi_attribute a, 1 @@ -25,6 +22,8 @@ // ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) // ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, a + +// Test syntax errors .aeabi_attribute Tag_PAuth_Platform, // ERR: error: AArch64 build attributes value not found // ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-headers.s similarity index 89% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-headers.s index 9e6dca341e9f8..501958a17bed3 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-headers.s @@ -1,21 +1,6 @@ // RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s -.aeabi_subsection aeabi_pauthabi, optional, uleb128 -// ERR: error: aeabi_pauthabi must be marked as required -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 - -.aeabi_subsection aeabi_pauthabi, required, ntbs -// ERR: error: aeabi_pauthabi must be marked as ULEB128 -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, ntbs - -.aeabi_subsection aeabi_feature_and_bits, required, uleb128 -// ERR: error: aeabi_feature_and_bits must be marked as optional -// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, required, uleb128 - -.aeabi_subsection aeabi_feature_and_bits, optional, ntbs -// ERR: error: aeabi_feature_and_bits must be marked as ULEB128 -// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, optional, ntbs - +// Test syntax errors .aeabi_subsection 1, required, uleb128 // ERR: error: subsection name not found // ERR-NEXT: .aeabi_subsection 1, required, uleb128 @@ -25,11 +10,7 @@ // ERR-NEXT: .aeabi_subsection , required, uleb128 .aeabi_subsection aeabi_pauthabi, a, uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: a -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, a, uleb128 - -.aeabi_subsection aeabi_pauthabi, a, uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: a +// ERR: error: unknown AArch64 build attributes optionality, expected required|optional // ERR-NEXT: .aeabi_subsection aeabi_pauthabi, a, uleb128 .aeabi_subsection aeabi_pauthabi, 1, uleb128 @@ -41,7 +22,7 @@ // ERR-NEXT: .aeabi_subsection aeabi_pauthabi, ,uleb128 .aeabi_subsection aeabi_pauthabi,uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: uleb128 +// ERR: error: unknown AArch64 build attributes optionality, expected required|optional // ERR-NEXT: .aeabi_subsection aeabi_pauthabi,uleb128 .aeabi_subsection aeabi_pauthabi uleb128 @@ -57,5 +38,27 @@ // ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, .aeabi_subsection aeabi_pauthabi, required, a -// ERR: error: unknown AArch64 build attributes type, expected uleb128|ntbs: a +// ERR: error: unknown AArch64 build attributes type, expected uleb128|ntbs // ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, a + +.aeabi_subsection aeabi_pauthabi, optional, uleb128 +// ERR: error: aeabi_pauthabi must be marked as required +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 + + +// Test types mismatch +.aeabi_subsection aeabi_pauthabi, optional, uleb128 +// ERR: error: aeabi_pauthabi must be marked as required +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 + +.aeabi_subsection aeabi_pauthabi, required, ntbs +// ERR: error: aeabi_pauthabi must be marked as ULEB128 +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, ntbs + +.aeabi_subsection aeabi_feature_and_bits, required, uleb128 +// ERR: error: aeabi_feature_and_bits must be marked as optional +// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, required, uleb128 + +.aeabi_subsection aeabi_feature_and_bits, optional, ntbs +// ERR: error: aeabi_feature_and_bits must be marked as ULEB128 +// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, optional, ntbs diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s similarity index 58% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s index 5cb7e6835e5c1..177d2499e2005 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s @@ -1,10 +1,10 @@ -// 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 +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s new file mode 100644 index 0000000000000..96bb59b8cd0a5 --- /dev/null +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s @@ -0,0 +1,50 @@ +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection subsection_a, optional, uleb128 +// ASM: .aeabi_subsection aeabi_subsection, optional, ntbs +// ASM: .aeabi_subsection subsection_b, required, uleb128 +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 9 // Tag_PAuth_Platform +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS +// ASM: .aeabi_subsection aeabi_subsection, optional, ntbs +// ASM: .aeabi_attribute 5, "Value" +// ASM: .aeabi_subsection subsection_b, required, uleb128 +// ASM: .aeabi_attribute 6, 536 +// ASM: .aeabi_subsection subsection_a, optional, uleb128 +// ASM: .aeabi_attribute 7, 11 + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41150000 00737562 73656374 696f6e5f A....subsection_ +// ELF-NEXT: 0x00000010 61000100 070b2000 00006165 6162695f a..... ...aeabi_ +// ELF-NEXT: 0x00000020 73756273 65637469 6f6e0001 01052256 subsection...."V +// ELF-NEXT: 0x00000030 616c7565 22001600 00007375 62736563 alue".....subsec +// ELF-NEXT: 0x00000040 74696f6e 5f620000 00069804 1a000000 tion_b.......... +// ELF-NEXT: 0x00000050 61656162 695f7061 75746861 62690000 aeabi_pauthabi.. +// ELF-NEXT: 0x00000060 00010902 89062300 00006165 6162695f ......#...aeabi_ +// ELF-NEXT: 0x00000070 66656174 7572655f 616e645f 62697473 feature_and_bits +// ELF-NEXT: 0x00000080 00010000 01010102 01 ......... + + +.aeabi_subsection subsection_a, optional, uleb128 +.aeabi_subsection aeabi_subsection, optional, ntbs +.aeabi_subsection subsection_b, required, uleb128 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 7 +.aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_attribute Tag_PAuth_Platform, 9 +.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 +.aeabi_subsection aeabi_subsection, optional, ntbs +.aeabi_attribute 5, "Value" +.aeabi_subsection subsection_b, required, uleb128 +.aeabi_attribute 6, 536 +.aeabi_subsection subsection_a, optional, uleb128 +.aeabi_attribute 7, 11 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-none.s similarity index 68% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-none.s index a3cbbe270dffe..0b60b8c47d049 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-none.s @@ -1,13 +1,13 @@ // 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_attribute Tag_PAuth_Platform, 0 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 0 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 0 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 0 // Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-numerical-tags.s similarity index 82% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-numerical-tags.s index 047939d2efd6c..25b6a1836bba9 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-numerical-tags.s @@ -2,15 +2,15 @@ // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_attribute 0, 1 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 1 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 +// ASM: .aeabi_attribute 1, 1 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 1 // Tag_PAuth_Schema // ASM: .aeabi_attribute 3, 1 // ASM: .aeabi_attribute 4, 1 // ASM: .aeabi_attribute 5, 1 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_attribute 3, 1 // ASM: .aeabi_attribute 4, 1 // ASM: .aeabi_attribute 5, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-out-of-order.s similarity index 89% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-out-of-order.s index 2d5d42561aa6f..c4192cddb1f2e 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-out-of-order.s @@ -3,18 +3,18 @@ // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 +// ASM: .aeabi_attribute 2, 1 // Tag_PAuth_Schema // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 1 +// ASM: .aeabi_attribute 1, 1 // Tag_PAuth_Platform // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_attribute 7, 1 // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-pac.s similarity index 67% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-pac.s index e3191acf31141..228e2be8af88a 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-pac.s @@ -2,9 +2,9 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu @@ -13,6 +13,6 @@ .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 0 -.aeabi_attribute Tag_Feature_PAC, 1 -.aeabi_attribute Tag_Feature_GCS, 0 +.aeabi_attribute 0, 0 // Tag_Feature_BTI +.aeabi_attribute 1, 1 // Tag_Feature_PAC +.aeabi_attribute 2, 0 // Tag_Feature_GCS diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi-err.s similarity index 87% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s rename to llvm/test/MC/AArch64/build-attributes-asm-non_aeabi-err.s index 5884a74f989cc..6e28481aeb97b 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi-err.s @@ -15,6 +15,11 @@ // ERR: error: active subsection type is NTBS (string), found ULEB128 (unsigned) // ERR-NEXT: .aeabi_attribute 324, 1 +.aeabi_attribute str_not_int, "1" +// ERR: error: unrecognized Tag: 'str_not_int' +// ERR-NEXT: Except for public subsections, tags have to be an unsigned int. +// ERR-NEXT: .aeabi_attribute str_not_int, "1" + .aeabi_subsection foo, optional, uleb128 .aeabi_subsection bar, optional, uleb128 .aeabi_subsection foo, required, uleb128 diff --git a/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi.s b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi.s new file mode 100644 index 0000000000000..ef55a3cfc89de --- /dev/null +++ b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi.s @@ -0,0 +1,49 @@ +// 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 private_subsection_1, optional, uleb128 +// ASM: .aeabi_attribute 12, 257 +// ASM: .aeabi_subsection aeabi_2, required, uleb128 +// ASM: .aeabi_attribute 76, 257 +// ASM: .aeabi_subsection aeabi_3, optional, ntbs +// ASM: .aeabi_attribute 34, hello_llvm +// ASM: .aeabi_subsection private_subsection_4, required, ntbs +// ASM: .aeabi_attribute 777, "hello_llvm" +// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 +// ASM: .aeabi_attribute 876, 257 +// ASM: .aeabi_subsection aeabi_2, required, uleb128 +// ASM: .aeabi_attribute 876, 257 +// ASM: .aeabi_subsection aeabi_3, optional, ntbs +// ASM: .aeabi_attribute 876, "hello_llvm" +// ASM: .aeabi_subsection private_subsection_4, required, ntbs +// ASM: .aeabi_attribute 876, hello_llvm + +// ELF: Hex dump of section '.ARM.attributes': +// ELF: 0x00000000 41220000 00707269 76617465 5f737562 A"...private_sub +// ELF: 0x00000010 73656374 696f6e5f 31000100 0c8102ec section_1....... +// ELF: 0x00000020 06810215 00000061 65616269 5f320000 .......aeabi_2.. +// ELF: 0x00000030 004c8102 ec068102 29000000 61656162 .L......)...aeab +// ELF: 0x00000040 695f3300 01012268 656c6c6f 5f6c6c76 i_3..."hello_llv +// ELF: 0x00000050 6d00ec06 2268656c 6c6f5f6c 6c766d22 m..."hello_llvm" +// ELF: 0x00000060 00370000 00707269 76617465 5f737562 .7...private_sub +// ELF: 0x00000070 73656374 696f6e5f 34000001 89062268 section_4....."h +// ELF: 0x00000080 656c6c6f 5f6c6c76 6d2200ec 0668656c ello_llvm"...hel +// ELF: 0x00000090 6c6f5f6c 6c766d00 lo_llvm. + + +.aeabi_subsection private_subsection_1, optional, uleb128 +.aeabi_attribute 12, 257 +.aeabi_subsection aeabi_2, required, uleb128 +.aeabi_attribute 76, 257 +.aeabi_subsection aeabi_3, optional, ntbs +.aeabi_attribute 34, hello_llvm +.aeabi_subsection private_subsection_4, required, ntbs +.aeabi_attribute 777, "hello_llvm" +.aeabi_subsection private_subsection_1, optional, uleb128 +.aeabi_attribute 876, 257 +.aeabi_subsection aeabi_2, required, uleb128 +.aeabi_attribute 876, 257 +.aeabi_subsection aeabi_3, optional, ntbs +.aeabi_attribute 876, "hello_llvm" +.aeabi_subsection private_subsection_4, required, ntbs +.aeabi_attribute 876, hello_llvm