]> granicus.if.org Git - llvm/commitdiff
[llvm-nm] Fix output formatting of -f sysv for 64bit targets
authorSam Clegg <sbc@chromium.org>
Thu, 31 Aug 2017 21:23:44 +0000 (21:23 +0000)
committerSam Clegg <sbc@chromium.org>
Thu, 31 Aug 2017 21:23:44 +0000 (21:23 +0000)
Differential Revision: https://reviews.llvm.org/D37347

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

test/tools/llvm-nm/X86/Inputs/hello.obj.elf-i386 [new file with mode: 0644]
test/tools/llvm-nm/X86/sysv-i386.test [new file with mode: 0644]
test/tools/llvm-nm/X86/sysv-x86_64.test [new file with mode: 0644]
tools/llvm-nm/llvm-nm.cpp

diff --git a/test/tools/llvm-nm/X86/Inputs/hello.obj.elf-i386 b/test/tools/llvm-nm/X86/Inputs/hello.obj.elf-i386
new file mode 100644 (file)
index 0000000..d14b8d7
Binary files /dev/null and b/test/tools/llvm-nm/X86/Inputs/hello.obj.elf-i386 differ
diff --git a/test/tools/llvm-nm/X86/sysv-i386.test b/test/tools/llvm-nm/X86/sysv-i386.test
new file mode 100644 (file)
index 0000000..b9b1f60
--- /dev/null
@@ -0,0 +1,6 @@
+RUN: llvm-nm -f sysv %p/Inputs/hello.obj.elf-i386 | FileCheck %s --strict-whitespace
+
+CHECK: Name                  Value   Class        Type         Size     Line  Section
+CHECK: .L.str              |00000000|   r  |                  |0000000f|     |
+CHECK: main                |00000000|   T  |                  |00000015|     |
+CHECK: puts                |        |   U  |                  |        |     |
diff --git a/test/tools/llvm-nm/X86/sysv-x86_64.test b/test/tools/llvm-nm/X86/sysv-x86_64.test
new file mode 100644 (file)
index 0000000..bf041b2
--- /dev/null
@@ -0,0 +1,13 @@
+RUN: llvm-nm -f sysv %p/Inputs/hello.obj.elf-x86_64 | FileCheck %s --check-prefix=ELF --strict-whitespace
+RUN: llvm-nm -f sysv %p/Inputs/hello.obj.macho-x86_64 2>&1 | FileCheck %s --check-prefix=MACHO --strict-whitespace
+
+ELF: Name                  Value           Class        Type         Size             Line  Section
+ELF: main                |0000000000000000|   T  |                  |0000000000000015|     |
+ELF: puts                |                |   U  |                  |                |     |
+
+MACHO: Name                  Value           Class        Type         Size             Line  Section
+MACHO: EH_frame0           |0000000000000068|   s  |                  |0000000000000000|     |
+MACHO: L_.str              |000000000000003b|   s  |                  |0000000000000000|     |
+MACHO: _main               |0000000000000000|   T  |                  |0000000000000000|     |
+MACHO: _main.eh            |0000000000000080|   S  |                  |0000000000000000|     |
+MACHO: _printf             |                |   U  |                  |                |     |
index 126a9ae925e24e9badbfee6bbebfd5147e52736c..1934051c65d7bb0db1b7781ba4d1396240c735b7 100644 (file)
@@ -709,9 +709,13 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
     } else if (OutputFormat == bsd && MultipleFiles && printName) {
       outs() << "\n" << CurrentFilename << ":\n";
     } else if (OutputFormat == sysv) {
-      outs() << "\n\nSymbols from " << CurrentFilename << ":\n\n"
-             << "Name                  Value   Class        Type"
-             << "         Size   Line  Section\n";
+      outs() << "\n\nSymbols from " << CurrentFilename << ":\n\n";
+      if (isSymbolList64Bit(Obj))
+        outs() << "Name                  Value           Class        Type"
+               << "         Size             Line  Section\n";
+      else
+        outs() << "Name                  Value   Class        Type"
+               << "         Size     Line  Section\n";
     }
   }