# CHECK-NOT: __start:
# CHECK-NOT: 0000000100000d22
# CHECK-NOT: _main:
+
+# not RUN: llvm-objdump -m -d %p/Inputs/exeThread.macho-x86_64 -dis-symname _environ 2>&1 | FileCheck -check-prefix BAD-SYMAME-1 %s
+BAD-SYMAME-1: -dis-symname: _environ not in the section
+
+# not RUN: llvm-objdump -m -d %p/Inputs/exeThread.macho-x86_64 -dis-symname __mh_execute_header 2>&1 | FileCheck -check-prefix BAD-SYMAME-2 %s
+BAD-SYMAME-2: -dis-symname: __mh_execute_header not in any section
--- /dev/null
+// RUN: llvm-objdump -d -m -no-show-raw-insn -full-leading-addr -print-imm-hex %p/Inputs/hello.exe.stripped.macho-x86_64 | FileCheck %s
+
+CHECK: (__TEXT,__text) section
+CHECK: 0000000100000f30 pushq %rbp
+CHECK: 0000000100000f31 movq %rsp, %rbp
+CHECK: 0000000100000f34 subq $0x20, %rsp
// Make sure the symbol is defined in this section.
bool containsSym = Sections[SectIdx].containsSymbol(Symbols[SymIdx]);
- if (!containsSym)
+ if (!containsSym) {
+ if (!DisSymName.empty() && DisSymName == SymName) {
+ outs() << "-dis-symname: " << DisSymName << " not in the section\n";
+ return;
+ }
+ continue;
+ }
+ // The __mh_execute_header is special and we need to deal with that fact
+ // this symbol is before the start of the (__TEXT,__text) section and at the
+ // address of the start of the __TEXT segment. This is because this symbol
+ // is an N_SECT symbol in the (__TEXT,__text) but its address is before the
+ // start of the section in a standard MH_EXECUTE filetype.
+ if (!DisSymName.empty() && DisSymName == "__mh_execute_header") {
+ outs() << "-dis-symname: __mh_execute_header not in any section\n";
+ return;
+ }
+ // When this code is trying to disassemble a symbol at a time and in the case
+ // there is only the __mh_execute_header symbol left as in a stripped
+ // executable, we need to deal with this by ignoring this symbol so the whole
+ // section is disassembled and this symbol is then not displayed.
+ if (SymName == "__mh_execute_header")
continue;
// If we are only disassembling one symbol see if this is that symbol.