Fix the output of llvm-nm for Mach-O files to use the characters ‘d’ and ‘b’ for
authorKevin Enderby <enderby@apple.com>
Thu, 19 Jun 2014 22:49:21 +0000 (22:49 +0000)
committerKevin Enderby <enderby@apple.com>
Thu, 19 Jun 2014 22:49:21 +0000 (22:49 +0000)
data and bss symbols instead of the generic ’s’ for a symbol in a section.

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

test/Object/nm-trivial-object.test
test/Object/nm-universal-binary.test
tools/llvm-nm/llvm-nm.cpp

index 20ac6621e72876860c2c3e4364d86a73ee9f2069..c53dc91ecd4c6a47c3673ed1f7e2c9deba0e0309 100644 (file)
@@ -14,6 +14,8 @@ RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \
 RUN:         | FileCheck %s -check-prefix macho
 RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
 RUN:         | FileCheck %s -check-prefix macho64
 RUN:         | FileCheck %s -check-prefix macho
 RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
 RUN:         | FileCheck %s -check-prefix macho64
+RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
+RUN:         | FileCheck %s -check-prefix macho-tdb
 RUN: llvm-nm %p/Inputs/common.coff-i386 \
 RUN:         | FileCheck %s -check-prefix COFF-COMMON
 RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
 RUN: llvm-nm %p/Inputs/common.coff-i386 \
 RUN:         | FileCheck %s -check-prefix COFF-COMMON
 RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
@@ -64,6 +66,11 @@ macho64:                  U _SomeOtherFunction
 macho64: 0000000000000000 T _main
 macho64:                  U _puts
 
 macho64: 0000000000000000 T _main
 macho64:                  U _puts
 
+macho-tdb: 0000000000000030 s EH_frame0
+macho-tdb: 0000000000000070 b _b
+macho-tdb: 000000000000000c D _d
+macho-tdb: 0000000000000000 T _t
+macho-tdb: 0000000000000048 S _t.eh
 
 Test that nm uses addresses even with ELF .o files.
 ELF-SEC-ADDR64:      0000000000000058 D a
 
 Test that nm uses addresses even with ELF .o files.
 ELF-SEC-ADDR64:      0000000000000058 D a
index 52781267c5cbb9944a0aa2541eea06803bdf2d9c..8992359a79b6df34c5509cf26b936190a8566e64 100644 (file)
@@ -15,5 +15,5 @@ CHECK-AR: 0000000000000000 T _main
 CHECK-AR: 0000000000000080 S _main.eh
 CHECK-AR:                  U _printf
 CHECK-AR: macho-universal-archive.x86_64.i386(foo.o) (for architecture i386):
 CHECK-AR: 0000000000000080 S _main.eh
 CHECK-AR:                  U _printf
 CHECK-AR: macho-universal-archive.x86_64.i386(foo.o) (for architecture i386):
-CHECK-AR: 00000008 S _bar
+CHECK-AR: 00000008 D _bar
 CHECK-AR: 00000000 T _foo
 CHECK-AR: 00000000 T _foo
index c6b80d1dd965eeff39693493a2511deb62dd8a16..5062435d8971e467eb6ef6ae2257b44b172882ce 100644 (file)
@@ -577,6 +577,10 @@ static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) {
     StringRef SegmentName = Obj.getSectionFinalSegmentName(Ref);
     if (SegmentName == "__TEXT" && SectionName == "__text")
       return 't';
     StringRef SegmentName = Obj.getSectionFinalSegmentName(Ref);
     if (SegmentName == "__TEXT" && SectionName == "__text")
       return 't';
+    else if (SegmentName == "__DATA" && SectionName == "__data")
+      return 'd';
+    else if (SegmentName == "__DATA" && SectionName == "__bss")
+      return 'b';
     else
       return 's';
   }
     else
       return 's';
   }