[llvm] r190769 - ELF: Add support for the exclude section bit for gas compat.
Benjamin Kramer
benny.kra at googlemail.com
Sun Sep 15 12:53:20 PDT 2013
Author: d0k
Date: Sun Sep 15 14:53:20 2013
New Revision: 190769
URL: http://llvm.org/viewvc/llvm-project?rev=190769&view=rev
Log:
ELF: Add support for the exclude section bit for gas compat.
Modified:
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
llvm/trunk/lib/MC/MCSectionELF.cpp
llvm/trunk/lib/Object/ELFYAML.cpp
llvm/trunk/test/MC/ELF/section.s
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Sun Sep 15 14:53:20 2013
@@ -1196,6 +1196,9 @@ enum {
// This section holds Thread-Local Storage.
SHF_TLS = 0x400U,
+ // This section is excluded from the final executable or shared library.
+ SHF_EXCLUDE = 0x80000000U,
+
// Start of target-specific flags.
/// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Sun Sep 15 14:53:20 2013
@@ -279,14 +279,17 @@ static SectionKind computeSectionKind(un
return SectionKind::getDataRel();
}
-static int parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
- int flags = 0;
+static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
+ unsigned flags = 0;
for (unsigned i = 0; i < flagsStr.size(); i++) {
switch (flagsStr[i]) {
case 'a':
flags |= ELF::SHF_ALLOC;
break;
+ case 'e':
+ flags |= ELF::SHF_EXCLUDE;
+ break;
case 'x':
flags |= ELF::SHF_EXECINSTR;
break;
@@ -315,7 +318,7 @@ static int parseSectionFlags(StringRef f
*UseLastGroup = true;
break;
default:
- return -1;
+ return -1U;
}
}
@@ -381,8 +384,8 @@ bool ELFAsmParser::ParseSectionArguments
StringRef FlagsStr = getTok().getStringContents();
Lex();
- int extraFlags = parseSectionFlags(FlagsStr, &UseLastGroup);
- if (extraFlags < 0)
+ unsigned extraFlags = parseSectionFlags(FlagsStr, &UseLastGroup);
+ if (extraFlags == -1U)
return TokError("unknown flag");
Flags |= extraFlags;
Modified: llvm/trunk/lib/MC/MCSectionELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionELF.cpp?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSectionELF.cpp (original)
+++ llvm/trunk/lib/MC/MCSectionELF.cpp Sun Sep 15 14:53:20 2013
@@ -75,6 +75,8 @@ void MCSectionELF::PrintSwitchToSection(
OS << ",#execinstr";
if (Flags & ELF::SHF_WRITE)
OS << ",#write";
+ if (Flags & ELF::SHF_EXCLUDE)
+ OS << ",#exclude";
if (Flags & ELF::SHF_TLS)
OS << ",#tls";
OS << '\n';
@@ -84,6 +86,8 @@ void MCSectionELF::PrintSwitchToSection(
OS << ",\"";
if (Flags & ELF::SHF_ALLOC)
OS << 'a';
+ if (Flags & ELF::SHF_EXCLUDE)
+ OS << 'e';
if (Flags & ELF::SHF_EXECINSTR)
OS << 'x';
if (Flags & ELF::SHF_GROUP)
Modified: llvm/trunk/lib/Object/ELFYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFYAML.cpp (original)
+++ llvm/trunk/lib/Object/ELFYAML.cpp Sun Sep 15 14:53:20 2013
@@ -266,6 +266,7 @@ void ScalarBitSetTraits<ELFYAML::ELF_SHF
#define BCase(X) IO.bitSetCase(Value, #X, ELF::X);
BCase(SHF_WRITE)
BCase(SHF_ALLOC)
+ BCase(SHF_EXCLUDE)
BCase(SHF_EXECINSTR)
BCase(SHF_MERGE)
BCase(SHF_STRINGS)
Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Sun Sep 15 14:53:20 2013
@@ -8,9 +8,9 @@
.section -.note.GNU,"", at progbits
// CHECK: Name: .note.GNU-stack (56)
-// CHECK: Name: .note.GNU-stack2 (143)
-// CHECK: Name: .note.GNU- (160)
-// CHECK: Name: -.note.GNU (132)
+// CHECK: Name: .note.GNU-stack2 (153)
+// CHECK: Name: .note.GNU- (170)
+// CHECK: Name: -.note.GNU (142)
// Test that the defaults are used
@@ -120,11 +120,28 @@ bar:
// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: }
+.section .excluded,"e", at progbits
+
+// CHECK: Section {
+// CHECK: Name: .excluded (92)
+// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT: Flags [ (0x80000000)
+// CHECK-NEXT: SHF_EXCLUDE (0x80000000)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x0
+// CHECK-NEXT: Offset: 0x50
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 1
+// CHECK-NEXT: EntrySize: 0
+// CHECK-NEXT: }
+
// Test that we handle the strings like gas
.section bar-"foo"
.section "foo"
// CHECK: Section {
-// CHECK: Name: bar-"foo" (171)
+// CHECK: Name: bar-"foo" (181)
// CHECK: Section {
// CHECK: Name: foo (52)
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=190769&r1=190768&r2=190769&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Sun Sep 15 14:53:20 2013
@@ -377,6 +377,7 @@ static const char *getElfSectionType(uns
static const EnumEntry<unsigned> ElfSectionFlags[] = {
LLVM_READOBJ_ENUM_ENT(ELF, SHF_WRITE ),
LLVM_READOBJ_ENUM_ENT(ELF, SHF_ALLOC ),
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_EXCLUDE ),
LLVM_READOBJ_ENUM_ENT(ELF, SHF_EXECINSTR ),
LLVM_READOBJ_ENUM_ENT(ELF, SHF_MERGE ),
LLVM_READOBJ_ENUM_ENT(ELF, SHF_STRINGS ),
More information about the llvm-commits
mailing list