[PATCH] D33978: MC, Object: Reserve a section type, SHT_LLVM_ODRTAB, for the ODR table.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 23:11:54 PDT 2017
pcc created this revision.
Herald added a subscriber: emaste.
Herald added a reviewer: hiraditya.
This is part of the ODR checker proposal:
http://lists.llvm.org/pipermail/llvm-dev/2017-June/113820.html
It appears [1] that binutils' most recent section type number
allocations in the OS-specific range have been of the form 0x6fff47XX,
where 0x47 ('G') presumably stands for GNU. So I have taken the
bold step of using 0x6fff4c00, where 0x4c ('L') stands for LLVM. If
this seems reasonable I will contact gnu-gabi to reserve the entire
0x6fff4cXX range for LLVM.
[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=elfcpp/elfcpp.h;h=cce40d41dedb281c2d8f41135250c2cc39162469;hb=HEAD#l369
https://reviews.llvm.org/D33978
Files:
llvm/include/llvm/BinaryFormat/ELF.h
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/lib/MC/MCSectionELF.cpp
llvm/lib/Object/ELF.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/MC/ELF/section.s
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2592,6 +2592,8 @@
return "GROUP";
case SHT_SYMTAB_SHNDX:
return "SYMTAB SECTION INDICES";
+ case SHT_LLVM_ODRTAB:
+ return "LLVM_ODRTAB";
// FIXME: Parse processor specific GNU attributes
case SHT_GNU_ATTRIBUTES:
return "ATTRIBUTES";
Index: llvm/test/MC/ELF/section.s
===================================================================
--- llvm/test/MC/ELF/section.s
+++ llvm/test/MC/ELF/section.s
@@ -267,3 +267,15 @@
// CHECK-NEXT: SHF_TLS
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
+
+// Test SHT_LLVM_ODRTAB
+
+.section .odrtab,"e", at llvm_odrtab
+// ASM: .section .odrtab,"e", at llvm_odrtab
+
+// CHECK: Section {
+// CHECK: Name: .odrtab
+// CHECK-NEXT: Type: SHT_LLVM_ODRTAB
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_EXCLUDE
+// CHECK-NEXT: ]
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -372,6 +372,7 @@
ECase(SHT_GROUP);
ECase(SHT_SYMTAB_SHNDX);
ECase(SHT_LOOS);
+ ECase(SHT_LLVM_ODRTAB);
ECase(SHT_GNU_ATTRIBUTES);
ECase(SHT_GNU_HASH);
ECase(SHT_GNU_verdef);
Index: llvm/lib/Object/ELF.cpp
===================================================================
--- llvm/lib/Object/ELF.cpp
+++ llvm/lib/Object/ELF.cpp
@@ -192,6 +192,7 @@
STRINGIFY_ENUM_CASE(ELF, SHT_PREINIT_ARRAY);
STRINGIFY_ENUM_CASE(ELF, SHT_GROUP);
STRINGIFY_ENUM_CASE(ELF, SHT_SYMTAB_SHNDX);
+ STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_ODRTAB);
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_ATTRIBUTES);
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_HASH);
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_verdef);
Index: llvm/lib/MC/MCSectionELF.cpp
===================================================================
--- llvm/lib/MC/MCSectionELF.cpp
+++ llvm/lib/MC/MCSectionELF.cpp
@@ -147,6 +147,8 @@
// Print hex value of the flag while we do not have
// any standard symbolic representation of the flag.
OS << "0x7000001e";
+ else if (Type == ELF::SHT_LLVM_ODRTAB)
+ OS << "llvm_odrtab";
else
report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) +
" for section " + getSectionName());
Index: llvm/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -603,6 +603,8 @@
Type = ELF::SHT_NOTE;
else if (TypeName == "unwind")
Type = ELF::SHT_X86_64_UNWIND;
+ else if (TypeName == "llvm_odrtab")
+ Type = ELF::SHT_LLVM_ODRTAB;
else if (TypeName.getAsInteger(0, Type))
return TokError("unknown section type");
}
Index: llvm/include/llvm/BinaryFormat/ELF.h
===================================================================
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -683,6 +683,7 @@
SHT_GROUP = 17, // Section group.
SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries.
SHT_LOOS = 0x60000000, // Lowest operating system-specific type.
+ SHT_LLVM_ODRTAB = 0x6fff4c00, // LLVM ODR table.
SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes.
SHT_GNU_HASH = 0x6ffffff6, // GNU-style hash table.
SHT_GNU_verdef = 0x6ffffffd, // GNU version definitions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33978.101669.patch
Type: text/x-patch
Size: 3602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170607/b49025de/attachment.bin>
More information about the llvm-commits
mailing list