From 9ae2d05d45f76a86fe220d2f39fe0a042dfc97fa Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 26 Dec 2010 21:30:59 +0000 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20@note.=20Patch=20by=20J?= =?UTF-8?q?=C3=B6rg=20Sonnenberger.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llvm-svn: 122568 --- llvm/lib/MC/ELFObjectWriter.cpp | 1 + llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 ++ llvm/lib/MC/MCSectionELF.cpp | 2 ++ llvm/test/MC/ELF/section.s | 15 ++++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index ef6e0f14141c..5ff12bc01f0b 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1265,6 +1265,7 @@ void ELFObjectWriter::WriteSection(MCAssembler &Asm, case ELF::SHT_PROGBITS: case ELF::SHT_STRTAB: case ELF::SHT_NOBITS: + case ELF::SHT_NOTE: case ELF::SHT_NULL: case ELF::SHT_ARM_ATTRIBUTES: // Nothing to do. diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 0aa89c20a2f8..0456b4bac4c3 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -335,6 +335,8 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { Type = MCSectionELF::SHT_NOBITS; else if (TypeName == "progbits") Type = MCSectionELF::SHT_PROGBITS; + else if (TypeName == "note") + Type = MCSectionELF::SHT_NOTE; else return TokError("unknown section type"); } diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index 59568adf7085..a53489790d28 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -92,6 +92,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << "preinit_array"; else if (Type == MCSectionELF::SHT_NOBITS) OS << "nobits"; + else if (Type == MCSectionELF::SHT_NOTE) + OS << "note"; else if (Type == MCSectionELF::SHT_PROGBITS) OS << "progbits"; diff --git a/llvm/test/MC/ELF/section.s b/llvm/test/MC/ELF/section.s index 38cf8ad4356b..8e40ae8c0419 100644 --- a/llvm/test/MC/ELF/section.s +++ b/llvm/test/MC/ELF/section.s @@ -12,7 +12,7 @@ // CHECK: ('sh_name', 0x00000033) # '.note.GNU-' // CHECK: ('sh_name', 0x0000003e) # '-.note.GNU' -// Test that the dafults are used +// Test that the defaults are used .section .init .section .fini @@ -67,6 +67,19 @@ // CHECK-NEXT: ('sh_entsize', 0x00000000) // CHECK-NEXT: ), +.section .note.test,"",@note +// CHECK: (('sh_name', 0x00000061) # '.note.test' +// CHECK-NEXT: ('sh_type', 0x00000007) +// CHECK-NEXT: ('sh_flags', 0x00000000) +// CHECK-NEXT: ('sh_addr', 0x00000000) +// CHECK-NEXT: ('sh_offset', 0x00000050) +// CHECK-NEXT: ('sh_size', 0x00000000) +// CHECK-NEXT: ('sh_link', 0x00000000) +// CHECK-NEXT: ('sh_info', 0x00000000) +// CHECK-NEXT: ('sh_addralign', 0x00000001) +// CHECK-NEXT: ('sh_entsize', 0x00000000) +// CHECK-NEXT: ), + // Test that we can parse these foo: bar: