Add the option, -non-verbose to llvm-objdump used with -macho to print things

using numeric values and not their symbolic constant names.

The routines that print Mach-O stuff already had a verbose parameter and this
change is just changing the passing true to passing !NonVerbose.  With just a
couple of fixes and a bunch of test case updates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232182 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kevin Enderby 2015-03-13 17:56:32 +00:00
parent 2ccb127ba0
commit 300c79d840
11 changed files with 192 additions and 16 deletions

View File

@ -1,4 +1,5 @@
RUN: llvm-objdump -m -data-in-code %p/Inputs/data-in-code.macho-arm | FileCheck %s
RUN: llvm-objdump -m -data-in-code -non-verbose %p/Inputs/data-in-code.macho-arm | FileCheck %s -check-prefix=NON_VERBOSE
CHECK: Data in code table (4 entries)
CHECK: offset length kind
@ -6,3 +7,10 @@ CHECK: 0x00000000 4 DATA
CHECK: 0x00000004 4 JUMP_TABLE32
CHECK: 0x00000008 2 JUMP_TABLE16
CHECK: 0x0000000a 1 JUMP_TABLE8
NON_VERBOSE: Data in code table (4 entries)
NON_VERBOSE: offset length kind
NON_VERBOSE: 0x00000000 4 0x0001
NON_VERBOSE: 0x00000004 4 0x0004
NON_VERBOSE: 0x00000008 2 0x0003
NON_VERBOSE: 0x0000000a 1 0x0002

View File

@ -1,4 +1,8 @@
RUN: llvm-objdump -m -section __TEXT,__cstring %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
RUN: llvm-objdump -m -section __TEXT,__cstring -non-verbose %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s -check-prefix=NON_VERBOSE
CHECK: Contents of (__TEXT,__cstring) section
CHECK: 000000000000003b Hello world\n
NON_VERBOSE: Contents of (__TEXT,__cstring) section
NON_VERBOSE: 000000000000003b 48 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00

View File

@ -1,4 +1,5 @@
RUN: llvm-objdump -macho -indirect-symbols %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s
RUN: llvm-objdump -macho -indirect-symbols -non-verbose %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s -check-prefix=NON_VERBOSE
CHECK: Indirect symbols for (__TEXT,__stubs) 1 entries
CHECK: address index name
@ -10,3 +11,14 @@ CHECK: 0x0000000100001008 ABSOLUTE
CHECK: Indirect symbols for (__DATA,__la_symbol_ptr) 1 entries
CHECK: address index name
CHECK: 0x0000000100001010 2 _printf
NON_VERBOSE: Indirect symbols for (__TEXT,__stubs) 1 entries
NON_VERBOSE: address index
NON_VERBOSE: 0x0000000100000f6c 2
NON_VERBOSE: Indirect symbols for (__DATA,__nl_symbol_ptr) 2 entries
NON_VERBOSE: address index
NON_VERBOSE: 0x0000000100001000 3
NON_VERBOSE: 0x0000000100001008 ABSOLUTE
NON_VERBOSE: Indirect symbols for (__DATA,__la_symbol_ptr) 1 entries
NON_VERBOSE: address index
NON_VERBOSE: 0x0000000100001010 2

View File

@ -1,4 +1,5 @@
# RUN: llvm-mc < %s -triple i386-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp - | FileCheck %s
# RUN: llvm-mc < %s -triple i386-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp -non-verbose - | FileCheck %s -check-prefix=NON-VERBOSE
.cstring
L1: .asciz "Hello world\n"
@ -32,3 +33,7 @@ L5: .asciz "const non-literal string"
# CHECK: 00000054 __TEXT:__literal8:0x00000000 0x40200000
# CHECK: 00000058 __TEXT:__literal16:0x10000016 0x20000016 0x30000016 0x40000016
# CHECK: 0000005c 0x30 (not in a literal section)
# NON-VERBOSE: Contents of (__DATA,__litp) section
# NON-VERBOSE: 0000004c 00 00 00 00 10 00 00 00 18 00 00 00 20 00 00 00
# NON-VERBOSE: 0000005c 30 00 00 00

View File

@ -1,4 +1,5 @@
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp - | FileCheck %s
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp -non-verbose - | FileCheck %s -check-prefix=NON-VERBOSE
.cstring
L1: .asciz "Hello world\n"
@ -32,3 +33,8 @@ L5: .asciz "const non-literal string"
# CHECK: 0000000000000060 __TEXT:__literal8:0x00000000 0x40200000
# CHECK: 0000000000000068 __TEXT:__literal16:0x10000016 0x20000016 0x30000016 0x40000016
# CHECK: 0000000000000070 0x30 (not in a literal section)
# NON-VERBOSE: Contents of (__DATA,__litp) section
# NON-VERBOSE: 0000000000000050 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00
# NON-VERBOSE: 0000000000000060 18 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00
# NON-VERBOSE: 0000000000000070 30 00 00 00 00 00 00 00

View File

@ -1,6 +1,9 @@
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal4 - | FileCheck %s -check-prefix=CHECK-LIT4
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal4 -non-verbose - | FileCheck %s -check-prefix=NON-VERBOSE-LIT4
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal8 - | FileCheck %s -check-prefix=CHECK-LIT8
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal8 -non-verbose - | FileCheck %s -check-prefix=NON-VERBOSE-LIT8
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal16 - | FileCheck %s -check-prefix=CHECK-LIT16
# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __TEXT,__literal16 -non-verbose - | FileCheck %s -check-prefix=NON-VERBOSE-LIT16
.literal4
.float 2.5
@ -18,6 +21,10 @@
# CHECK-LIT4: 0000000000000010 0x7fc00000
# CHECK-LIT4: 0000000000000014 0x7f800001
# NON-VERBOSE-LIT4: Contents of (__TEXT,__literal4) section
# NON-VERBOSE-LIT4: 0000000000000000 00 00 20 40 00 00 04 41 00 00 80 7f 00 00 80 ff
# NON-VERBOSE-LIT4: 0000000000000010 00 00 c0 7f 01 00 80 7f
.literal8
.double 2.5
.double 8.25
@ -38,6 +45,11 @@
# CHECK-LIT8: 0000000000000038 0x00000000 0x7ff80000
# CHECK-LIT8: 0000000000000040 0x00000001 0x7ff00000
# NON-VERBOSE-LIT8: Contents of (__TEXT,__literal8) section
# NON-VERBOSE-LIT8: 0000000000000018 00 00 00 00 00 00 04 40 00 00 00 00 00 80 20 40
# NON-VERBOSE-LIT8: 0000000000000028 00 00 00 00 00 00 f0 7f 00 00 00 00 00 00 f0 ff
# NON-VERBOSE-LIT8: 0000000000000038 00 00 00 00 00 00 f8 7f 01 00 00 00 00 00 f0 7f
.literal16
.long 1
.long 2
@ -46,3 +58,6 @@
# CHECK-LIT16: Contents of (__TEXT,__literal16) section
# CHECK-LIT16: 0000000000000050 0x00000001 0x00000002 0x00000003 0x00000004
# NON-VERBOSE-LIT16: Contents of (__TEXT,__literal16) section
# NON-VERBOSE-LIT16: 0000000000000050 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00

View File

@ -19,6 +19,8 @@
// RUN: | FileCheck %s -check-prefix=THREAD
// RUN: llvm-objdump -macho -p -arch i386 %p/Inputs/macho-universal.x86_64.i386 \
// RUN: | FileCheck %s -check-prefix=FATi386
// RUN: llvm-objdump -p -non-verbose %p/Inputs/hello.obj.macho-x86_64 \
// RUN: | FileCheck %s -check-prefix=NON_VERBOSE
CHECK: Mach header
CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
@ -443,3 +445,95 @@ THREAD: gs 0x0000000000000000
FATi386: Mach header
FATi386: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
FATi386: MH_MAGIC I386 ALL 0x00 EXECUTE 16 716 NOUNDEFS DYLDLINK TWOLEVEL PIE MH_NO_HEAP_EXECUTION
NON_VERBOSE: Mach header
NON_VERBOSE: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
NON_VERBOSE: 0xfeedfacf 16777223 3 0x00 1 3 496 0x00002000
NON_VERBOSE: Load command 0
NON_VERBOSE: cmd LC_SEGMENT_64
NON_VERBOSE: cmdsize 392
NON_VERBOSE: segname
NON_VERBOSE: vmaddr 0x0000000000000000
NON_VERBOSE: vmsize 0x00000000000000a8
NON_VERBOSE: fileoff 528
NON_VERBOSE: filesize 168
NON_VERBOSE: maxprot 0x00000007
NON_VERBOSE: initprot 0x00000007
NON_VERBOSE: nsects 4
NON_VERBOSE: flags 0x0
NON_VERBOSE: Section
NON_VERBOSE: sectname __text
NON_VERBOSE: segname __TEXT
NON_VERBOSE: addr 0x0000000000000000
NON_VERBOSE: size 0x000000000000003b
NON_VERBOSE: offset 528
NON_VERBOSE: align 2^4 (16)
NON_VERBOSE: reloff 696
NON_VERBOSE: nreloc 2
NON_VERBOSE: flags 0x80000400
NON_VERBOSE: reserved1 0
NON_VERBOSE: reserved2 0
NON_VERBOSE: Section
NON_VERBOSE: sectname __cstring
NON_VERBOSE: segname __TEXT
NON_VERBOSE: addr 0x000000000000003b
NON_VERBOSE: size 0x000000000000000d
NON_VERBOSE: offset 587
NON_VERBOSE: align 2^0 (1)
NON_VERBOSE: reloff 0
NON_VERBOSE: nreloc 0
NON_VERBOSE: flags 0x00000002
NON_VERBOSE: reserved1 0
NON_VERBOSE: reserved2 0
NON_VERBOSE: Section
NON_VERBOSE: sectname __compact_unwind
NON_VERBOSE: segname __LD
NON_VERBOSE: addr 0x0000000000000048
NON_VERBOSE: size 0x0000000000000020
NON_VERBOSE: offset 600
NON_VERBOSE: align 2^3 (8)
NON_VERBOSE: reloff 712
NON_VERBOSE: nreloc 1
NON_VERBOSE: flags 0x02000000
NON_VERBOSE: reserved1 0
NON_VERBOSE: reserved2 0
NON_VERBOSE: Section
NON_VERBOSE: sectname __eh_frame
NON_VERBOSE: segname __TEXT
NON_VERBOSE: addr 0x0000000000000068
NON_VERBOSE: size 0x0000000000000040
NON_VERBOSE: offset 632
NON_VERBOSE: align 2^3 (8)
NON_VERBOSE: reloff 0
NON_VERBOSE: nreloc 0
NON_VERBOSE: flags 0x6800000b
NON_VERBOSE: reserved1 0
NON_VERBOSE: reserved2 0
NON_VERBOSE: Load command 1
NON_VERBOSE: cmd LC_SYMTAB
NON_VERBOSE: cmdsize 24
NON_VERBOSE: symoff 720
NON_VERBOSE: nsyms 5
NON_VERBOSE: stroff 800
NON_VERBOSE: strsize 44
NON_VERBOSE: Load command 2
NON_VERBOSE: cmd LC_DYSYMTAB
NON_VERBOSE: cmdsize 80
NON_VERBOSE: ilocalsym 0
NON_VERBOSE: nlocalsym 2
NON_VERBOSE: iextdefsym 2
NON_VERBOSE: nextdefsym 2
NON_VERBOSE: iundefsym 4
NON_VERBOSE: nundefsym 1
NON_VERBOSE: tocoff 0
NON_VERBOSE: ntoc 0
NON_VERBOSE: modtaboff 0
NON_VERBOSE: nmodtab 0
NON_VERBOSE: extrefsymoff 0
NON_VERBOSE: nextrefsyms 0
NON_VERBOSE: indirectsymoff 0
NON_VERBOSE: nindirectsyms 0
NON_VERBOSE: extreloff 0
NON_VERBOSE: nextrel 0
NON_VERBOSE: locreloff 0
NON_VERBOSE: nlocrel 0

View File

@ -1,4 +1,8 @@
// RUN: llvm-objdump -m -section __DATA,__mod_init_func %p/Inputs/dylibModInit.macho-x86_64 | FileCheck %s -check-prefix=MODINIT
// RUN: llvm-objdump -m -section __DATA,__mod_init_func -non-verbose %p/Inputs/dylibModInit.macho-x86_64 | FileCheck %s -check-prefix=NON_VERBOSE
MODINIT: Contents of (__DATA,__mod_init_func) section
MODINIT: 0x0000000000001000 0x0000000000000f30 _libinit
NON_VERBOSE: Contents of (__DATA,__mod_init_func) section
NON_VERBOSE: 0000000000001000 30 0f 00 00 00 00 00 00

View File

@ -4,6 +4,8 @@ RUN: llvm-objdump %p/Inputs/macho-universal-archive.x86_64.i386 -d -m -no-show-r
RUN: | FileCheck %s -check-prefix UArchive-i386
RUN: llvm-objdump %p/Inputs/macho-universal.x86_64.i386 -universal-headers -m \
RUN: | FileCheck %s -check-prefix FAT
RUN: llvm-objdump %p/Inputs/macho-universal.x86_64.i386 -universal-headers -m \
RUN: -non-verbose | FileCheck %s -check-prefix NON-VERBOSE
UEXE-all: macho-universal.x86_64.i386 (architecture x86_64):
UEXE-all: (__TEXT,__text) section
@ -42,3 +44,21 @@ FAT: capabilities 0x0
FAT: offset 12288
FAT: size 4336
FAT: align 2^12 (4096)
NON-VERBOSE: Fat headers
NON-VERBOSE: fat_magic 0xcafebabe
NON-VERBOSE: nfat_arch 2
NON-VERBOSE: architecture 0
NON-VERBOSE: cputype 16777223
NON-VERBOSE: cpusubtype 3
NON-VERBOSE: capabilities 0x80
NON-VERBOSE: offset 4096
NON-VERBOSE: size 4360
NON-VERBOSE: align 2^12 (4096)
NON-VERBOSE: architecture 1
NON-VERBOSE: cputype 7
NON-VERBOSE: cpusubtype 3
NON-VERBOSE: capabilities 0x0
NON-VERBOSE: offset 12288
NON-VERBOSE: size 4336
NON-VERBOSE: align 2^12 (4096)

View File

@ -101,6 +101,11 @@ cl::opt<bool>
cl::desc("Print the info plist section as strings for "
"Mach-O objects (requires -macho)"));
cl::opt<bool>
llvm::NonVerbose("non-verbose",
cl::desc("Print the info for Mach-O objects in "
"non-verbose or numeric form (requires -macho)"));
static cl::list<std::string>
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
cl::ZeroOrMore);
@ -328,15 +333,17 @@ static void PrintIndirectSymbolTable(MachOObjectFile *O, bool verbose,
continue;
}
outs() << format("%5u ", indirect_symbol);
MachO::symtab_command Symtab = O->getSymtabLoadCommand();
if (indirect_symbol < Symtab.nsyms) {
symbol_iterator Sym = O->getSymbolByIndex(indirect_symbol);
SymbolRef Symbol = *Sym;
StringRef SymName;
Symbol.getName(SymName);
outs() << SymName;
} else {
outs() << "?";
if (verbose) {
MachO::symtab_command Symtab = O->getSymtabLoadCommand();
if (indirect_symbol < Symtab.nsyms) {
symbol_iterator Sym = O->getSymbolByIndex(indirect_symbol);
SymbolRef Symbol = *Sym;
StringRef SymName;
Symbol.getName(SymName);
outs() << SymName;
} else {
outs() << "?";
}
}
outs() << "\n";
}
@ -899,7 +906,7 @@ static void DumpRawSectionContents(MachOObjectFile *O, const char *sect,
if (O->is64Bit())
outs() << format("%016" PRIx64, addr) << "\t";
else
outs() << format("%08" PRIx64, sect) << "\t";
outs() << format("%08" PRIx64, addr) << "\t";
for (j = 0; j < 16 && i + j < size; j++) {
uint8_t byte_word = *(sect + i + j);
outs() << format("%02" PRIx32, (uint32_t)byte_word) << " ";
@ -1111,9 +1118,9 @@ static void ProcessMachO(StringRef Filename, MachOObjectFile *MachOOF,
if (Disassemble)
DisassembleMachO(Filename, MachOOF, "__TEXT", "__text");
if (IndirectSymbols)
PrintIndirectSymbols(MachOOF, true);
PrintIndirectSymbols(MachOOF, !NonVerbose);
if (DataInCode)
PrintDataInCodeTable(MachOOF, true);
PrintDataInCodeTable(MachOOF, !NonVerbose);
if (LinkOptHints)
PrintLinkOptHints(MachOOF);
if (Relocations)
@ -1123,7 +1130,7 @@ static void ProcessMachO(StringRef Filename, MachOObjectFile *MachOOF,
if (SectionContents)
PrintSectionContents(MachOOF);
if (DumpSections.size() != 0)
DumpSectionContents(Filename, MachOOF, true);
DumpSectionContents(Filename, MachOOF, !NonVerbose);
if (InfoPlist)
DumpInfoPlistSectionContents(Filename, MachOOF);
if (SymbolTable)
@ -1462,7 +1469,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
}
if (UniversalHeaders) {
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin))
printMachOUniversalHeaders(UB, true);
printMachOUniversalHeaders(UB, !NonVerbose);
}
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin)) {
// If we have a list of architecture flags specified dump only those.
@ -5461,8 +5468,8 @@ void llvm::printMachOFileHeader(const object::ObjectFile *Obj) {
uint32_t ncmds = 0;
uint32_t filetype = 0;
uint32_t cputype = 0;
getAndPrintMachHeader(file, ncmds, filetype, cputype, true);
PrintLoadCommands(file, ncmds, filetype, cputype, true);
getAndPrintMachHeader(file, ncmds, filetype, cputype, !NonVerbose);
PrintLoadCommands(file, ncmds, filetype, cputype, !NonVerbose);
}
//===----------------------------------------------------------------------===//

View File

@ -41,6 +41,7 @@ extern cl::opt<bool> IndirectSymbols;
extern cl::opt<bool> DataInCode;
extern cl::opt<bool> LinkOptHints;
extern cl::opt<bool> InfoPlist;
extern cl::opt<bool> NonVerbose;
extern cl::opt<bool> Relocations;
extern cl::opt<bool> SectionHeaders;
extern cl::opt<bool> SectionContents;