]> granicus.if.org Git - llvm/commitdiff
Print reasonable representations of type names in llvm-nm, readelf and readobj
authorSunil Srivastava <sunil_srivastava@playstation.sony.com>
Fri, 9 Aug 2019 16:54:51 +0000 (16:54 +0000)
committerSunil Srivastava <sunil_srivastava@playstation.sony.com>
Fri, 9 Aug 2019 16:54:51 +0000 (16:54 +0000)
For type values that do not have proper names, print reasonable representation
in llvm-nm, llvm-readobj and llvm-readelf, matching GNU tools.s

Fixes PR41713.

Differential Revision: https://reviews.llvm.org/D65537

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368451 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELFObjectFile.h
lib/Object/ELFObjectFile.cpp
test/tools/llvm-nm/format-sysv-type.test
test/tools/llvm-readobj/elf-symbol-types.test
test/tools/yaml2obj/symbol-type.yaml

index 86c015efd704e55fd2ae4c65a40a58f90ad4723d..c4527b3435ff3cdc420bf343d779431422a5f7c0 100644 (file)
@@ -41,7 +41,7 @@
 namespace llvm {
 namespace object {
 
-constexpr int NumElfSymbolTypes = 8;
+constexpr int NumElfSymbolTypes = 16;
 extern const llvm::EnumEntry<unsigned> ElfSymbolTypes[NumElfSymbolTypes];
 
 class elf_symbol_iterator;
index c7b715793048c28cbc12cb384ff48af33eb096e5..9945018d957da2cc831495e0421da21d5e652387 100644 (file)
@@ -43,7 +43,16 @@ const EnumEntry<unsigned> llvm::object::ElfSymbolTypes[NumElfSymbolTypes] = {
     {"File", "FILE", ELF::STT_FILE},
     {"Common", "COMMON", ELF::STT_COMMON},
     {"TLS", "TLS", ELF::STT_TLS},
-    {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC}};
+    {"Unknown", "<unknown>: 7", 7},
+    {"Unknown", "<unknown>: 8", 8},
+    {"Unknown", "<unknown>: 9", 9},
+    {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC},
+    {"OS Specific", "<OS specific>: 11", 11},
+    {"OS Specific", "<OS specific>: 12", 12},
+    {"Proc Specific", "<processor specific>: 13", 13},
+    {"Proc Specific", "<processor specific>: 14", 14},
+    {"Proc Specific", "<processor specific>: 15", 15}
+};
 
 ELFObjectFileBase::ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source)
     : ObjectFile(Type, Source) {}
index a8bf1b5ef419654f3c0aad3e0553d282fcfa0aeb..68b376aecab19b6d8652a82fb785f934dd9307fb 100644 (file)
@@ -20,25 +20,40 @@ Symbols:
     Type: STT_OBJECT
   - Name: symbol_func
     Type: STT_FUNC
+  - Name: unknown_7
+    Type: 7
+  - Name: unknown_8
+    Type: 8
+  - Name: unknown_9
+    Type: 9
   - Name: symbol_ifunc
     Type: STT_GNU_IFUNC
-  - Name: os_specific
+  - Name: os_specific_10
+    Type: 10
+  - Name: os_specific_11
     Type: 11
-  - Name: proc_specific
+  - Name: os_specific_12
+    Type: 12
+  - Name: proc_specific_13
     Type: 13
-  - Name: unknown
-    Type: 7
-
-## FIXME: Should not print blank types for unknown, OS-specific and processor-
-##        specific types. See https://bugs.llvm.org/show_bug.cgi?id=41713.
+  - Name: proc_specific_14
+    Type: 14
+  - Name: proc_specific_15
+    Type: 15
 
-# CHECK:      os_specific   {{.*}}|                  |                |     |*UND*
-# CHECK-NEXT: proc_specific {{.*}}|                  |                |     |*UND*
-# CHECK-NEXT: symbol_common {{.*}}|            COMMON|                |     |*COM*
-# CHECK-NEXT: symbol_file   {{.*}}|              FILE|                |     |*UND*
-# CHECK-NEXT: symbol_func   {{.*}}|              FUNC|                |     |*UND*
-# CHECK-NEXT: symbol_ifunc  {{.*}}|             IFUNC|                |     |*UND*
-# CHECK-NEXT: symbol_notype {{.*}}|            NOTYPE|                |     |*UND*
-# CHECK-NEXT: symbol_obj    {{.*}}|            OBJECT|                |     |*UND*
-# CHECK-NEXT: symbol_tls    {{.*}}|               TLS|                |     |*UND*
-# CHECK-NEXT: unknown       {{.*}}|                  |                |     |*UND*
+# CHECK:      os_specific_10      |                |   U  |             IFUNC|                |     |*UND*
+# CHECK-NEXT: os_specific_11      |                |   U  | <OS specific>: 11|                |     |*UND*
+# CHECK-NEXT: os_specific_12      |                |   U  | <OS specific>: 12|                |     |*UND*
+# CHECK-NEXT: proc_specific_13    |                |   U  |<processor specific>: 13|                |     |*UND*
+# CHECK-NEXT: proc_specific_14    |                |   U  |<processor specific>: 14|                |     |*UND*
+# CHECK-NEXT: proc_specific_15    |                |   U  |<processor specific>: 15|                |     |*UND*
+# CHECK-NEXT: symbol_common       |                |   U  |            COMMON|                |     |*COM*
+# CHECK-NEXT: symbol_file         |                |   U  |              FILE|                |     |*UND*
+# CHECK-NEXT: symbol_func         |                |   U  |              FUNC|                |     |*UND*
+# CHECK-NEXT: symbol_ifunc        |                |   U  |             IFUNC|                |     |*UND*
+# CHECK-NEXT: symbol_notype       |                |   U  |            NOTYPE|                |     |*UND*
+# CHECK-NEXT: symbol_obj          |                |   U  |            OBJECT|                |     |*UND*
+# CHECK-NEXT: symbol_tls          |                |   U  |               TLS|                |     |*UND*
+# CHECK-NEXT: unknown_7           |                |   U  |      <unknown>: 7|                |     |*UND*
+# CHECK-NEXT: unknown_8           |                |   U  |      <unknown>: 8|                |     |*UND*
+# CHECK-NEXT: unknown_9           |                |   U  |      <unknown>: 9|                |     |*UND*
index 8d46b1624765c91920549ab28c2c6d0767a4db56..3d0ba4a48082203001695eab92143f95efe1a676 100644 (file)
 # LLVM: Type: TLS
 # LLVM: Name: gnu_ifunc
 # LLVM: Type: GNU_IFunc
-# LLVM: Name: os_specific
-# LLVM: Type: 0xB
-# LLVM: Name: proc_specific
-# LLVM: Type: 0xD
-# LLVM: Name: unknown
-# LLVM: Type: 0x7
+
+# LLVM: Name: os_specific_11
+# LLVM: Type: OS Specific (0xB)
+# LLVM: Name: os_specific_12
+# LLVM: Type: OS Specific (0xC)
+
+# LLVM: Name: proc_specific_13
+# LLVM: Type: Proc Specific (0xD)
+# LLVM: Name: proc_specific_14
+# LLVM: Type: Proc Specific (0xE)
+# LLVM: Name: proc_specific_15
+# LLVM: Type: Proc Specific (0xF)
+
+# LLVM: Name: unknown_7
+# LLVM: Type: Unknown (0x7)
+# LLVM: Name: unknown_8
+# LLVM: Type: Unknown (0x8)
+# LLVM: Name: unknown_9
+# LLVM: Type: Unknown (0x9)
 
 # GNU: NOTYPE  {{.*}} notype
 # GNU: OBJECT  {{.*}} object
 # GNU: COMMON  {{.*}} common
 # GNU: TLS     {{.*}} tls
 # GNU: IFUNC   {{.*}} gnu_ifunc
-# GNU: b       {{.*}} os_specific
-# GNU: d       {{.*}} proc_specific
-# GNU: 7       {{.*}} unknown
+# GNU: <OS specific>: 11       {{.*}} os_specific_11
+# GNU: <OS specific>: 12       {{.*}} os_specific_12
+# GNU: <processor specific>: 13       {{.*}} proc_specific_13
+# GNU: <processor specific>: 14       {{.*}} proc_specific_14
+# GNU: <processor specific>: 15       {{.*}} proc_specific_15
+# GNU: <unknown>: 7       {{.*}} unknown_7
+# GNU: <unknown>: 8       {{.*}} unknown_8
+# GNU: <unknown>: 9       {{.*}} unknown_9
 
 !ELF
 FileHeader:
@@ -76,12 +94,27 @@ Symbols:
   - Name:    gnu_ifunc
     Type:    STT_GNU_IFUNC
     Binding: STB_GLOBAL
-  - Name:    os_specific
+  - Name:    os_specific_11
     Type:    11
     Binding: STB_GLOBAL
-  - Name:    proc_specific
+  - Name:    os_specific_12
+    Type:    12
+    Binding: STB_GLOBAL
+  - Name:    proc_specific_13
     Type:    13
     Binding: STB_GLOBAL
-  - Name:    unknown
+  - Name:    proc_specific_14
+    Type:    14
+    Binding: STB_GLOBAL
+  - Name:    proc_specific_15
+    Type:    15
+    Binding: STB_GLOBAL
+  - Name:    unknown_7
     Type:    7
     Binding: STB_GLOBAL
+  - Name:    unknown_8
+    Type:    8
+    Binding: STB_GLOBAL
+  - Name:    unknown_9
+    Type:    9
+    Binding: STB_GLOBAL
index 5b3bb73c43b5fedadac6cbce5b1a696e727c748d..2eec6a46fd86c4c7a4b6874ce330cfe6bb0ada9b 100644 (file)
@@ -9,12 +9,14 @@
 # CHECK: Type: Section
 # CHECK: Name: known_hex
 # CHECK: Type: Object
-# CHECK: Name: unknown_hex
-# CHECK: Type: 0xB
+
+# CHECK: Name: unknown_hex_11
+# CHECK: Type: OS Specific (0xB)
+
 # CHECK: Name: known_int
 # CHECK: Type: Object
 # CHECK: Name: unknown_int
-# CHECK: Type: 0xB
+# CHECK: Type: OS Specific (0xB)
 
 !ELF
 FileHeader:
@@ -38,7 +40,7 @@ Symbols:
   - Name:    known_hex
     Type:    0x1
     Binding: STB_GLOBAL
-  - Name:    unknown_hex
+  - Name:    unknown_hex_11
     Type:    0xb
     Binding: STB_GLOBAL
   - Name:    known_int