[llvm] r368451 - Print reasonable representations of type names in llvm-nm, readelf and readobj

Sunil Srivastava via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 9 09:54:51 PDT 2019


Author: ssrivastava
Date: Fri Aug  9 09:54:51 2019
New Revision: 368451

URL: http://llvm.org/viewvc/llvm-project?rev=368451&view=rev
Log:
Print reasonable representations of type names in llvm-nm, readelf and readobj

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


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

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Fri Aug  9 09:54:51 2019
@@ -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;

Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Fri Aug  9 09:54:51 2019
@@ -43,7 +43,16 @@ const EnumEntry<unsigned> llvm::object::
     {"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) {}

Modified: llvm/trunk/test/tools/llvm-nm/format-sysv-type.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/format-sysv-type.test?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/format-sysv-type.test (original)
+++ llvm/trunk/test/tools/llvm-nm/format-sysv-type.test Fri Aug  9 09:54:51 2019
@@ -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*

Modified: llvm/trunk/test/tools/llvm-readobj/elf-symbol-types.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-symbol-types.test?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/elf-symbol-types.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/elf-symbol-types.test Fri Aug  9 09:54:51 2019
@@ -22,12 +22,25 @@
 # 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
@@ -37,9 +50,14 @@
 # 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

Modified: llvm/trunk/test/tools/yaml2obj/symbol-type.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/symbol-type.yaml?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/symbol-type.yaml (original)
+++ llvm/trunk/test/tools/yaml2obj/symbol-type.yaml Fri Aug  9 09:54:51 2019
@@ -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




More information about the llvm-commits mailing list